about summary refs log tree commit diff homepage
path: root/lib/Module
diff options
context:
space:
mode:
authorMartin Nowack <martin@se.inf.tu-dresden.de>2017-07-22 01:03:44 +0200
committerMartin Nowack <martin@se.inf.tu-dresden.de>2017-07-23 12:18:35 +0200
commit37e92d0c802524c19a9a84164253639aac47fee3 (patch)
tree6b9036dcc8415544eb5a6d5cace7fddb2bfc323a /lib/Module
parent9fb2f5666d5f8c7c2f335fc8408883a0cf958964 (diff)
downloadklee-37e92d0c802524c19a9a84164253639aac47fee3.tar.gz
Remove support for LLVM < 3.4
Request LLVM 3.4 as minimal requirement for KLEE
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/Checks.cpp28
-rw-r--r--lib/Module/InstructionInfoTable.cpp11
-rw-r--r--lib/Module/InstructionOperandTypeCheckPass.cpp16
-rw-r--r--lib/Module/IntrinsicCleaner.cpp30
-rw-r--r--lib/Module/KModule.cpp96
-rw-r--r--lib/Module/LowerSwitch.cpp10
-rw-r--r--lib/Module/ModuleUtil.cpp36
-rw-r--r--lib/Module/Optimize.cpp41
-rw-r--r--lib/Module/Passes.h38
-rw-r--r--lib/Module/RaiseAsm.cpp36
10 files changed, 37 insertions, 305 deletions
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index eb0f189b..aac63e1d 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -11,7 +11,6 @@
 
 #include "klee/Config/Version.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
@@ -23,25 +22,6 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/DataLayout.h"
-#else
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
-#include "llvm/InstrTypes.h"
-#include "llvm/Instruction.h"
-#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/Module.h"
-#include "llvm/Type.h"
-
-#include "llvm/LLVMContext.h"
-
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-#include "llvm/Target/TargetData.h"
-#else
-#include "llvm/DataLayout.h"
-#endif
-#endif
 #include "llvm/Pass.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -144,12 +124,8 @@ bool OvershiftCheckPass::runOnModule(Module &M) {
             }
 
             // Inject CallInstr to check if overshifting possible
-            CallInst* ci =
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
-            CallInst::Create(overshiftCheckFunction, args, "", &*i);
-#else
-            CallInst::Create(overshiftCheckFunction, args.begin(), args.end(), "", &*i);
-#endif
+            CallInst *ci =
+                CallInst::Create(overshiftCheckFunction, args, "", &*i);
             // set debug information from binary operand to preserve it
             ci->setDebugLoc(binOp->getDebugLoc());
             moduleChanged = true;
diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp
index 3ba4895e..e2f05205 100644
--- a/lib/Module/InstructionInfoTable.cpp
+++ b/lib/Module/InstructionInfoTable.cpp
@@ -10,17 +10,10 @@
 #include "klee/Internal/Module/InstructionInfoTable.h"
 #include "klee/Config/Version.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Module.h"
-#else
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/Module.h"
-#endif
 
 # if LLVM_VERSION_CODE < LLVM_VERSION(3,5)
 #include "llvm/Assembly/AssemblyAnnotationWriter.h"
@@ -37,10 +30,8 @@
 
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3,5)
 #include "llvm/IR/DebugInfo.h"
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
-#include "llvm/DebugInfo.h"
 #else
-#include "llvm/Analysis/DebugInfo.h"
+#include "llvm/DebugInfo.h"
 #endif
 
 #include "llvm/Analysis/ValueTracking.h"
diff --git a/lib/Module/InstructionOperandTypeCheckPass.cpp b/lib/Module/InstructionOperandTypeCheckPass.cpp
index 449eea48..8f2b59bd 100644
--- a/lib/Module/InstructionOperandTypeCheckPass.cpp
+++ b/lib/Module/InstructionOperandTypeCheckPass.cpp
@@ -15,8 +15,8 @@ using namespace llvm;
 
 namespace {
 
-void printOperandWarning(const char *expected, const Instruction *i,
-                         LLVM_TYPE_Q Type *ty, unsigned opNum) {
+void printOperandWarning(const char *expected, const Instruction *i, Type *ty,
+                         unsigned opNum) {
   std::string msg;
   llvm::raw_string_ostream ss(msg);
   ss << "Found unexpected type (" << *ty << ") at operand " << opNum
@@ -28,7 +28,7 @@ void printOperandWarning(const char *expected, const Instruction *i,
 
 bool checkOperandTypeIsScalarInt(const Instruction *i, unsigned opNum) {
   assert(opNum < i->getNumOperands());
-  LLVM_TYPE_Q llvm::Type *ty = i->getOperand(opNum)->getType();
+  llvm::Type *ty = i->getOperand(opNum)->getType();
   if (!(ty->isIntegerTy())) {
     printOperandWarning("scalar integer", i, ty, opNum);
     return false;
@@ -39,7 +39,7 @@ bool checkOperandTypeIsScalarInt(const Instruction *i, unsigned opNum) {
 bool checkOperandTypeIsScalarIntOrPointer(const Instruction *i,
                                           unsigned opNum) {
   assert(opNum < i->getNumOperands());
-  LLVM_TYPE_Q llvm::Type *ty = i->getOperand(opNum)->getType();
+  llvm::Type *ty = i->getOperand(opNum)->getType();
   if (!(ty->isIntegerTy() || ty->isPointerTy())) {
     printOperandWarning("scalar integer or pointer", i, ty, opNum);
     return false;
@@ -49,7 +49,7 @@ bool checkOperandTypeIsScalarIntOrPointer(const Instruction *i,
 
 bool checkOperandTypeIsScalarPointer(const Instruction *i, unsigned opNum) {
   assert(opNum < i->getNumOperands());
-  LLVM_TYPE_Q llvm::Type *ty = i->getOperand(opNum)->getType();
+  llvm::Type *ty = i->getOperand(opNum)->getType();
   if (!(ty->isPointerTy())) {
     printOperandWarning("scalar pointer", i, ty, opNum);
     return false;
@@ -59,7 +59,7 @@ bool checkOperandTypeIsScalarPointer(const Instruction *i, unsigned opNum) {
 
 bool checkOperandTypeIsScalarFloat(const Instruction *i, unsigned opNum) {
   assert(opNum < i->getNumOperands());
-  LLVM_TYPE_Q llvm::Type *ty = i->getOperand(opNum)->getType();
+  llvm::Type *ty = i->getOperand(opNum)->getType();
   if (!(ty->isFloatingPointTy())) {
     printOperandWarning("scalar float", i, ty, opNum);
     return false;
@@ -71,8 +71,8 @@ bool checkOperandsHaveSameType(const Instruction *i, unsigned opNum0,
                                unsigned opNum1) {
   assert(opNum0 < i->getNumOperands());
   assert(opNum1 < i->getNumOperands());
-  LLVM_TYPE_Q llvm::Type *ty0 = i->getOperand(opNum0)->getType();
-  LLVM_TYPE_Q llvm::Type *ty1 = i->getOperand(opNum1)->getType();
+  llvm::Type *ty0 = i->getOperand(opNum0)->getType();
+  llvm::Type *ty1 = i->getOperand(opNum1)->getType();
   if (!(ty0 == ty1)) {
     std::string msg;
     llvm::raw_string_ostream ss(msg);
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 3f7644af..b0260520 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -10,7 +10,6 @@
 #include "Passes.h"
 
 #include "klee/Config/Version.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/DerivedTypes.h"
 #include "llvm/IR/Function.h"
@@ -21,29 +20,6 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/IRBuilder.h"
-
-#else
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Function.h"
-#include "llvm/InstrTypes.h"
-#include "llvm/Instruction.h"
-#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/Type.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
-#include "llvm/IRBuilder.h"
-#else
-#include "llvm/Support/IRBuilder.h"
-#endif
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-#include "llvm/Target/TargetData.h"
-#else
-#include "llvm/DataLayout.h"
-#endif
-#endif
 #include "llvm/Pass.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
@@ -72,11 +48,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
   bool block_split=false;
   LLVMContext &ctx = M.getContext();
   
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  unsigned WordSize = TargetData.getPointerSizeInBits() / 8;
-#else
   unsigned WordSize = DataLayout.getPointerSizeInBits() / 8;
-#endif
   for (BasicBlock::iterator i = b.begin(), ie = b.end();
        (i != ie) && (block_split == false);) {
     IntrinsicInst *ii = dyn_cast<IntrinsicInst>(&*i);
@@ -246,7 +218,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) {
         assert(minArgAsInt && "Second arg is not a ConstantInt");
         assert(minArgAsInt->getBitWidth() == 1 && "Second argument is not an i1");
         Value *replacement = NULL;
-        LLVM_TYPE_Q IntegerType *intType = dyn_cast<IntegerType>(ii->getType());
+        IntegerType *intType = dyn_cast<IntegerType>(ii->getType());
         assert(intType && "intrinsic does not have integer return type");
         if (minArgAsInt->isZero()) {
           // min=false
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index ec9972eb..19408d65 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -22,24 +22,11 @@
 #include "klee/Internal/Support/ModuleUtil.h"
 
 #include "llvm/Bitcode/ReaderWriter.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/ValueSymbolTable.h"
 #include "llvm/IR/DataLayout.h"
-#else
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#include "llvm/ValueSymbolTable.h"
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-#include "llvm/Target/TargetData.h"
-#else
-#include "llvm/DataLayout.h"
-#endif
-
-#endif
 
 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
 #include "llvm/Support/CallSite.h"
@@ -103,11 +90,7 @@ namespace {
 
 KModule::KModule(Module *_module) 
   : module(_module),
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-    targetData(new TargetData(module)),
-#else
     targetData(new DataLayout(module)),
-#endif
     kleeMergeFn(0),
     infos(0),
     constantTable(0) {
@@ -141,8 +124,8 @@ static Function *getStubFunctionForCtorList(Module *m,
                                             std::string name) {
   assert(!gv->isDeclaration() && !gv->hasInternalLinkage() &&
          "do not support old LLVM style constructor/destructor lists");
-  
-  std::vector<LLVM_TYPE_Q Type*> nullary;
+
+  std::vector<Type *> nullary;
 
   Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(m->getContext()),
 						    nullary, false),
@@ -208,32 +191,6 @@ static void injectStaticConstructorsAndDestructors(Module *m) {
   }
 }
 
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
-static void forceImport(Module *m, const char *name, LLVM_TYPE_Q Type *retType,
-                        ...) {
-  // If module lacks an externally visible symbol for the name then we
-  // need to create one. We have to look in the symbol table because
-  // we want to check everything (global variables, functions, and
-  // aliases).
-
-  Value *v = m->getValueSymbolTable().lookup(name);
-  GlobalValue *gv = dyn_cast_or_null<GlobalValue>(v);
-
-  if (!gv || gv->hasInternalLinkage()) {
-    va_list ap;
-
-    va_start(ap, retType);
-    std::vector<LLVM_TYPE_Q Type *> argTypes;
-    while (LLVM_TYPE_Q Type *t = va_arg(ap, LLVM_TYPE_Q Type*))
-      argTypes.push_back(t);
-    va_end(ap);
-
-    m->getOrInsertFunction(name, FunctionType::get(retType, argTypes, false));
-  }
-}
-#endif
-
-
 void KModule::addInternalFunction(const char* functionName){
   Function* internalFunction = module->getFunction(functionName);
   if (!internalFunction) {
@@ -252,9 +209,8 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
   if (!MergeAtExit.empty()) {
     Function *mergeFn = module->getFunction("klee_merge");
     if (!mergeFn) {
-      LLVM_TYPE_Q llvm::FunctionType *Ty = 
-        FunctionType::get(Type::getVoidTy(ctx),
-                          std::vector<LLVM_TYPE_Q Type*>(), false);
+      llvm::FunctionType *Ty =
+          FunctionType::get(Type::getVoidTy(ctx), std::vector<Type *>(), false);
       mergeFn = Function::Create(Ty, GlobalVariable::ExternalLinkage,
 				 "klee_merge",
 				 module);
@@ -275,11 +231,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
       BasicBlock *exit = BasicBlock::Create(ctx, "exit", f);
       PHINode *result = 0;
       if (f->getReturnType() != Type::getVoidTy(ctx))
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
         result = PHINode::Create(f->getReturnType(), 0, "retval", exit);
-#else
-		result = PHINode::Create(f->getReturnType(), "retval", exit);
-#endif
       CallInst::Create(mergeFn, "", exit);
       ReturnInst::Create(ctx, result, exit);
 
@@ -307,7 +259,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
   // module.
   LegacyLLVMPassManagerTy pm;
   pm.add(new RaiseAsmPass());
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3,4)
   // This pass will scalarize as much code as possible so that the Executor
   // does not need to handle operands of vector type for most instructions
   // other than InsertElementInst and ExtractElementInst.
@@ -315,7 +266,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
   // NOTE: Must come before division/overshift checks because those passes
   // don't know how to handle vector instructions.
   pm.add(createScalarizerPass());
-#endif
   if (opts.CheckDivZero) pm.add(new DivCheckPass());
   if (opts.CheckOvershift) pm.add(new OvershiftCheckPass());
   // FIXME: This false here is to work around a bug in
@@ -327,28 +277,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
 
   if (opts.Optimize)
     Optimize(module, opts.EntryPoint);
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
-  // Force importing functions required by intrinsic lowering. Kind of
-  // unfortunate clutter when we don't need them but we won't know
-  // that until after all linking and intrinsic lowering is
-  // done. After linking and passes we just try to manually trim these
-  // by name. We only add them if such a function doesn't exist to
-  // avoid creating stale uses.
-
-  LLVM_TYPE_Q llvm::Type *i8Ty = Type::getInt8Ty(ctx);
-  forceImport(module, "memcpy", PointerType::getUnqual(i8Ty),
-              PointerType::getUnqual(i8Ty),
-              PointerType::getUnqual(i8Ty),
-              targetData->getIntPtrType(ctx), (Type*) 0);
-  forceImport(module, "memmove", PointerType::getUnqual(i8Ty),
-              PointerType::getUnqual(i8Ty),
-              PointerType::getUnqual(i8Ty),
-              targetData->getIntPtrType(ctx), (Type*) 0);
-  forceImport(module, "memset", PointerType::getUnqual(i8Ty),
-              PointerType::getUnqual(i8Ty),
-              Type::getInt32Ty(ctx),
-              targetData->getIntPtrType(ctx), (Type*) 0);
-#endif
+
   // FIXME: Missing force import for various math functions.
 
   // FIXME: Find a way that we can test programs without requiring
@@ -357,11 +286,7 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
 
   SmallString<128> LibPath(opts.LibraryDir);
   llvm::sys::path::append(LibPath,
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3,3)
       "kleeRuntimeIntrinsic.bc"
-#else
-      "libkleeRuntimeIntrinsic.bca"
-#endif
     );
   module = linkWithLibrary(module, LibPath.str());
 
@@ -403,17 +328,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
   if (!operandTypeCheckPass->checkPassed()) {
     klee_error("Unexpected instruction operand types detected");
   }
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
-  // For cleanliness see if we can discard any of the functions we
-  // forced to import.
-  Function *f;
-  f = module->getFunction("memcpy");
-  if (f && f->use_empty()) f->eraseFromParent();
-  f = module->getFunction("memmove");
-  if (f && f->use_empty()) f->eraseFromParent();
-  f = module->getFunction("memset");
-  if (f && f->use_empty()) f->eraseFromParent();
-#endif
 
   // Write out the .ll assembly file. We truncate long lines to work
   // around a kcachegrind parsing bug (it puts them on new lines), so
diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp
index b20c21ab..1a194245 100644
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -16,11 +16,7 @@
 
 #include "Passes.h"
 #include "klee/Config/Version.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/LLVMContext.h"
-#else
-#include "llvm/LLVMContext.h"
-#endif
 #include <algorithm>
 
 using namespace llvm;
@@ -119,15 +115,9 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
   
   CaseVector cases;
   
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
   for (SwitchInst::CaseIt i = SI->case_begin(), e = SI->case_end(); i != e; ++i)
     cases.push_back(SwitchCase(i.getCaseValue(),
                                i.getCaseSuccessor()));
-#else
-  for (unsigned i = 1; i < SI->getNumSuccessors(); ++i)  
-    cases.push_back(SwitchCase(SI->getSuccessorValue(i),
-                               SI->getSuccessor(i)));
-#endif
   
   // reverse cases, as switchConvert constructs a chain of
   //   basic blocks by appending to the front. if we reverse,
diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp
index 1642f6d7..a8a87b2c 100644
--- a/lib/Module/ModuleUtil.cpp
+++ b/lib/Module/ModuleUtil.cpp
@@ -14,29 +14,19 @@
 #include "klee/Internal/Support/ErrorHandling.h"
 #include "../Core/SpecialFunctionHandler.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 4)
-#include "llvm/IR/LLVMContext.h"
-#endif
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#include "llvm/IRReader/IRReader.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/IntrinsicInst.h"
-#include "llvm/IRReader/IRReader.h"
+#include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/ValueSymbolTable.h"
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/Error.h"
 #include "llvm/Support/FileSystem.h"
-#include "llvm/IR/ValueSymbolTable.h"
 #include "llvm/Support/SourceMgr.h"
 #include "llvm/Support/DataStream.h"
-#else
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/Module.h"
-#endif
 
 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
 #include "llvm/Linker.h"
@@ -46,11 +36,6 @@
 #include "llvm/IR/AssemblyAnnotationWriter.h"
 #endif
 
-#if LLVM_VERSION_CODE <= LLVM_VERSION(2, 9)
-// for llvm::error_code
-#include "llvm/Support/system_error.h"
-#endif
-
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Bitcode/ReaderWriter.h"
 #include "llvm/Support/MemoryBuffer.h"
@@ -66,7 +51,6 @@
 using namespace llvm;
 using namespace klee;
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 /// Based on GetAllUndefinedSymbols() from LLVM3.2
 ///
 /// GetAllUndefinedSymbols - calculates the set of undefined symbols that still
@@ -396,13 +380,11 @@ static bool linkBCA(object::Archive* archive, Module* composite, std::string& er
   return true;
 
 }
-#endif
 
 
 Module *klee::linkWithLibrary(Module *module,
                               const std::string &libraryName) {
   KLEE_DEBUG_WITH_TYPE("klee_linker", dbgs() << "Linking file " << libraryName << "\n");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
   if (!sys::fs::exists(libraryName)) {
     klee_error("Link with library %s failed. No such file.",
         libraryName.c_str());
@@ -514,18 +496,6 @@ Module *klee::linkWithLibrary(Module *module,
   }
 
   return module;
-#else
-  Linker linker("klee", module, false);
-
-  llvm::sys::Path libraryPath(libraryName);
-  bool native = false;
-
-  if (linker.LinkInFile(libraryPath, native)) {
-    klee_error("Linking library %s failed", libraryName.c_str());
-  }
-
-  return linker.releaseModule();
-#endif
 }
 
 Function *klee::getDirectCallTarget(CallSite cs, bool moduleIsFullyLinked) {
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index 21c77c04..02ab446a 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -17,22 +17,17 @@
 
 #include "klee/Config/Version.h"
 #include "klee/Internal/Module/LLVMPassManager.h"
+
 #include "llvm/Analysis/Passes.h"
 #include "llvm/Analysis/LoopPass.h"
-#include "llvm/Support/CommandLine.h"
-#include "llvm/Support/DynamicLibrary.h"
-
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Module.h"
 #include "llvm/IR/DataLayout.h"
-#else
-#include "llvm/Module.h"
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-#include "llvm/Target/TargetData.h"
-#else
-#include "llvm/DataLayout.h"
-#endif
-#endif
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/DynamicLibrary.h"
+#include "llvm/Support/PluginLoader.h"
+#include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/IPO.h"
+#include "llvm/Transforms/Scalar.h"
 
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
 #include "llvm/IR/Verifier.h"
@@ -40,10 +35,6 @@
 #include "llvm/Analysis/Verifier.h"
 #endif
 
-#include "llvm/Target/TargetMachine.h"
-#include "llvm/Transforms/IPO.h"
-#include "llvm/Transforms/Scalar.h"
-#include "llvm/Support/PluginLoader.h"
 using namespace llvm;
 
 // Don't verify at the end
@@ -95,10 +86,6 @@ namespace llvm {
 static void AddStandardCompilePasses(klee::LegacyLLVMPassManagerTy &PM) {
   PM.add(createVerifierPass());                  // Verify that input is correct
 
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
-  addPass(PM, createLowerSetJmpPass());          // Lower llvm.setjmp/.longjmp
-#endif
-
   // If the -strip-debug command line option was specified, do it.
   if (StripDebug)
     addPass(PM, createStripSymbolsPass(true));
@@ -121,9 +108,6 @@ static void AddStandardCompilePasses(klee::LegacyLLVMPassManagerTy &PM) {
     addPass(PM, createFunctionInliningPass());   // Inline small functions
   addPass(PM, createArgumentPromotionPass());    // Scalarize uninlined fn args
 
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 4)
-  addPass(PM, createSimplifyLibCallsPass());     // Library Call Optimizations
-#endif
   addPass(PM, createInstructionCombiningPass()); // Cleanup for scalarrepl.
   addPass(PM, createJumpThreadingPass());        // Thread jumps.
   addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
@@ -154,9 +138,6 @@ static void AddStandardCompilePasses(klee::LegacyLLVMPassManagerTy &PM) {
   addPass(PM, createAggressiveDCEPass());        // Delete dead instructions
   addPass(PM, createCFGSimplificationPass());    // Merge & remove BBs
   addPass(PM, createStripDeadPrototypesPass());  // Get rid of dead prototypes
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
-  addPass(PM, createDeadTypeEliminationPass());  // Eliminate dead types
-#endif
   addPass(PM, createConstantMergePass());        // Merge dup global constants
 }
 
@@ -179,10 +160,8 @@ void Optimize(Module *M, const std::string &EntryPoint) {
   addPass(Passes, dlpass);
 #elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
   addPass(Passes, new DataLayoutPass(M));
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
-  addPass(Passes, new DataLayout(M));
 #else
-  addPass(Passes, new TargetData(M));
+  addPass(Passes, new DataLayout(M));
 #endif
 
   // DWD - Run the opt standard pass list as well.
@@ -193,12 +172,8 @@ void Optimize(Module *M, const std::string &EntryPoint) {
     // for a main function.  If main is defined, mark all other functions
     // internal.
     if (!DisableInternalize) {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
       ModulePass *pass = createInternalizePass(
           std::vector<const char *>(1, EntryPoint.c_str()));
-#else
-      ModulePass *pass = createInternalizePass(true);
-#endif
       addPass(Passes, pass);
     }
 
diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h
index 2ac57b9b..6ebcc98f 100644
--- a/lib/Module/Passes.h
+++ b/lib/Module/Passes.h
@@ -12,28 +12,18 @@
 
 #include "klee/Config/Version.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#include "llvm/ADT/Triple.h"
+#include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Module.h"
-#else
-#include "llvm/Constants.h"
-#include "llvm/Instructions.h"
-#include "llvm/Module.h"
-#endif
-#include "llvm/ADT/Triple.h"
-#include "llvm/CodeGen/IntrinsicLowering.h"
 #include "llvm/Pass.h"
 
 namespace llvm {
   class Function;
   class Instruction;
   class Module;
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  class TargetData;
-#else
   class DataLayout;
-#endif
   class TargetLowering;
   class Type;
 }
@@ -49,13 +39,9 @@ class RaiseAsmPass : public llvm::ModulePass {
 
   llvm::Triple triple;
 
-  llvm::Function *getIntrinsic(llvm::Module &M,
-                               unsigned IID,
-                               LLVM_TYPE_Q llvm::Type **Tys,
+  llvm::Function *getIntrinsic(llvm::Module &M, unsigned IID, llvm::Type **Tys,
                                unsigned NumTys);
-  llvm::Function *getIntrinsic(llvm::Module &M,
-                               unsigned IID, 
-                               LLVM_TYPE_Q llvm::Type *Ty0) {
+  llvm::Function *getIntrinsic(llvm::Module &M, unsigned IID, llvm::Type *Ty0) {
     return getIntrinsic(M, IID, &Ty0, 1);
   }
 
@@ -71,28 +57,16 @@ public:
   // variables (via intrinsic lowering).
 class IntrinsicCleanerPass : public llvm::ModulePass {
   static char ID;
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  const llvm::TargetData &TargetData;
-#else
   const llvm::DataLayout &DataLayout;
-#endif
   llvm::IntrinsicLowering *IL;
   bool LowerIntrinsics;
 
   bool runOnBasicBlock(llvm::BasicBlock &b, llvm::Module &M);
 public:
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  IntrinsicCleanerPass(const llvm::TargetData &TD,
-#else
   IntrinsicCleanerPass(const llvm::DataLayout &TD,
-#endif
                        bool LI=true)
     : llvm::ModulePass(ID),
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-      TargetData(TD),
-#else
       DataLayout(TD),
-#endif
       IL(new llvm::IntrinsicLowering(TD)),
       LowerIntrinsics(LI) {}
   ~IntrinsicCleanerPass() { delete IL; } 
@@ -181,9 +155,7 @@ private:
 };
 
 // This is the interface to a back-ported LLVM pass.
-// Newer versions of LLVM already have this in-tree
-// and we are not supporting vector instructions for
-// LLVM 2.9. Therefore this interface is only needed for
+// Therefore this interface is only needed for
 // LLVM 3.4.
 #if LLVM_VERSION_CODE == LLVM_VERSION(3,4)
 llvm::FunctionPass *createScalarizerPass();
diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp
index 113dcc62..22c51e18 100644
--- a/lib/Module/RaiseAsm.cpp
+++ b/lib/Module/RaiseAsm.cpp
@@ -10,45 +10,29 @@
 #include "Passes.h"
 #include "klee/Config/Version.h"
 #include "klee/Internal/Support/ErrorHandling.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/IRBuilder.h"
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Instructions.h"
-#else
-#include "llvm/InlineAsm.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Support/IRBuilder.h"
-#endif
 
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/Host.h"
+#include "llvm/Support/TargetRegistry.h"
 #include "llvm/Target/TargetLowering.h"
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
 #endif
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
-#include "llvm/Target/TargetRegistry.h"
-#else
-#include "llvm/Support/TargetRegistry.h"
-#endif
 
 using namespace llvm;
 using namespace klee;
 
 char RaiseAsmPass::ID = 0;
 
-Function *RaiseAsmPass::getIntrinsic(llvm::Module &M,
-                                     unsigned IID,
-                                     LLVM_TYPE_Q Type **Tys,
-                                     unsigned NumTys) {  
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
+Function *RaiseAsmPass::getIntrinsic(llvm::Module &M, unsigned IID, Type **Tys,
+                                     unsigned NumTys) {
   return Intrinsic::getDeclaration(&M, (llvm::Intrinsic::ID) IID,
                                    llvm::ArrayRef<llvm::Type*>(Tys, NumTys));
-#else
-  return Intrinsic::getDeclaration(&M, (llvm::Intrinsic::ID) IID, Tys, NumTys);
-#endif
 }
 
 // FIXME: This should just be implemented as a patch to
@@ -75,10 +59,8 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) {
        triple.getOS() == llvm::Triple::Darwin)) {
 
     if (ia->getAsmString() == "" && ia->hasSideEffects()) {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
       IRBuilder<> Builder(I);
       Builder.CreateFence(llvm::SequentiallyConsistent);
-#endif
       I->eraseFromParent();
       return true;
     }
@@ -91,11 +73,7 @@ bool RaiseAsmPass::runOnModule(Module &M) {
   bool changed = false;
 
   std::string Err;
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
   std::string HostTriple = llvm::sys::getDefaultTargetTriple();
-#else
-  std::string HostTriple = llvm::sys::getHostTriple();
-#endif
   const Target *NativeTarget = TargetRegistry::lookupTarget(HostTriple, Err);
 
   TargetMachine * TM = 0;
@@ -106,16 +84,10 @@ bool RaiseAsmPass::runOnModule(Module &M) {
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
     TM = NativeTarget->createTargetMachine(HostTriple, "", "", TargetOptions());
     TLI = TM->getSubtargetImpl()->getTargetLowering();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
+#else
     TM = NativeTarget->createTargetMachine(HostTriple, "", "",
                                                           TargetOptions());
     TLI = TM->getTargetLowering();
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
-    TM = NativeTarget->createTargetMachine(HostTriple, "", "");
-    TLI = TM->getTargetLowering();
-#else
-    TM = NativeTarget->createTargetMachine(HostTriple, "");
-    TLI = TM->getTargetLowering();
 #endif
 
     triple = llvm::Triple(HostTriple);