about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-08-20 11:31:59 -0700
committerbors <bors@rust-lang.org>2013-08-20 11:31:59 -0700
commita8c3fe45c6138cd1f4d143fdb0e843ee2d4759b2 (patch)
tree73c09899e53768afb90d337c870e4f63bb06ff2a
parent67c954e365970e4c2cd06f0c50724656d7010f45 (diff)
parent7f91e7740dfbf020e2538d95e21851a32a3454a6 (diff)
downloadrust-a8c3fe45c6138cd1f4d143fdb0e843ee2d4759b2.tar.gz
rust-a8c3fe45c6138cd1f4d143fdb0e843ee2d4759b2.zip
auto merge of #8328 : alexcrichton/rust/llvm-head, r=brson
The first commit message is pretty good, but whomever reviews this should probably also at least glance at the changes I made in LLVM. I basically reorganized our pending patch queue to be a bit more organized and clearer in what needs to go where. After this, our queue would be:

* Add the `no-split-stack` attribute
* Add the `fixedstacksegment` attribute
* Add split-stacks for arm android
* Add split-stacks for arm linux
* Add split stacks for mips

Then there's a patch which I added to get rust to build at all on LLVM-head, and I'm not quite sure why it's there, but nothing seems to be crashing for now! (famous last words).

Otherwise, I just updated code to reflect the changes I made in LLVM with the only major change being the advent of the new `no_split_stack` attribute. This is work towards #1226, but someone more familiar with the code should probably actually assign the attribute to the appropriate functions.

Also as a bonus, I've verified that this closes #5774
-rw-r--r--src/librustc/back/passes.rs1
-rw-r--r--src/librustc/lib/llvm.rs27
-rw-r--r--src/librustc/middle/trans/base.rs23
-rw-r--r--src/librustc/middle/trans/monomorphize.rs8
m---------src/llvm0
-rw-r--r--src/rustllvm/RustWrapper.cpp10
-rw-r--r--src/rustllvm/llvm-auto-clean-trigger2
-rw-r--r--src/rustllvm/rustllvm.def.in1
8 files changed, 35 insertions, 37 deletions
diff --git a/src/librustc/back/passes.rs b/src/librustc/back/passes.rs
index 29bc577dff9..bb5ddc1ae77 100644
--- a/src/librustc/back/passes.rs
+++ b/src/librustc/back/passes.rs
@@ -293,7 +293,6 @@ pub static transform_passes : &'static [(&'static str, &'static str)] = &'static
     ("scalarrepl",                      "Scalar Replacement of Aggregates (DT)"),
     ("scalarrepl-ssa",                  "Scalar Replacement of Aggregates (SSAUp)"),
     ("sccp",                            "Sparse Conditional Constant Propagation"),
-    ("simplify-libcalls",               "Simplify well-known library calls"),
     ("simplifycfg",                     "Simplify the CFG"),
     ("sink",                            "Code sinking"),
     ("strip",                           "Strip all symbols from a module"),
diff --git a/src/librustc/lib/llvm.rs b/src/librustc/lib/llvm.rs
index 9175c13c8ae..60f8a1773fc 100644
--- a/src/librustc/lib/llvm.rs
+++ b/src/librustc/lib/llvm.rs
@@ -89,11 +89,6 @@ pub enum Attribute {
     ReturnsTwiceAttribute = 1 << 29,
     UWTableAttribute = 1 << 30,
     NonLazyBindAttribute = 1 << 31,
-
-    // Not added to LLVM yet, so may need to stay updated if LLVM changes.
-    // FIXME(#8199): if this changes, be sure to change the relevant constant
-    //               down below
-    // FixedStackSegment = 1 << 41,
 }
 
 // enum for the LLVM IntPredicate type
@@ -847,7 +842,9 @@ pub mod llvm {
         #[fast_ffi]
         pub fn LLVMSetGC(Fn: ValueRef, Name: *c_char);
         #[fast_ffi]
-        pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint, HighPA: c_uint);
+        pub fn LLVMAddFunctionAttr(Fn: ValueRef, PA: c_uint);
+        #[fast_ffi]
+        pub fn LLVMAddFunctionAttrString(Fn: ValueRef, Name: *c_char);
         #[fast_ffi]
         pub fn LLVMGetFunctionAttr(Fn: ValueRef) -> c_ulonglong;
         #[fast_ffi]
@@ -2138,23 +2135,7 @@ pub fn ConstFCmp(Pred: RealPredicate, V1: ValueRef, V2: ValueRef) -> ValueRef {
 
 pub fn SetFunctionAttribute(Fn: ValueRef, attr: Attribute) {
     unsafe {
-        let attr = attr as u64;
-        let lower = attr & 0xffffffff;
-        let upper = (attr >> 32) & 0xffffffff;
-        llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
-    }
-}
-
-// FIXME(#8199): this shouldn't require this hackery. On i686
-//               (FixedStackSegment as u64) will return 0 instead of 1 << 41.
-//               Furthermore, if we use a match of any sort then an LLVM
-//               assertion is generated!
-pub fn SetFixedStackSegmentAttribute(Fn: ValueRef) {
-    unsafe {
-        let attr = 1u64 << 41;
-        let lower = attr & 0xffffffff;
-        let upper = (attr >> 32) & 0xffffffff;
-        llvm::LLVMAddFunctionAttr(Fn, lower as c_uint, upper as c_uint);
+        llvm::LLVMAddFunctionAttr(Fn, attr as c_uint)
     }
 }
 /* Memory-managed object interface to type handles. */
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index f4d52c3aa31..95021d3b6e7 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -442,15 +442,20 @@ pub fn set_inline_hint(f: ValueRef) {
     lib::llvm::SetFunctionAttribute(f, lib::llvm::InlineHintAttribute)
 }
 
-pub fn set_inline_hint_if_appr(attrs: &[ast::Attribute],
-                               llfn: ValueRef) {
+pub fn set_llvm_fn_attrs(attrs: &[ast::Attribute], llfn: ValueRef) {
     use syntax::attr::*;
+    // Set the inline hint if there is one
     match find_inline_attr(attrs) {
         InlineHint   => set_inline_hint(llfn),
         InlineAlways => set_always_inline(llfn),
         InlineNever  => set_no_inline(llfn),
         InlineNone   => { /* fallthrough */ }
     }
+
+    // Add the no-split-stack attribute if requested
+    if contains_name(attrs, "no_split_stack") {
+        set_no_split_stack(llfn);
+    }
 }
 
 pub fn set_always_inline(f: ValueRef) {
@@ -458,7 +463,15 @@ pub fn set_always_inline(f: ValueRef) {
 }
 
 pub fn set_fixed_stack_segment(f: ValueRef) {
-    lib::llvm::SetFixedStackSegmentAttribute(f);
+    do "fixed-stack-segment".to_c_str().with_ref |buf| {
+        unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
+    }
+}
+
+pub fn set_no_split_stack(f: ValueRef) {
+    do "no-split-stack".to_c_str().with_ref |buf| {
+        unsafe { llvm::LLVMAddFunctionAttrString(f, buf); }
+    }
 }
 
 pub fn set_glue_inlining(f: ValueRef, t: ty::t) {
@@ -2472,7 +2485,7 @@ pub fn get_item_val(ccx: @mut CrateContext, id: ast::NodeId) -> ValueRef {
                                                                            sym,
                                                                            i.id)
                             };
-                            set_inline_hint_if_appr(i.attrs, llfn);
+                            set_llvm_fn_attrs(i.attrs, llfn);
                             llfn
                         }
 
@@ -2605,7 +2618,7 @@ pub fn register_method(ccx: @mut CrateContext,
     let sym = exported_name(ccx, path, mty, m.attrs);
 
     let llfn = register_fn(ccx, m.span, sym, id, mty);
-    set_inline_hint_if_appr(m.attrs, llfn);
+    set_llvm_fn_attrs(m.attrs, llfn);
     llfn
 }
 
diff --git a/src/librustc/middle/trans/monomorphize.rs b/src/librustc/middle/trans/monomorphize.rs
index 5249a2b9b7b..ab458f2799d 100644
--- a/src/librustc/middle/trans/monomorphize.rs
+++ b/src/librustc/middle/trans/monomorphize.rs
@@ -12,7 +12,7 @@
 use back::link::mangle_exported_name;
 use driver::session;
 use lib::llvm::ValueRef;
-use middle::trans::base::{set_inline_hint_if_appr, set_inline_hint};
+use middle::trans::base::{set_llvm_fn_attrs, set_inline_hint};
 use middle::trans::base::{trans_enum_variant,push_ctxt};
 use middle::trans::base::{trans_fn, decl_internal_cdecl_fn};
 use middle::trans::base::{get_item_val, no_self};
@@ -222,7 +222,7 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
                 _
             }, _) => {
         let d = mk_lldecl();
-        set_inline_hint_if_appr(i.attrs, d);
+        set_llvm_fn_attrs(i.attrs, d);
         trans_fn(ccx,
                  pt,
                  decl,
@@ -266,13 +266,13 @@ pub fn monomorphic_fn(ccx: @mut CrateContext,
       ast_map::node_method(mth, _, _) => {
         // XXX: What should the self type be here?
         let d = mk_lldecl();
-        set_inline_hint_if_appr(mth.attrs.clone(), d);
+        set_llvm_fn_attrs(mth.attrs, d);
         meth::trans_method(ccx, pt, mth, Some(psubsts), d);
         d
       }
       ast_map::node_trait_method(@ast::provided(mth), _, pt) => {
         let d = mk_lldecl();
-        set_inline_hint_if_appr(mth.attrs.clone(), d);
+        set_llvm_fn_attrs(mth.attrs, d);
         meth::trans_method(ccx, (*pt).clone(), mth, Some(psubsts), d);
         d
       }
diff --git a/src/llvm b/src/llvm
-Subproject f67442eee27d3d075a65cf7f9a70f7ec6649ffd
+Subproject 0964c68ddf2c67ce455e7443a06f4bb3db9e92b
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 61ea0d549b3..1a4b7f32329 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -43,7 +43,7 @@ extern "C" void LLVMRustAddPrintModulePass(LLVMPassManagerRef PMR,
                                            const char* path) {
   PassManager *PM = unwrap<PassManager>(PMR);
   std::string ErrorInfo;
-  raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
+  raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_Binary);
   formatted_raw_ostream FOS(OS);
   PM->add(createPrintModulePass(&FOS));
   PM->run(*unwrap(M));
@@ -413,7 +413,7 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
   bool NoVerify = false;
   std::string ErrorInfo;
   raw_fd_ostream OS(path, ErrorInfo,
-                    raw_fd_ostream::F_Binary);
+                    sys::fs::F_Binary);
   if (ErrorInfo != "") {
     LLVMRustError = ErrorInfo.c_str();
     return false;
@@ -482,6 +482,10 @@ extern "C" LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) {
   return wrap(Type::getMetadataTy(*unwrap(C)));
 }
 
+extern "C" void LLVMAddFunctionAttrString(LLVMValueRef fn, const char *Name) {
+  unwrap<Function>(fn)->addFnAttr(Name);
+}
+
 extern "C" LLVMValueRef LLVMBuildAtomicLoad(LLVMBuilderRef B,
                                             LLVMValueRef source,
                                             const char* Name,
@@ -625,7 +629,7 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
     return wrap(Builder->createFunction(
         unwrapDI<DIScope>(Scope), Name, LinkageName,
         unwrapDI<DIFile>(File), LineNo,
-        unwrapDI<DIType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
+        unwrapDI<DICompositeType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
         Flags, isOptimized,
         unwrap<Function>(Fn),
         unwrapDI<MDNode*>(TParam),
diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger
index 670eebbed13..cfc1d20b283 100644
--- a/src/rustllvm/llvm-auto-clean-trigger
+++ b/src/rustllvm/llvm-auto-clean-trigger
@@ -1,4 +1,4 @@
 # If this file is modified, then llvm will be forcibly cleaned and then rebuilt.
 # The actual contents of this file do not matter, but to trigger a change on the
 # build bots then the contents should be changed so git updates the mtime.
-2013-07-04
+2013-08-20
diff --git a/src/rustllvm/rustllvm.def.in b/src/rustllvm/rustllvm.def.in
index 0b777abfb87..75a55fdf88a 100644
--- a/src/rustllvm/rustllvm.def.in
+++ b/src/rustllvm/rustllvm.def.in
@@ -42,6 +42,7 @@ LLVMAddDestination
 LLVMAddEarlyCSEPass
 LLVMAddFunction
 LLVMAddFunctionAttr
+LLVMAddFunctionAttrString
 LLVMAddFunctionAttrsPass
 LLVMAddFunctionInliningPass
 LLVMAddGVNPass