Skip to content

Commit 3d14470

Browse files
committed
auto merge of #7115 : alexcrichton/rust/llvm-upgrades, r=thestinger
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 b49d026 + 60e9507 commit 3d14470

File tree

10 files changed

+72
-80
lines changed

10 files changed

+72
-80
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
@@ -97,7 +97,6 @@ pub fn create_standard_passes(level: OptLevel) -> ~[~str] {
9797
passes.push(~"sroa");
9898
passes.push(~"domtree");
9999
passes.push(~"early-cse");
100-
passes.push(~"simplify-libcalls");
101100
passes.push(~"lazy-value-info");
102101
passes.push(~"jump-threading");
103102
passes.push(~"correlated-propagation");

src/librustc/lib/llvm.rs

+55-30
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,37 @@ pub enum Linkage {
5959

6060
#[deriving(Clone)]
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+
// FIXME(#8199): if this changes, be sure to change the relevant constant
91+
// down below
92+
// FixedStackSegment = 1 << 41,
9193
}
9294

9395
// enum for the LLVM IntPredicate type
@@ -1541,7 +1543,8 @@ pub mod llvm {
15411543
Op: AtomicBinOp,
15421544
LHS: ValueRef,
15431545
RHS: ValueRef,
1544-
Order: AtomicOrdering)
1546+
Order: AtomicOrdering,
1547+
SingleThreaded: Bool)
15451548
-> ValueRef;
15461549

15471550
pub fn LLVMBuildAtomicFence(B: BuilderRef, Order: AtomicOrdering);
@@ -2106,6 +2109,28 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
21062109
llvm::LLVMConstFCmp(Pred as c_ushort, V1, V2)
21072110
}
21082111
}
2112+
2113+
pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
2114+
unsafe {
2115+
let attr = attr as u64;
2116+
let lower = attr & 0xffffffff;
2117+
let upper = (attr >> 32) & 0xffffffff;
2118+
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
2119+
}
2120+
}
2121+
2122+
// FIXME(#8199): this shouldn't require this hackery. On i686
2123+
// (FixedStackSegment as u64) will return 0 instead of 1 << 41.
2124+
// Furthermore, if we use a match of any sort then an LLVM
2125+
// assertion is generated!
2126+
pub fn SetFixedStackSegmentAttribute(Fn: ValueRef) {
2127+
unsafe {
2128+
let attr = 1u64 << 41;
2129+
let lower = attr & 0xffffffff;
2130+
let upper = (attr >> 32) & 0xffffffff;
2131+
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
2132+
}
2133+
}
21092134
/* Memory-managed object interface to type handles. */
21102135

21112136
pub struct TypeNames {

src/librustc/middle/trans/base.rs

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

421421
pub fn set_optimize_for_size(f: ValueRef) {
422-
unsafe {
423-
llvm::LLVMAddFunctionAttr(f,
424-
lib::llvm::OptimizeForSizeAttribute
425-
as c_uint,
426-
0);
427-
}
422+
lib::llvm::SetFunctionAttribute(f, lib::llvm::OptimizeForSizeAttribute)
428423
}
429424

430425
pub fn set_no_inline(f: ValueRef) {
431-
unsafe {
432-
llvm::LLVMAddFunctionAttr(f,
433-
lib::llvm::NoInlineAttribute as c_uint,
434-
0);
435-
}
426+
lib::llvm::SetFunctionAttribute(f, lib::llvm::NoInlineAttribute)
436427
}
437428

438429
pub fn set_no_unwind(f: ValueRef) {
439-
unsafe {
440-
llvm::LLVMAddFunctionAttr(f,
441-
lib::llvm::NoUnwindAttribute as c_uint,
442-
0);
443-
}
430+
lib::llvm::SetFunctionAttribute(f, lib::llvm::NoUnwindAttribute)
444431
}
445432

446433
// Tell LLVM to emit the information necessary to unwind the stack for the
447434
// function f.
448435
pub fn set_uwtable(f: ValueRef) {
449-
unsafe {
450-
llvm::LLVMAddFunctionAttr(f,
451-
lib::llvm::UWTableAttribute as c_uint,
452-
0);
453-
}
436+
lib::llvm::SetFunctionAttribute(f, lib::llvm::UWTableAttribute)
454437
}
455438

456439
pub fn set_inline_hint(f: ValueRef) {
457-
unsafe {
458-
llvm::LLVMAddFunctionAttr(f,
459-
lib::llvm::InlineHintAttribute as c_uint,
460-
0);
461-
}
440+
lib::llvm::SetFunctionAttribute(f, lib::llvm::InlineHintAttribute)
462441
}
463442

464443
pub fn set_inline_hint_if_appr(attrs: &[ast::Attribute],
@@ -473,17 +452,11 @@ pub fn set_inline_hint_if_appr(attrs: &[ast::Attribute],
473452
}
474453

475454
pub fn set_always_inline(f: ValueRef) {
476-
unsafe {
477-
llvm::LLVMAddFunctionAttr(f,
478-
lib::llvm::AlwaysInlineAttribute as c_uint,
479-
0);
480-
}
455+
lib::llvm::SetFunctionAttribute(f, lib::llvm::AlwaysInlineAttribute)
481456
}
482457

483458
pub fn set_fixed_stack_segment(f: ValueRef) {
484-
unsafe {
485-
llvm::LLVMAddFunctionAttr(f, 0, 1 << (39 - 32));
486-
}
459+
lib::llvm::SetFixedStackSegmentAttribute(f);
487460
}
488461

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

src/librustc/middle/trans/builder.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ impl Builder {
940940
dst: ValueRef, src: ValueRef,
941941
order: AtomicOrdering) -> ValueRef {
942942
unsafe {
943-
llvm::LLVMBuildAtomicRMW(self.llbuilder, op, dst, src, order)
943+
llvm::LLVMBuildAtomicRMW(self.llbuilder, op, dst, src, order, False)
944944
}
945945
}
946946

src/llvm

Submodule llvm updated 2977 files

src/rustllvm/RustWrapper.cpp

+1-10
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class RustMCJITMemoryManager : public JITMemoryManager {
113113

114114
virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
115115
unsigned SectionID, bool isReadOnly);
116+
bool finalizeMemory(std::string *ErrMsg) { return false; }
116117

117118
virtual bool applyPermissions(std::string *Str);
118119

@@ -340,7 +341,6 @@ LLVMRustBuildJIT(void* mem,
340341

341342
std::string Err;
342343
TargetOptions Options;
343-
Options.JITExceptionHandling = true;
344344
Options.JITEmitDebugInfo = true;
345345
Options.NoFramePointerElim = true;
346346
Options.EnableSegmentedStacks = EnableSegmentedStacks;
@@ -516,15 +516,6 @@ extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B,
516516
extern "C" LLVMValueRef LLVMBuildAtomicFence(LLVMBuilderRef B, AtomicOrdering order) {
517517
return wrap(unwrap(B)->CreateFence(order));
518518
}
519-
extern "C" LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,
520-
AtomicRMWInst::BinOp op,
521-
LLVMValueRef target,
522-
LLVMValueRef source,
523-
AtomicOrdering order) {
524-
return wrap(unwrap(B)->CreateAtomicRMW(op,
525-
unwrap(target), unwrap(source),
526-
order));
527-
}
528519

529520
extern "C" void LLVMSetDebug(int Enabled) {
530521
#ifndef NDEBUG

src/rustllvm/llvm-auto-clean-trigger

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
22
# The actual contents of this file do not matter, but to trigger a change on the
33
# build bots then the contents should be changed so git updates the mtime.
4-
2013-07-03
4+
2013-07-04

src/rustllvm/rustllvm.h

+2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#include "llvm/IR/IRBuilder.h"
1112
#include "llvm/IR/InlineAsm.h"
1213
#include "llvm/IR/LLVMContext.h"
14+
#include "llvm/IR/Module.h"
1315
#include "llvm/Linker.h"
1416
#include "llvm/PassManager.h"
1517
#include "llvm/IR/InlineAsm.h"

0 commit comments

Comments
 (0)