Skip to content

Commit cf64c32

Browse files
committed
auto merge of #7115 : alexcrichton/rust/llvm-upgrades, r=Aatch
This is a reopening of #6713 This is still blocked on windows failures. I'll re-push try once the existing crisis has passed.
2 parents b055a10 + 5bdbe9d commit cf64c32

File tree

10 files changed

+100
-146
lines changed

10 files changed

+100
-146
lines changed

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[submodule "src/llvm"]
22
path = src/llvm
3-
url = https://github.com/brson/llvm.git
3+
url = https://github.com/alexcrichton/llvm.git
44
branch = master
55
[submodule "src/libuv"]
66
path = src/libuv

mk/llvm.mk

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ LLVM_DEPS := $(S)/.gitmodules
1414
else
1515

1616
# This is just a rough approximation of LLVM deps
17-
LLVM_DEPS=$(call rwildcard,$(CFG_LLVM_SRC_DIR),*cpp *hpp)
17+
LLVM_DEPS_SRC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)/lib,*cpp *hpp)
18+
LLVM_DEPS_INC=$(call rwildcard,$(CFG_LLVM_SRC_DIR)/include,*cpp *hpp)
19+
LLVM_DEPS=$(LLVM_DEPS_SRC) $(LLVM_DEPS_INC)
1820
endif
1921

2022
define DEF_LLVM_RULES

src/librustc/back/passes.rs

-1
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ pub fn create_standard_passes(level: OptLevel) -> ~[~str] {
9898
passes.push(~"sroa");
9999
passes.push(~"domtree");
100100
passes.push(~"early-cse");
101-
passes.push(~"simplify-libcalls");
102101
passes.push(~"lazy-value-info");
103102
passes.push(~"jump-threading");
104103
passes.push(~"correlated-propagation");

src/librustc/lib/llvm.rs

+41-54
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,35 @@ pub enum Linkage {
5959
}
6060

6161
pub enum Attribute {
62-
ZExtAttribute = 1,
63-
SExtAttribute = 2,
64-
NoReturnAttribute = 4,
65-
InRegAttribute = 8,
66-
StructRetAttribute = 16,
67-
NoUnwindAttribute = 32,
68-
NoAliasAttribute = 64,
69-
ByValAttribute = 128,
70-
NestAttribute = 256,
71-
ReadNoneAttribute = 512,
72-
ReadOnlyAttribute = 1024,
73-
NoInlineAttribute = 2048,
74-
AlwaysInlineAttribute = 4096,
75-
OptimizeForSizeAttribute = 8192,
76-
StackProtectAttribute = 16384,
77-
StackProtectReqAttribute = 32768,
78-
// 31 << 16
79-
AlignmentAttribute = 2031616,
80-
NoCaptureAttribute = 2097152,
81-
NoRedZoneAttribute = 4194304,
82-
NoImplicitFloatAttribute = 8388608,
83-
NakedAttribute = 16777216,
84-
InlineHintAttribute = 33554432,
85-
// 7 << 26
86-
StackAttribute = 469762048,
87-
ReturnsTwiceAttribute = 536870912,
88-
// 1 << 30
89-
UWTableAttribute = 1073741824,
90-
NonLazyBindAttribute = 2147483648,
62+
ZExtAttribute = 1 << 0,
63+
SExtAttribute = 1 << 1,
64+
NoReturnAttribute = 1 << 2,
65+
InRegAttribute = 1 << 3,
66+
StructRetAttribute = 1 << 4,
67+
NoUnwindAttribute = 1 << 5,
68+
NoAliasAttribute = 1 << 6,
69+
ByValAttribute = 1 << 7,
70+
NestAttribute = 1 << 8,
71+
ReadNoneAttribute = 1 << 9,
72+
ReadOnlyAttribute = 1 << 10,
73+
NoInlineAttribute = 1 << 11,
74+
AlwaysInlineAttribute = 1 << 12,
75+
OptimizeForSizeAttribute = 1 << 13,
76+
StackProtectAttribute = 1 << 14,
77+
StackProtectReqAttribute = 1 << 15,
78+
AlignmentAttribute = 31 << 16,
79+
NoCaptureAttribute = 1 << 21,
80+
NoRedZoneAttribute = 1 << 22,
81+
NoImplicitFloatAttribute = 1 << 23,
82+
NakedAttribute = 1 << 24,
83+
InlineHintAttribute = 1 << 25,
84+
StackAttribute = 7 << 26,
85+
ReturnsTwiceAttribute = 1 << 29,
86+
UWTableAttribute = 1 << 30,
87+
NonLazyBindAttribute = 1 << 31,
88+
89+
// Not added to LLVM yet, so may need to stay updated if LLVM changes.
90+
FixedStackSegment = 1 << 41,
9191
}
9292

9393
// enum for the LLVM IntPredicate type
@@ -274,9 +274,7 @@ pub mod llvm {
274274
#[abi = "cdecl"]
275275
pub extern {
276276
/* Create and destroy contexts. */
277-
#[fast_ffi]
278277
pub unsafe fn LLVMContextCreate() -> ContextRef;
279-
#[fast_ffi]
280278
pub unsafe fn LLVMContextDispose(C: ContextRef);
281279
#[fast_ffi]
282280
pub unsafe fn LLVMGetMDKindIDInContext(C: ContextRef,
@@ -285,13 +283,11 @@ pub mod llvm {
285283
-> c_uint;
286284

287285
/* Create and destroy modules. */
288-
#[fast_ffi]
289286
pub unsafe fn LLVMModuleCreateWithNameInContext(ModuleID: *c_char,
290287
C: ContextRef)
291288
-> ModuleRef;
292289
#[fast_ffi]
293290
pub unsafe fn LLVMGetModuleContext(M: ModuleRef) -> ContextRef;
294-
#[fast_ffi]
295291
pub unsafe fn LLVMDisposeModule(M: ModuleRef);
296292

297293
/** Data layout. See Module::getDataLayout. */
@@ -307,7 +303,6 @@ pub mod llvm {
307303
pub unsafe fn LLVMSetTarget(M: ModuleRef, Triple: *c_char);
308304

309305
/** See Module::dump. */
310-
#[fast_ffi]
311306
pub unsafe fn LLVMDumpModule(M: ModuleRef);
312307

313308
/** See Module::setModuleInlineAsm. */
@@ -1589,15 +1584,15 @@ pub mod llvm {
15891584
Op: AtomicBinOp,
15901585
LHS: ValueRef,
15911586
RHS: ValueRef,
1592-
Order: AtomicOrdering)
1587+
Order: AtomicOrdering,
1588+
SingleThreaded: Bool)
15931589
-> ValueRef;
15941590

15951591
/* Selected entries from the downcasts. */
15961592
#[fast_ffi]
15971593
pub unsafe fn LLVMIsATerminatorInst(Inst: ValueRef) -> ValueRef;
15981594

15991595
/** Writes a module to the specified path. Returns 0 on success. */
1600-
#[fast_ffi]
16011596
pub unsafe fn LLVMWriteBitcodeToFile(M: ModuleRef,
16021597
Path: *c_char) -> c_int;
16031598

@@ -1647,40 +1642,30 @@ pub mod llvm {
16471642
pub unsafe fn LLVMDisposeTargetData(TD: TargetDataRef);
16481643

16491644
/** Creates a pass manager. */
1650-
#[fast_ffi]
16511645
pub unsafe fn LLVMCreatePassManager() -> PassManagerRef;
16521646
/** Creates a function-by-function pass manager */
1653-
#[fast_ffi]
16541647
pub unsafe fn LLVMCreateFunctionPassManagerForModule(M:ModuleRef) -> PassManagerRef;
16551648

16561649
/** Disposes a pass manager. */
1657-
#[fast_ffi]
16581650
pub unsafe fn LLVMDisposePassManager(PM: PassManagerRef);
16591651

16601652
/** Runs a pass manager on a module. */
1661-
#[fast_ffi]
16621653
pub unsafe fn LLVMRunPassManager(PM: PassManagerRef,
16631654
M: ModuleRef) -> Bool;
16641655

16651656
/** Runs the function passes on the provided function. */
1666-
#[fast_ffi]
16671657
pub unsafe fn LLVMRunFunctionPassManager(FPM:PassManagerRef, F:ValueRef) -> Bool;
16681658

16691659
/** Initializes all the function passes scheduled in the manager */
1670-
#[fast_ffi]
16711660
pub unsafe fn LLVMInitializeFunctionPassManager(FPM:PassManagerRef) -> Bool;
16721661

16731662
/** Finalizes all the function passes scheduled in the manager */
1674-
#[fast_ffi]
16751663
pub unsafe fn LLVMFinalizeFunctionPassManager(FPM:PassManagerRef) -> Bool;
16761664

1677-
#[fast_ffi]
16781665
pub unsafe fn LLVMInitializePasses();
16791666

1680-
#[fast_ffi]
16811667
pub unsafe fn LLVMAddPass(PM:PassManagerRef,P:PassRef);
16821668

1683-
#[fast_ffi]
16841669
pub unsafe fn LLVMCreatePass(PassName:*c_char) -> PassRef;
16851670

16861671
#[fast_ffi]
@@ -1762,9 +1747,7 @@ pub mod llvm {
17621747
#[fast_ffi]
17631748
pub unsafe fn LLVMAddBasicAliasAnalysisPass(PM: PassManagerRef);
17641749

1765-
#[fast_ffi]
17661750
pub unsafe fn LLVMPassManagerBuilderCreate() -> PassManagerBuilderRef;
1767-
#[fast_ffi]
17681751
pub unsafe fn LLVMPassManagerBuilderDispose(PMB:
17691752
PassManagerBuilderRef);
17701753
#[fast_ffi]
@@ -1801,19 +1784,17 @@ pub mod llvm {
18011784
/* Stuff that's in rustllvm/ because it's not upstream yet. */
18021785

18031786
/** Opens an object file. */
1804-
#[fast_ffi]
18051787
pub unsafe fn LLVMCreateObjectFile(MemBuf: MemoryBufferRef)
18061788
-> ObjectFileRef;
18071789
/** Closes an object file. */
1808-
#[fast_ffi]
18091790
pub unsafe fn LLVMDisposeObjectFile(ObjFile: ObjectFileRef);
18101791

18111792
/** Enumerates the sections in an object file. */
18121793
#[fast_ffi]
18131794
pub unsafe fn LLVMGetSections(ObjFile: ObjectFileRef)
18141795
-> SectionIteratorRef;
18151796
/** Destroys a section iterator. */
1816-
#[fast_ffi]
1797+
18171798
pub unsafe fn LLVMDisposeSectionIterator(SI: SectionIteratorRef);
18181799
/** Returns true if the section iterator is at the end of the section
18191800
list: */
@@ -1842,7 +1823,6 @@ pub mod llvm {
18421823
Path: *c_char)
18431824
-> MemoryBufferRef;
18441825

1845-
#[fast_ffi]
18461826
pub unsafe fn LLVMRustWriteOutputFile(PM: PassManagerRef,
18471827
M: ModuleRef,
18481828
Triple: *c_char,
@@ -1893,11 +1873,9 @@ pub mod llvm {
18931873
Output: *c_char);
18941874

18951875
/** Turn on LLVM pass-timing. */
1896-
#[fast_ffi]
18971876
pub unsafe fn LLVMRustEnableTimePasses();
18981877

18991878
/// Print the pass timings since static dtors aren't picking them up.
1900-
#[fast_ffi]
19011879
pub unsafe fn LLVMRustPrintPassTimings();
19021880

19031881
#[fast_ffi]
@@ -2117,6 +2095,15 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
21172095
llvm::LLVMConstFCmp(Pred as c_ushort, V1, V2)
21182096
}
21192097
}
2098+
2099+
pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
2100+
unsafe {
2101+
let attr = attr as u64;
2102+
let lower = attr & 0xffffffff;
2103+
let upper = (attr >> 32) & 0xffffffff;
2104+
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
2105+
}
2106+
}
21202107
/* Memory-managed object interface to type handles. */
21212108

21222109
pub struct TypeNames {

src/librustc/middle/trans/base.rs

+7-34
Original file line numberDiff line numberDiff line change
@@ -379,46 +379,25 @@ pub fn get_tydesc(ccx: &mut CrateContext, t: ty::t) -> @mut tydesc_info {
379379
}
380380

381381
pub fn set_optimize_for_size(f: ValueRef) {
382-
unsafe {
383-
llvm::LLVMAddFunctionAttr(f,
384-
lib::llvm::OptimizeForSizeAttribute
385-
as c_uint,
386-
0);
387-
}
382+
lib::llvm::SetFunctionAttribute(f, lib::llvm::OptimizeForSizeAttribute)
388383
}
389384

390385
pub fn set_no_inline(f: ValueRef) {
391-
unsafe {
392-
llvm::LLVMAddFunctionAttr(f,
393-
lib::llvm::NoInlineAttribute as c_uint,
394-
0);
395-
}
386+
lib::llvm::SetFunctionAttribute(f, lib::llvm::NoInlineAttribute)
396387
}
397388

398389
pub fn set_no_unwind(f: ValueRef) {
399-
unsafe {
400-
llvm::LLVMAddFunctionAttr(f,
401-
lib::llvm::NoUnwindAttribute as c_uint,
402-
0);
403-
}
390+
lib::llvm::SetFunctionAttribute(f, lib::llvm::NoUnwindAttribute)
404391
}
405392

406393
// Tell LLVM to emit the information necessary to unwind the stack for the
407394
// function f.
408395
pub fn set_uwtable(f: ValueRef) {
409-
unsafe {
410-
llvm::LLVMAddFunctionAttr(f,
411-
lib::llvm::UWTableAttribute as c_uint,
412-
0);
413-
}
396+
lib::llvm::SetFunctionAttribute(f, lib::llvm::UWTableAttribute)
414397
}
415398

416399
pub fn set_inline_hint(f: ValueRef) {
417-
unsafe {
418-
llvm::LLVMAddFunctionAttr(f,
419-
lib::llvm::InlineHintAttribute as c_uint,
420-
0);
421-
}
400+
lib::llvm::SetFunctionAttribute(f, lib::llvm::InlineHintAttribute)
422401
}
423402

424403
pub fn set_inline_hint_if_appr(attrs: &[ast::attribute],
@@ -432,17 +411,11 @@ pub fn set_inline_hint_if_appr(attrs: &[ast::attribute],
432411
}
433412

434413
pub fn set_always_inline(f: ValueRef) {
435-
unsafe {
436-
llvm::LLVMAddFunctionAttr(f,
437-
lib::llvm::AlwaysInlineAttribute as c_uint,
438-
0);
439-
}
414+
lib::llvm::SetFunctionAttribute(f, lib::llvm::AlwaysInlineAttribute)
440415
}
441416

442417
pub fn set_fixed_stack_segment(f: ValueRef) {
443-
unsafe {
444-
llvm::LLVMAddFunctionAttr(f, 0, 1 << (39 - 32));
445-
}
418+
lib::llvm::SetFunctionAttribute(f, lib::llvm::FixedStackSegment)
446419
}
447420

448421
pub fn set_glue_inlining(f: ValueRef, t: ty::t) {

src/librustc/middle/trans/build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,6 @@ pub fn AtomicRMW(cx: block, op: AtomicBinOp,
11241124
dst: ValueRef, src: ValueRef,
11251125
order: AtomicOrdering) -> ValueRef {
11261126
unsafe {
1127-
llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order)
1127+
llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order, lib::llvm::False)
11281128
}
11291129
}

src/llvm

Submodule llvm updated from 2e9f0d2 to e3abef3

0 commit comments

Comments
 (0)