Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rust to build with newer llvm versions. #403

Merged
merged 1 commit into from
Jun 8, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion src/comp/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,6 @@ mod write {
True, // unit-at-a-time
True, // unroll loops
True, // simplify lib calls
True, // have exceptions
threshold); // inline threshold
}

Expand Down
2 changes: 1 addition & 1 deletion src/comp/lib/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const uint LLVMNoImplicitFloatAttribute = 8388608u;
const uint LLVMNakedAttribute = 16777216u;
const uint LLVMInlineHintAttribute = 33554432u;
const uint LLVMStackAttribute = 469762048u; // 7 << 26
const uint LLVMUWTableAttribute = 1073741824u; // 1 << 30


// Consts for the LLVM IntPredicate type, pre-cast to uint.
Expand Down Expand Up @@ -813,7 +814,6 @@ native mod llvm = llvm_lib {
Bool UnitAtATime,
Bool UnrollLoops,
Bool SimplifyLibCalls,
Bool HaveExceptions,
uint InliningThreshold);

/** Destroys a memory buffer. */
Expand Down
6 changes: 6 additions & 0 deletions src/comp/middle/trans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1820,6 +1820,11 @@ fn set_no_inline(ValueRef f) {
lib::llvm::llvm::Attribute);
}

fn set_uwtable(ValueRef f) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMUWTableAttribute as
lib::llvm::llvm::Attribute);
}

fn set_always_inline(ValueRef f) {
llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMAlwaysInlineAttribute as
lib::llvm::llvm::Attribute);
Expand Down Expand Up @@ -6962,6 +6967,7 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ast::def_id fid,
option::t[ty_self_pair] ty_self,
&vec[ast::ty_param] ty_params, &ast::ann ann) {
auto llfndecl = cx.ccx.item_ids.get(fid);
set_uwtable(llfndecl);

// Set up arguments to the function.
auto fcx = new_fn_ctxt(cx, sp, llfndecl);
Expand Down
29 changes: 18 additions & 11 deletions src/rustllvm/Passes2.cpp
Original file line number Diff line number Diff line change
@@ -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>
Expand All @@ -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;
unsigned int InliningThreshold) {

PassManagerBuilder PMBuilder;
PMBuilder.OptLevel = OptimizationLevel;
PMBuilder.SizeLevel = OptimizeSize;
PMBuilder.DisableUnitAtATime = !UnitAtATime;
PMBuilder.DisableUnrollLoops = !UnrollLoops;

PMBuilder.DisableSimplifyLibCalls = !SimplifyLibCalls;

if (InliningThreshold)
InliningPass = createFunctionInliningPass(InliningThreshold);
else
InliningPass = NULL;
PMBuilder.Inliner = createFunctionInliningPass(InliningThreshold);

createStandardModulePasses(unwrap(PM), OptimizationLevel, OptimizeSize,
UnitAtATime, UnrollLoops, SimplifyLibCalls,
HaveExceptions, InliningPass);
PassManager *MPM = (PassManager*) unwrap(PM);
PMBuilder.populateModulePassManager(*MPM);
}


3 changes: 1 addition & 2 deletions src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -80,7 +80,6 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
LLVMCodeGenFileType FileType) {

// Set compilation options.
llvm::UnwindTablesMandatory = true;
llvm::NoFramePointerElim = true;

InitializeAllTargets();
Expand Down