about summary refs log tree commit diff
path: root/src/rustllvm
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@gmail.com>2015-04-20 10:19:02 -0700
committerTamir Duberstein <tamird@gmail.com>2015-04-21 07:20:48 -0700
commitba276adab596bafe48a27dc02dcc5867446a52b5 (patch)
tree5cb6a4d98ba9e6e3c1ffc5782654d292bf338266 /src/rustllvm
parent77acda1c8ee75f9eb923ddd811ee591951b2d43f (diff)
downloadrust-ba276adab596bafe48a27dc02dcc5867446a52b5.tar.gz
rust-ba276adab596bafe48a27dc02dcc5867446a52b5.zip
LLVM < 3.5 is unsupported since bb18a3c
Diffstat (limited to 'src/rustllvm')
-rw-r--r--src/rustllvm/ExecutionEngineWrapper.cpp8
-rw-r--r--src/rustllvm/PassWrapper.cpp19
-rw-r--r--src/rustllvm/RustWrapper.cpp22
-rw-r--r--src/rustllvm/rustllvm.h7
4 files changed, 13 insertions, 43 deletions
diff --git a/src/rustllvm/ExecutionEngineWrapper.cpp b/src/rustllvm/ExecutionEngineWrapper.cpp
index 8ca81ab3d68..7e0630fd242 100644
--- a/src/rustllvm/ExecutionEngineWrapper.cpp
+++ b/src/rustllvm/ExecutionEngineWrapper.cpp
@@ -89,12 +89,12 @@ extern "C" LLVMExecutionEngineRef LLVMBuildExecutionEngine(
     options.NoFramePointerElim = true;
 
     ExecutionEngine *ee =
-    #if LLVM_VERSION_MINOR <= 5
-        EngineBuilder(unwrap(mod))
-            .setMCJITMemoryManager(unwrap(mref))
-    #else
+    #if LLVM_VERSION_MINOR >= 6
         EngineBuilder(std::unique_ptr<Module>(unwrap(mod)))
             .setMCJITMemoryManager(std::unique_ptr<RustJITMemoryManager>(unwrap(mref)))
+    #else
+        EngineBuilder(unwrap(mod))
+            .setMCJITMemoryManager(unwrap(mref))
     #endif
             .setEngineKind(EngineKind::JIT)
             .setErrorStr(&error_str)
diff --git a/src/rustllvm/PassWrapper.cpp b/src/rustllvm/PassWrapper.cpp
index b205d87598c..a2ab8040198 100644
--- a/src/rustllvm/PassWrapper.cpp
+++ b/src/rustllvm/PassWrapper.cpp
@@ -92,9 +92,6 @@ LLVMRustCreateTargetMachine(const char *triple,
     TargetOptions Options;
     Options.PositionIndependentExecutable = PositionIndependentExecutable;
     Options.NoFramePointerElim = NoFramePointerElim;
-#if LLVM_VERSION_MINOR < 5
-    Options.EnableSegmentedStacks = EnableSegmentedStacks;
-#endif
     Options.FloatABIType = FloatABI::Default;
     Options.UseSoftFloat = UseSoftFloat;
     if (UseSoftFloat) {
@@ -128,10 +125,8 @@ LLVMRustAddAnalysisPasses(LLVMTargetMachineRef TM,
     PassManagerBase *PM = unwrap(PMR);
 #if LLVM_VERSION_MINOR >= 6
     PM->add(new DataLayoutPass());
-#elif LLVM_VERSION_MINOR == 5
-    PM->add(new DataLayoutPass(unwrap(M)));
 #else
-    PM->add(new DataLayout(unwrap(M)));
+    PM->add(new DataLayoutPass(unwrap(M)));
 #endif
     unwrap(TM)->addAnalysisPasses(*PM);
 }
@@ -202,10 +197,8 @@ LLVMRustWriteOutputFile(LLVMTargetMachineRef Target,
   raw_fd_ostream OS(path, EC, sys::fs::F_None);
   if (EC)
     ErrorInfo = EC.message();
-#elif LLVM_VERSION_MINOR >= 4
-  raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
 #else
-  raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
+  raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
 #endif
   if (ErrorInfo != "") {
     LLVMRustSetLastError(ErrorInfo.c_str());
@@ -230,19 +223,13 @@ LLVMRustPrintModule(LLVMPassManagerRef PMR,
   raw_fd_ostream OS(path, EC, sys::fs::F_None);
   if (EC)
     ErrorInfo = EC.message();
-#elif LLVM_VERSION_MINOR >= 4
-  raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
 #else
-  raw_fd_ostream OS(path, ErrorInfo, raw_fd_ostream::F_Binary);
+  raw_fd_ostream OS(path, ErrorInfo, sys::fs::F_None);
 #endif
 
   formatted_raw_ostream FOS(OS);
 
-#if LLVM_VERSION_MINOR >= 5
   PM->add(createPrintModulePass(FOS));
-#else
-  PM->add(createPrintModulePass(&FOS));
-#endif
 
   PM->run(*unwrap(M));
 }
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 31f75ae03b0..b9d62673a43 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -412,7 +412,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateStaticVariable(
     bool isLocalToUnit,
     LLVMValueRef Val,
     LLVMMetadataRef Decl = NULL) {
-#if LLVM_VERSION_MINOR == 6
+#if LLVM_VERSION_MINOR >= 6
     return wrap(Builder->createGlobalVariable(unwrapDI<DIDescriptor>(Context),
 #else
     return wrap(Builder->createStaticVariable(unwrapDI<DIDescriptor>(Context),
@@ -440,7 +440,7 @@ extern "C" LLVMMetadataRef LLVMDIBuilderCreateVariable(
     int64_t* AddrOps,
     unsigned AddrOpsCount,
     unsigned ArgNo) {
-#if LLVM_VERSION_MINOR < 6
+#if LLVM_VERSION_MINOR == 5
     if (AddrOpsCount > 0) {
         SmallVector<llvm::Value *, 16> addr_ops;
         llvm::Type *Int64Ty = Type::getInt64Ty(unwrap<MDNode>(Scope)->getContext());
@@ -707,12 +707,12 @@ extern "C" void LLVMWriteValueToString(LLVMValueRef Value, RustStringRef str) {
 extern "C" bool
 LLVMRustLinkInExternalBitcode(LLVMModuleRef dst, char *bc, size_t len) {
     Module *Dst = unwrap(dst);
-#if LLVM_VERSION_MINOR == 5
-    MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
-    ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
-#else
+#if LLVM_VERSION_MINOR >= 6
     std::unique_ptr<MemoryBuffer> buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
     ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(std::move(buf), Dst->getContext());
+#else
+    MemoryBuffer* buf = MemoryBuffer::getMemBufferCopy(StringRef(bc, len));
+    ErrorOr<Module *> Src = llvm::getLazyBitcodeModule(buf, Dst->getContext());
 #endif
     if (!Src) {
         LLVMRustSetLastError(Src.getError().message().c_str());
@@ -809,16 +809,6 @@ LLVMRustSetDLLExportStorageClass(LLVMValueRef Value) {
     V->setDLLStorageClass(GlobalValue::DLLExportStorageClass);
 }
 
-extern "C" int
-LLVMVersionMinor() {
-    return LLVM_VERSION_MINOR;
-}
-
-extern "C" int
-LLVMVersionMajor() {
-    return LLVM_VERSION_MAJOR;
-}
-
 // Note that the two following functions look quite similar to the
 // LLVMGetSectionName function. Sadly, it appears that this function only
 // returns a char* pointer, which isn't guaranteed to be null-terminated. The
diff --git a/src/rustllvm/rustllvm.h b/src/rustllvm/rustllvm.h
index 33dec63a728..8a4330acf43 100644
--- a/src/rustllvm/rustllvm.h
+++ b/src/rustllvm/rustllvm.h
@@ -46,17 +46,10 @@
 #include "llvm-c/ExecutionEngine.h"
 #include "llvm-c/Object.h"
 
-#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()
 // to get around glibc issues. See the function for more information.