Skip to content

Commit f54f279

Browse files
committed
Merge pull request #403 from espindola/newllvm
Update rust to build with newer llvm versions.
2 parents 08dcb93 + 698022d commit f54f279

File tree

5 files changed

+26
-15
lines changed

5 files changed

+26
-15
lines changed

src/comp/back/link.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ mod write {
153153
True, // unit-at-a-time
154154
True, // unroll loops
155155
True, // simplify lib calls
156-
True, // have exceptions
157156
threshold); // inline threshold
158157
}
159158

src/comp/lib/llvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ const uint LLVMNoImplicitFloatAttribute = 8388608u;
8888
const uint LLVMNakedAttribute = 16777216u;
8989
const uint LLVMInlineHintAttribute = 33554432u;
9090
const uint LLVMStackAttribute = 469762048u; // 7 << 26
91+
const uint LLVMUWTableAttribute = 1073741824u; // 1 << 30
9192

9293

9394
// Consts for the LLVM IntPredicate type, pre-cast to uint.
@@ -813,7 +814,6 @@ native mod llvm = llvm_lib {
813814
Bool UnitAtATime,
814815
Bool UnrollLoops,
815816
Bool SimplifyLibCalls,
816-
Bool HaveExceptions,
817817
uint InliningThreshold);
818818

819819
/** Destroys a memory buffer. */

src/comp/middle/trans.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1820,6 +1820,11 @@ fn set_no_inline(ValueRef f) {
18201820
lib::llvm::llvm::Attribute);
18211821
}
18221822

1823+
fn set_uwtable(ValueRef f) {
1824+
llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMUWTableAttribute as
1825+
lib::llvm::llvm::Attribute);
1826+
}
1827+
18231828
fn set_always_inline(ValueRef f) {
18241829
llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMAlwaysInlineAttribute as
18251830
lib::llvm::llvm::Attribute);
@@ -6962,6 +6967,7 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ast::def_id fid,
69626967
option::t[ty_self_pair] ty_self,
69636968
&vec[ast::ty_param] ty_params, &ast::ann ann) {
69646969
auto llfndecl = cx.ccx.item_ids.get(fid);
6970+
set_uwtable(llfndecl);
69656971

69666972
// Set up arguments to the function.
69676973
auto fcx = new_fn_ctxt(cx, sp, llfndecl);

src/rustllvm/Passes2.cpp

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "llvm/Analysis/Passes.h"
2-
#include "llvm/Support/StandardPasses.h"
2+
#include "llvm/Support/PassManagerBuilder.h"
33
#include "llvm/PassManager.h"
44
#include "llvm-c/Core.h"
55
#include <cstdlib>
@@ -8,22 +8,29 @@ using namespace llvm;
88

99
extern "C" void LLVMAddStandardFunctionPasses(LLVMPassManagerRef PM,
1010
unsigned int OptimizationLevel) {
11-
createStandardFunctionPasses(unwrap(PM), OptimizationLevel);
11+
PassManagerBuilder PMBuilder;
12+
PMBuilder.OptLevel = OptimizationLevel;
13+
FunctionPassManager *FPM = (FunctionPassManager*) unwrap(PM);
14+
PMBuilder.populateFunctionPassManager(*FPM);
1215
}
1316

1417
extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
1518
unsigned int OptimizationLevel, LLVMBool OptimizeSize,
1619
LLVMBool UnitAtATime, LLVMBool UnrollLoops, LLVMBool SimplifyLibCalls,
17-
LLVMBool HaveExceptions, unsigned int InliningThreshold) {
18-
Pass *InliningPass;
20+
unsigned int InliningThreshold) {
21+
22+
PassManagerBuilder PMBuilder;
23+
PMBuilder.OptLevel = OptimizationLevel;
24+
PMBuilder.SizeLevel = OptimizeSize;
25+
PMBuilder.DisableUnitAtATime = !UnitAtATime;
26+
PMBuilder.DisableUnrollLoops = !UnrollLoops;
27+
28+
PMBuilder.DisableSimplifyLibCalls = !SimplifyLibCalls;
29+
1930
if (InliningThreshold)
20-
InliningPass = createFunctionInliningPass(InliningThreshold);
21-
else
22-
InliningPass = NULL;
31+
PMBuilder.Inliner = createFunctionInliningPass(InliningThreshold);
2332

24-
createStandardModulePasses(unwrap(PM), OptimizationLevel, OptimizeSize,
25-
UnitAtATime, UnrollLoops, SimplifyLibCalls,
26-
HaveExceptions, InliningPass);
33+
PassManager *MPM = (PassManager*) unwrap(PM);
34+
PMBuilder.populateModulePassManager(*MPM);
2735
}
2836

29-

src/rustllvm/RustWrapper.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ extern "C" const char *LLVMRustGetLastError(void) {
4747
extern "C" void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
4848
extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
4949
unsigned int OptimizationLevel, bool OptimizeSize, bool UnitAtATime,
50-
bool UnrollLoops, bool SimplifyLibCalls, bool HaveExceptions,
50+
bool UnrollLoops, bool SimplifyLibCalls,
5151
unsigned int InliningThreshold);
5252

5353
int *RustHackToFetchPassesO = (int*)LLVMAddBasicAliasAnalysisPass;
@@ -80,7 +80,6 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
8080
LLVMCodeGenFileType FileType) {
8181

8282
// Set compilation options.
83-
llvm::UnwindTablesMandatory = true;
8483
llvm::NoFramePointerElim = true;
8584

8685
InitializeAllTargets();

0 commit comments

Comments
 (0)