about summary refs log tree commit diff
path: root/src/rustllvm
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2014-03-31 14:43:19 -0700
committerAlex Crichton <alex@alexcrichton.com>2014-04-17 11:11:39 -0700
commit30ff17f809869dec37d7b501fb532dc88fd47832 (patch)
treec2959002747236a37d2b5a1920ba49c8aea4c099 /src/rustllvm
parent903fbd263553c105b7b8c5f5ee19fab89d4618bd (diff)
downloadrust-30ff17f809869dec37d7b501fb532dc88fd47832.tar.gz
rust-30ff17f809869dec37d7b501fb532dc88fd47832.zip
Upgrade LLVM
This comes with a number of fixes to be compatible with upstream LLVM:

* Previously all monomorphizations of "mem::size_of()" would receive the same
  symbol. In the past LLVM would silently rename duplicated symbols, but it
  appears to now be dropping the duplicate symbols and functions now. The symbol
  names of monomorphized functions are now no longer solely based on the type of
  the function, but rather the type and the unique hash for the
  monomorphization.

* Split stacks are no longer a global feature controlled by a flag in LLVM.
  Instead, they are opt-in on a per-function basis through a function attribute.
  The rust #[no_split_stack] attribute will disable this, otherwise all
  functions have #[split_stack] attached to them.

* The compare and swap instruction now takes two atomic orderings, one for the
  successful case and one for the failure case. LLVM internally has an
  implementation of calculating the appropriate failure ordering given a
  particular success ordering (previously only a success ordering was
  specified), and I copied that into the intrinsic translation so the failure
  ordering isn't supplied on a source level for now.

* Minor tweaks to LLVM's API in terms of debuginfo, naming, c++11 conventions,
  etc.
Diffstat (limited to 'src/rustllvm')
-rw-r--r--src/rustllvm/PassWrapper.cpp6
-rw-r--r--src/rustllvm/RustWrapper.cpp48
-rw-r--r--src/rustllvm/llvm-auto-clean-trigger2
-rw-r--r--src/rustllvm/rustllvm.h9
4 files changed, 51 insertions, 14 deletions
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index 2be7c84ab03..32bac73debf 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -81,7 +81,9 @@ LLVMRustCreateTargetMachine(const char *triple,
 
     TargetOptions Options;
     Options.NoFramePointerElim = NoFramePointerElim;
+#if LLVM_VERSION_MINOR < 5
     Options.EnableSegmentedStacks = EnableSegmentedStacks;
+#endif
     Options.FloatABIType = FloatABI::Default;
     Options.UseSoftFloat = UseSoftFloat;
     if (UseSoftFloat) {
@@ -111,7 +113,11 @@ LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM,
                           LLVMPassManagerRef PMR,
                           LLVMModuleRef M) {
     PassManagerBase *PM = unwrap(PMR);
+#if LLVM_VERSION_MINOR >= 5
+    PM->add(new DataLayoutPass(unwrap(M)));
+#else
     PM->add(new DataLayout(unwrap(M)));
+#endif
     unwrap(TM)->addAnalysisPasses(*PM);
 }
 
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 5a00a8034e6..035a39669de 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -129,9 +129,14 @@ extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B,
                                                LLVMValueRef target,
                                                LLVMValueRef old,
                                                LLVMValueRef source,
-                                               AtomicOrdering order) {
+                                               AtomicOrdering order,
+                                               AtomicOrdering failure_order) {
     return wrap(unwrap(B)->CreateAtomicCmpXchg(unwrap(target), unwrap(old),
-                                               unwrap(source), order));
+                                               unwrap(source), order
+#if LLVM_VERSION_MINOR >= 5
+                                               , failure_order
+#endif
+                                               ));
 }
 extern "C" LLVMValueRef LLVMBuildAtomicFence(LLVMBuilderRef B, AtomicOrdering order) {
     return wrap(unwrap(B)->CreateFence(order));
@@ -289,10 +294,9 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStructType(
         RunTimeLang,
         unwrapDI<DIType>(VTableHolder)
 #if LLVM_VERSION_MINOR >= 5
-        ,UniqueId));
-#else
-        ));
+        ,UniqueId
 #endif
+        ));
 }
 
 extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType(
@@ -318,10 +322,15 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock(
     LLVMValueRef Scope,
     LLVMValueRef File,
     unsigned Line,
-    unsigned Col) {
+    unsigned Col,
+    unsigned Discriminator) {
     return wrap(Builder->createLexicalBlock(
         unwrapDI<DIDescriptor>(Scope),
-        unwrapDI<DIFile>(File), Line, Col));
+        unwrapDI<DIFile>(File), Line, Col
+#if LLVM_VERSION_MINOR >= 5
+        , Discriminator
+#endif
+        ));
 }
 
 extern "C" LLVMValueRef LLVMDIBuilderCreateStaticVariable(
@@ -477,15 +486,16 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateUnionType(
         unwrapDI<DIArray>(Elements),
         RunTimeLang
 #if LLVM_VERSION_MINOR >= 5
-        ,UniqueId));
-#else
-        ));
+        ,UniqueId
 #endif
+        ));
 }
 
+#if LLVM_VERSION_MINOR < 5
 extern "C" void LLVMSetUnnamedAddr(LLVMValueRef Value, LLVMBool Unnamed) {
     unwrap<GlobalValue>(Value)->setUnnamedAddr(Unnamed);
 }
+#endif
 
 extern "C" LLVMValueRef LLVMDIBuilderCreateTemplateTypeParameter(
     DIBuilderRef Builder,
@@ -620,6 +630,23 @@ LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
 }
 #endif
 
+#if LLVM_VERSION_MINOR >= 5
+extern "C" void*
+LLVMRustOpenArchive(char *path) {
+    std::unique_ptr<MemoryBuffer> buf;
+    error_code err = MemoryBuffer::getFile(path, buf);
+    if (err) {
+        LLVMRustError = err.message().c_str();
+        return NULL;
+    }
+    Archive *ret = new Archive(buf.release(), err);
+    if (err) {
+        LLVMRustError = err.message().c_str();
+        return NULL;
+    }
+    return ret;
+}
+#else
 extern "C" void*
 LLVMRustOpenArchive(char *path) {
     OwningPtr<MemoryBuffer> buf;
@@ -635,6 +662,7 @@ LLVMRustOpenArchive(char *path) {
     }
     return ret;
 }
+#endif
 
 extern "C" const char*
 LLVMRustArchiveReadSection(Archive *ar, char *name, size_t *size) {
diff --git a/src/rustllvm/llvm-auto-clean-trigger b/src/rustllvm/llvm-auto-clean-trigger
index 3426e823b9f..340a4915277 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.
-2014-02-25
+2014-04-14
diff --git a/src/rustllvm/rustllvm.h b/src/rustllvm/rustllvm.h
index f046587052a..42c60e72bab 100644
--- a/src/rustllvm/rustllvm.h
+++ b/src/rustllvm/rustllvm.h
@@ -12,7 +12,6 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#include "llvm/Linker.h"
 #include "llvm/PassManager.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
@@ -43,8 +42,6 @@
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/Instrumentation.h"
 #include "llvm/Transforms/Vectorize.h"
-#include "llvm/DebugInfo.h"
-#include "llvm/DIBuilder.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm-c/Core.h"
 #include "llvm-c/BitReader.h"
@@ -53,8 +50,14 @@
 
 #if LLVM_VERSION_MINOR >= 5
 #include "llvm/IR/IRPrintingPasses.h"
+#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DIBuilder.h"
+#include "llvm/Linker/Linker.h"
 #else
 #include "llvm/Assembly/PrintModulePass.h"
+#include "llvm/DebugInfo.h"
+#include "llvm/DIBuilder.h"
+#include "llvm/Linker.h"
 #endif
 
 // Used by RustMCJITMemoryManager::getPointerToNamedFunction()