about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRafael Ávila de Espíndola <respindola@mozilla.com>2011-05-24 13:47:27 -0400
committerRafael Ávila de Espíndola <respindola@mozilla.com>2011-06-08 14:08:24 -0400
commit698022d351e552b51cd9cca878bdc0de3de05b8c (patch)
tree36f0cc07c4f2b66ad914c5022c01b3706c937973 /src
parentd360c481e8bd6079eb92b155a7c5451fc8bd35f6 (diff)
downloadrust-698022d351e552b51cd9cca878bdc0de3de05b8c.tar.gz
rust-698022d351e552b51cd9cca878bdc0de3de05b8c.zip
Update rust to build with newer llvm versions.
Diffstat (limited to 'src')
-rw-r--r--src/comp/back/link.rs1
-rw-r--r--src/comp/lib/llvm.rs2
-rw-r--r--src/comp/middle/trans.rs6
-rw-r--r--src/rustllvm/Passes2.cpp29
-rw-r--r--src/rustllvm/RustWrapper.cpp3
5 files changed, 26 insertions, 15 deletions
diff --git a/src/comp/back/link.rs b/src/comp/back/link.rs
index 6469bbd3ced..b637b7e41b8 100644
--- a/src/comp/back/link.rs
+++ b/src/comp/back/link.rs
@@ -153,7 +153,6 @@ mod write {
                                               True,  // unit-at-a-time
                                               True,  // unroll loops
                                               True,  // simplify lib calls
-                                              True,  // have exceptions
                                               threshold); // inline threshold
         }
 
diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs
index 0de35b9f006..505e07e3f3f 100644
--- a/src/comp/lib/llvm.rs
+++ b/src/comp/lib/llvm.rs
@@ -88,6 +88,7 @@ const uint LLVMNoImplicitFloatAttribute = 8388608u;
 const uint LLVMNakedAttribute = 16777216u;
 const uint LLVMInlineHintAttribute = 33554432u;
 const uint LLVMStackAttribute = 469762048u;     // 7 << 26
+const uint LLVMUWTableAttribute = 1073741824u; // 1 << 30
 
 
 // Consts for the LLVM IntPredicate type, pre-cast to uint.
@@ -813,7 +814,6 @@ native mod llvm = llvm_lib {
                                    Bool UnitAtATime,
                                    Bool UnrollLoops,
                                    Bool SimplifyLibCalls,
-                                   Bool HaveExceptions,
                                    uint InliningThreshold);
 
     /** Destroys a memory buffer. */
diff --git a/src/comp/middle/trans.rs b/src/comp/middle/trans.rs
index 3780d2c86fb..f08d450e81d 100644
--- a/src/comp/middle/trans.rs
+++ b/src/comp/middle/trans.rs
@@ -1820,6 +1820,11 @@ fn set_no_inline(ValueRef f) {
                               lib::llvm::llvm::Attribute);
 }
 
+fn set_uwtable(ValueRef f) {
+    llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMUWTableAttribute as
+                              lib::llvm::llvm::Attribute);
+}
+
 fn set_always_inline(ValueRef f) {
     llvm::LLVMAddFunctionAttr(f, lib::llvm::LLVMAlwaysInlineAttribute as
                               lib::llvm::llvm::Attribute);
@@ -6962,6 +6967,7 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ast::def_id fid,
             option::t[ty_self_pair] ty_self,
             &vec[ast::ty_param] ty_params, &ast::ann ann) {
     auto llfndecl = cx.ccx.item_ids.get(fid);
+    set_uwtable(llfndecl);
 
     // Set up arguments to the function.
     auto fcx = new_fn_ctxt(cx, sp, llfndecl);
diff --git a/src/rustllvm/Passes2.cpp b/src/rustllvm/Passes2.cpp
index c4ead0de5aa..dcc549b511f 100644
--- a/src/rustllvm/Passes2.cpp
+++ b/src/rustllvm/Passes2.cpp
@@ -1,5 +1,5 @@
 #include "llvm/Analysis/Passes.h"
-#include "llvm/Support/StandardPasses.h"
+#include "llvm/Support/PassManagerBuilder.h"
 #include "llvm/PassManager.h"
 #include "llvm-c/Core.h"
 #include <cstdlib>
@@ -8,22 +8,29 @@ using namespace llvm;
 
 extern "C" void LLVMAddStandardFunctionPasses(LLVMPassManagerRef PM,
     unsigned int OptimizationLevel) {
-  createStandardFunctionPasses(unwrap(PM), OptimizationLevel);
+  PassManagerBuilder PMBuilder;
+  PMBuilder.OptLevel = OptimizationLevel;
+  FunctionPassManager *FPM = (FunctionPassManager*) unwrap(PM);
+  PMBuilder.populateFunctionPassManager(*FPM);
 }
 
 extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
     unsigned int OptimizationLevel, LLVMBool OptimizeSize,
     LLVMBool UnitAtATime, LLVMBool UnrollLoops, LLVMBool SimplifyLibCalls,
-    LLVMBool HaveExceptions, unsigned int InliningThreshold) {
-  Pass *InliningPass;
+    unsigned int InliningThreshold) {
+
+  PassManagerBuilder PMBuilder;
+  PMBuilder.OptLevel = OptimizationLevel;
+  PMBuilder.SizeLevel = OptimizeSize;
+  PMBuilder.DisableUnitAtATime = !UnitAtATime;
+  PMBuilder.DisableUnrollLoops = !UnrollLoops;
+
+  PMBuilder.DisableSimplifyLibCalls = !SimplifyLibCalls;
+
   if (InliningThreshold)
-    InliningPass = createFunctionInliningPass(InliningThreshold);
-  else
-    InliningPass = NULL;
+    PMBuilder.Inliner = createFunctionInliningPass(InliningThreshold);
 
-  createStandardModulePasses(unwrap(PM), OptimizationLevel, OptimizeSize,
-                             UnitAtATime, UnrollLoops, SimplifyLibCalls,
-                             HaveExceptions, InliningPass);
+  PassManager *MPM = (PassManager*) unwrap(PM);
+  PMBuilder.populateModulePassManager(*MPM);
 }
 
-
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 2c50a6ccfa7..eb06398c48e 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -47,7 +47,7 @@ extern "C" const char *LLVMRustGetLastError(void) {
 extern "C" void LLVMAddBasicAliasAnalysisPass(LLVMPassManagerRef PM);
 extern "C" void LLVMAddStandardModulePasses(LLVMPassManagerRef PM,
     unsigned int OptimizationLevel, bool OptimizeSize, bool UnitAtATime,
-    bool UnrollLoops, bool SimplifyLibCalls, bool HaveExceptions,
+    bool UnrollLoops, bool SimplifyLibCalls,
     unsigned int InliningThreshold);
 
 int *RustHackToFetchPassesO = (int*)LLVMAddBasicAliasAnalysisPass;
@@ -80,7 +80,6 @@ extern "C" void LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
                                         LLVMCodeGenFileType FileType) {
 
   // Set compilation options.
-  llvm::UnwindTablesMandatory = true;
   llvm::NoFramePointerElim = true;
 
   InitializeAllTargets();