Skip to content

Commit 329a829

Browse files
committed
Revert "auto merge of rust-lang#8328 : alexcrichton/rust/llvm-head, r=brson"
This reverts commit a8c3fe4, reversing changes made to 67c954e.
1 parent 2c0f9bd commit 329a829

File tree

8 files changed

+38
-36
lines changed

8 files changed

+38
-36
lines changed

src/librustc/back/passes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ pub static transform_passes : &'static [(&'static str, &'static str)] = &'static
293293
("scalarrepl", "Scalar Replacement of Aggregates (DT)"),
294294
("scalarrepl-ssa", "Scalar Replacement of Aggregates (SSAUp)"),
295295
("sccp", "Sparse Conditional Constant Propagation"),
296+
("simplify-libcalls", "Simplify well-known library calls"),
296297
("simplifycfg", "Simplify the CFG"),
297298
("sink", "Code sinking"),
298299
("strip", "Strip all symbols from a module"),

src/librustc/lib/llvm.rs

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,11 @@ pub enum Attribute {
8989
ReturnsTwiceAttribute = 1 << 29,
9090
UWTableAttribute = 1 << 30,
9191
NonLazyBindAttribute = 1 << 31,
92+
93+
// Not added to LLVM yet, so may need to stay updated if LLVM changes.
94+
// FIXME(#8199): if this changes, be sure to change the relevant constant
95+
// down below
96+
// FixedStackSegment = 1 << 41,
9297
}
9398

9499
// enum for the LLVM IntPredicate type
@@ -842,9 +847,7 @@ pub mod llvm {
842847
#[fast_ffi]
843848
pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
844849
#[fast_ffi]
845-
pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint);
846-
#[fast_ffi]
847-
pub fn LLVMAddFunctionAttrString(Fn: ValueRef, Name: *c_char);
850+
pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint, HighPA: c_uint);
848851
#[fast_ffi]
849852
pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
850853
#[fast_ffi]
@@ -2135,7 +2138,23 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
21352138

21362139
pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
21372140
unsafe {
2138-
llvm::LLVMAddFunctionAttr(Fn, attr as c_uint)
2141+
let attr = attr as u64;
2142+
let lower = attr & 0xffffffff;
2143+
let upper = (attr >> 32) & 0xffffffff;
2144+
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
2145+
}
2146+
}
2147+
2148+
// FIXME(#8199): this shouldn't require this hackery. On i686
2149+
// (FixedStackSegment as u64) will return 0 instead of 1 << 41.
2150+
// Furthermore, if we use a match of any sort then an LLVM
2151+
// assertion is generated!
2152+
pub fn SetFixedStackSegmentAttribute(Fn: ValueRef) {
2153+
unsafe {
2154+
let attr = 1u64 << 41;
2155+
let lower = attr & 0xffffffff;
2156+
let upper = (attr >> 32) & 0xffffffff;
2157+
llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
21392158
}
21402159
}
21412160
/* Memory-managed object interface to type handles. */

src/librustc/middle/trans/base.rs

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -448,36 +448,23 @@ pub fn set_inline_hint(f: ValueRef) {
448448
lib::llvm::SetFunctionAttribute(f, lib::llvm::InlineHintAttribute)
449449
}
450450

451-
pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
451+
pub fn set_inline_hint_if_appr(attrs: &[ast::Attribute],
452+
llfn: ValueRef) {
452453
use syntax::attr::*;
453-
// Set the inline hint if there is one
454454
match find_inline_attr(attrs) {
455455
InlineHint => set_inline_hint(llfn),
456456
InlineAlways => set_always_inline(llfn),
457457
InlineNever => set_no_inline(llfn),
458458
InlineNone => { /* fallthrough */ }
459459
}
460-
461-
// Add the no-split-stack attribute if requested
462-
if contains_name(attrs, "no_split_stack") {
463-
set_no_split_stack(llfn);
464-
}
465460
}
466461

467462
pub fn set_always_inline(f: ValueRef) {
468463
lib::llvm::SetFunctionAttribute(f, lib::llvm::AlwaysInlineAttribute)
469464
}
470465

471466
pub fn set_fixed_stack_segment(f: ValueRef) {
472-
do "fixed-stack-segment".to_c_str().with_ref |buf| {
473-
unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
474-
}
475-
}
476-
477-
pub fn set_no_split_stack(f: ValueRef) {
478-
do "no-split-stack".to_c_str().with_ref |buf| {
479-
unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
480-
}
467+
lib::llvm::SetFixedStackSegmentAttribute(f);
481468
}
482469

483470
pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
@@ -2504,7 +2491,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
25042491
sym,
25052492
i.id)
25062493
};
2507-
set_llvm_fn_attrs(i.attrs, llfn);
2494+
set_inline_hint_if_appr(i.attrs, llfn);
25082495
llfn
25092496
}
25102497

@@ -2637,7 +2624,7 @@ pub fn register_method(ccx: @mut CrateContext,
26372624
let sym = exported_name(ccx, path, mty, m.attrs);
26382625

26392626
let llfn = register_fn(ccx, m.span, sym, id, mty);
2640-
set_llvm_fn_attrs(m.attrs, llfn);
2627+
set_inline_hint_if_appr(m.attrs, llfn);
26412628
llfn
26422629
}
26432630

src/librustc/middle/trans/monomorphize.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
use back::link::mangle_exported_name;
1313
use driver::session;
1414
use lib::llvm::ValueRef;
15-
use middle::trans::base::{set_llvm_fn_attrs, set_inline_hint};
15+
use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint};
1616
use middle::trans::base::{trans_enum_variant,push_ctxt};
1717
use middle::trans::base::{trans_fn, decl_internal_cdecl_fn};
1818
use middle::trans::base::{get_item_val, no_self};
@@ -222,7 +222,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
222222
_
223223
}, _) => {
224224
let d = mk_lldecl();
225-
set_llvm_fn_attrs(i.attrs, d);
225+
set_inline_hint_if_appr(i.attrs, d);
226226
trans_fn(ccx,
227227
pt,
228228
decl,
@@ -266,13 +266,13 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
266266
ast_map::node_method(mth, _, _) => {
267267
// XXX: What should the self type be here?
268268
let d = mk_lldecl();
269-
set_llvm_fn_attrs(mth.attrs, d);
269+
set_inline_hint_if_appr(mth.attrs.clone(), d);
270270
meth::trans_method(ccx, pt, mth, Some(psubsts), d);
271271
d
272272
}
273273
ast_map::node_trait_method(@ast::provided(mth), _, pt) => {
274274
let d = mk_lldecl();
275-
set_llvm_fn_attrs(mth.attrs, d);
275+
set_inline_hint_if_appr(mth.attrs.clone(), d);
276276
meth::trans_method(ccx, (*pt).clone(), mth, Some(psubsts), d);
277277
d
278278
}

src/llvm

Submodule llvm updated 5382 files

src/rustllvm/RustWrapper.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ extern "C" void LLVMRustAddPrintModulePass(LLVMPassManagerRef PMR,
4343
const char* path) {
4444
PassManager *PM = unwrap<PassManager>(PMR);
4545
std::string ErrorInfo;
46-
raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_Binary);
46+
raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
4747
formatted_raw_ostream FOS(OS);
4848
PM->add(createPrintModulePass(&FOS));
4949
PM->run(*unwrap(M));
@@ -411,7 +411,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
411411
bool NoVerify = false;
412412
std::string ErrorInfo;
413413
raw_fd_ostream OS(path, ErrorInfo,
414-
sys::fs::F_Binary);
414+
raw_fd_ostream::F_Binary);
415415
if (ErrorInfo != "") {
416416
LLVMRustError = ErrorInfo.c_str();
417417
return false;
@@ -480,10 +480,6 @@ extern "C" LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) {
480480
return wrap(Type::getMetadataTy(*unwrap(C)));
481481
}
482482

483-
extern "C" void LLVMAddFunctionAttrString(LLVMValueRef fn, const char *Name) {
484-
unwrap<Function>(fn)->addFnAttr(Name);
485-
}
486-
487483
extern "C" LLVMValueRef LLVMBuildAtomicLoad(LLVMBuilderRef B,
488484
LLVMValueRef source,
489485
const char* Name,
@@ -627,7 +623,7 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
627623
return wrap(Builder->createFunction(
628624
unwrapDI<DIScope>(Scope), Name, LinkageName,
629625
unwrapDI<DIFile>(File), LineNo,
630-
unwrapDI<DICompositeType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
626+
unwrapDI<DIType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
631627
Flags, isOptimized,
632628
unwrap<Function>(Fn),
633629
unwrapDI<MDNode*>(TParam),

src/rustllvm/llvm-auto-clean-trigger

Lines changed: 1 addition & 1 deletion
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-08-20
4+
2013-07-04

src/rustllvm/rustllvm.def.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ LLVMAddDestination
4242
LLVMAddEarlyCSEPass
4343
LLVMAddFunction
4444
LLVMAddFunctionAttr
45-
LLVMAddFunctionAttrString
4645
LLVMAddFunctionAttrsPass
4746
LLVMAddFunctionInliningPass
4847
LLVMAddGVNPass

0 commit comments

Comments
 (0)