Update rust to build with newer llvm versions.

This commit is contained in:
Rafael Ávila de Espíndola
2011-05-24 13:47:27 -04:00
parent d360c481e8
commit 698022d351
5 changed files with 27 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
#include "llvm/Analysis/Passes.h"
#include "llvm/Support/StandardPasses.h"
#include "llvm/Support/PassManagerBuilder.h"
#include "llvm/PassManager.h"
#include "llvm-c/Core.h"
#include <cstdlib>
@@ -8,22 +8,29 @@ using namespace llvm;
extern "C" void LLVMAddStandardFunctionPasses(LLVMPassManagerRef PM,
unsigned int OptimizationLevel) {
createStandardFunctionPasses(unwrap(PM), OptimizationLevel);
PassManagerBuilder PMBuilder;
PMBuilder.OptLevel = OptimizationLevel;
FunctionPassManager *FPM = (FunctionPassManager*) unwrap(PM);
PMBuilder.populateFunctionPassManager(*FPM);
}
extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
unsigned int OptimizationLevel, LLVMBool OptimizeSize,
LLVMBool UnitAtATime, LLVMBool UnrollLoops, LLVMBool SimplifyLibCalls,
LLVMBool HaveExceptions, unsigned int InliningThreshold) {
Pass *InliningPass;
if (InliningThreshold)
InliningPass = createFunctionInliningPass(InliningThreshold);
else
InliningPass = NULL;
unsigned int InliningThreshold) {
createStandardModulePasses(unwrap(PM), OptimizationLevel, OptimizeSize,
UnitAtATime, UnrollLoops, SimplifyLibCalls,
HaveExceptions, InliningPass);
PassManagerBuilder PMBuilder;
PMBuilder.OptLevel = OptimizationLevel;
PMBuilder.SizeLevel = OptimizeSize;
PMBuilder.DisableUnitAtATime = !UnitAtATime;
PMBuilder.DisableUnrollLoops = !UnrollLoops;
PMBuilder.DisableSimplifyLibCalls = !SimplifyLibCalls;
if (InliningThreshold)
PMBuilder.Inliner = createFunctionInliningPass(InliningThreshold);
PassManager *MPM = (PassManager*) unwrap(PM);
PMBuilder.populateModulePassManager(*MPM);
}

View File

@@ -47,7 +47,7 @@ extern "C" const char *LLVMRustGetLastError(void) {
extern "C" void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
unsigned int OptimizationLevel, bool OptimizeSize, bool UnitAtATime,
bool UnrollLoops, bool SimplifyLibCalls, bool HaveExceptions,
bool UnrollLoops, bool SimplifyLibCalls,
unsigned int InliningThreshold);
int *RustHackToFetchPassesO = (int*)LLVMAddBasicAliasAnalysisPass;
@@ -80,7 +80,6 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
LLVMCodeGenFileType FileType) {
// Set compilation options.
llvm::UnwindTablesMandatory = true;
llvm::NoFramePointerElim = true;
InitializeAllTargets();