about summary refs log tree commit diff homepage
path: root/lib
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
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')
-rw-r--r--lib/Core/CallPathManager.cpp4
-rw-r--r--lib/Core/Context.cpp5
-rw-r--r--lib/Core/ExecutionState.cpp4
-rw-r--r--lib/Core/Executor.cpp159
-rw-r--r--lib/Core/Executor.h6
-rw-r--r--lib/Core/ExecutorTimers.cpp5
-rw-r--r--lib/Core/ExecutorUtil.cpp20
-rw-r--r--lib/Core/ExternalDispatcher.cpp23
-rw-r--r--lib/Core/Memory.cpp12
-rw-r--r--lib/Core/Searcher.cpp6
-rw-r--r--lib/Core/SpecialFunctionHandler.cpp17
-rw-r--r--lib/Core/StatsTracker.cpp13
-rw-r--r--lib/Expr/Constraints.cpp7
-rw-r--r--lib/Expr/Expr.cpp6
-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
-rw-r--r--lib/Support/CompressionStream.cpp13
-rw-r--r--lib/Support/FileHandling.cpp5
26 files changed, 60 insertions, 587 deletions
diff --git a/lib/Core/CallPathManager.cpp b/lib/Core/CallPathManager.cpp
index 03e75108..42be3735 100644
--- a/lib/Core/CallPathManager.cpp
+++ b/lib/Core/CallPathManager.cpp
@@ -13,11 +13,7 @@
 
 #include <map>
 #include <vector>
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
-#else
-#include "llvm/Function.h"
-#endif
 
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/lib/Core/Context.cpp b/lib/Core/Context.cpp
index 935e4316..8246e631 100644
--- a/lib/Core/Context.cpp
+++ b/lib/Core/Context.cpp
@@ -11,13 +11,8 @@
 
 #include "klee/Expr.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Type.h"
 #include "llvm/IR/DerivedTypes.h"
-#else
-#include "llvm/Type.h"
-#include "llvm/DerivedTypes.h"
-#endif
 
 #include <cassert>
 
diff --git a/lib/Core/ExecutionState.cpp b/lib/Core/ExecutionState.cpp
index 30d20266..20b1a162 100644
--- a/lib/Core/ExecutionState.cpp
+++ b/lib/Core/ExecutionState.cpp
@@ -17,11 +17,7 @@
 #include "klee/Expr.h"
 
 #include "Memory.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
-#else
-#include "llvm/Function.h"
-#endif
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index ff842fd1..5560a3e5 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -49,7 +49,6 @@
 #include "klee/Internal/System/MemoryUsage.h"
 #include "klee/SolverStats.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Attributes.h"
 #include "llvm/IR/BasicBlock.h"
@@ -61,22 +60,6 @@
 #include "llvm/IR/Module.h"
 #include "llvm/IR/DataLayout.h"
 #include "llvm/IR/TypeBuilder.h"
-#else
-#include "llvm/Attributes.h"
-#include "llvm/BasicBlock.h"
-#include "llvm/Constants.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-#include "llvm/Target/TargetData.h"
-#else
-#include "llvm/DataLayout.h"
-#include "llvm/TypeBuilder.h"
-#endif
-#endif
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
@@ -293,17 +276,10 @@ namespace {
 		    KLEE_LLVM_CL_VAL_END),
 		  cl::ZeroOrMore);
 
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
-  cl::opt<unsigned int>
-  StopAfterNInstructions("stop-after-n-instructions",
-                         cl::desc("Stop execution after specified number of instructions (default=0 (off))"),
-                         cl::init(0));
-#else
   cl::opt<unsigned long long>
   StopAfterNInstructions("stop-after-n-instructions",
                          cl::desc("Stop execution after specified number of instructions (default=0 (off))"),
                          cl::init(0));
-#endif
   
   cl::opt<unsigned>
   MaxForks("max-forks",
@@ -420,11 +396,7 @@ const Module *Executor::setModule(llvm::Module *module,
   kmodule = new KModule(module);
 
   // Initialize the context.
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  TargetData *TD = kmodule->targetData;
-#else
   DataLayout *TD = kmodule->targetData;
-#endif
   Context::initialize(TD->isLittleEndian(),
                       (Expr::Width) TD->getPointerSizeInBits());
 
@@ -469,11 +441,7 @@ Executor::~Executor() {
 void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
                                       const Constant *c, 
                                       unsigned offset) {
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  TargetData *targetData = kmodule->targetData;
-#else
   DataLayout *targetData = kmodule->targetData;
-#endif
   if (const ConstantVector *cp = dyn_cast<ConstantVector>(c)) {
     unsigned elementSize =
       targetData->getTypeStoreSize(cp->getType()->getElementType());
@@ -496,7 +464,6 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
     for (unsigned i=0, e=cs->getNumOperands(); i != e; ++i)
       initializeGlobalObject(state, os, cs->getOperand(i), 
 			     offset + sl->getElementOffset(i));
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
   } else if (const ConstantDataSequential *cds =
                dyn_cast<ConstantDataSequential>(c)) {
     unsigned elementSize =
@@ -504,7 +471,6 @@ void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
     for (unsigned i=0, e=cds->getNumElements(); i != e; ++i)
       initializeGlobalObject(state, os, cds->getElementAsConstant(i),
                              offset + i*elementSize);
-#endif
   } else if (!isa<UndefValue>(c)) {
     unsigned StoreBits = targetData->getTypeStoreSizeInBits(c->getType());
     ref<ConstantExpr> C = evalConstant(c);
@@ -539,10 +505,6 @@ void Executor::initializeGlobals(ExecutionState &state) {
 
   if (m->getModuleInlineAsm() != "")
     klee_warning("executable has module level assembly (ignoring)");
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 3)
-  assert(m->lib_begin() == m->lib_end() &&
-         "XXX do not support dependent libraries");
-#endif
   // represent function globals using the address of the actual llvm function
   // object. given that we use malloc to allocate memory in states this also
   // ensures that we won't conflict. we don't need to allocate a memory object
@@ -610,7 +572,7 @@ void Executor::initializeGlobals(ExecutionState &state) {
       // better we could support user definition, or use the EXE style
       // hack where we check the object file information.
 
-      LLVM_TYPE_Q Type *ty = i->getType()->getElementType();
+      Type *ty = i->getType()->getElementType();
       uint64_t size = 0;
       if (ty->isSized()) {
 	size = kmodule->targetData->getTypeStoreSize(ty);
@@ -659,7 +621,7 @@ void Executor::initializeGlobals(ExecutionState &state) {
           os->write8(offset, ((unsigned char*)addr)[offset]);
       }
     } else {
-      LLVM_TYPE_Q Type *ty = i->getType()->getElementType();
+      Type *ty = i->getType()->getElementType();
       uint64_t size = kmodule->targetData->getTypeStoreSize(ty);
       MemoryObject *mo = memory->allocate(size, /*isLocal=*/false,
                                           /*isGlobal=*/true, /*allocSite=*/v,
@@ -1063,7 +1025,6 @@ ref<klee::ConstantExpr> Executor::evalConstant(const Constant *c) {
       return Expr::createPointer(0);
     } else if (isa<UndefValue>(c) || isa<ConstantAggregateZero>(c)) {
       return ConstantExpr::create(0, getWidthForLLVMType(c->getType()));
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
     } else if (const ConstantDataSequential *cds =
                  dyn_cast<ConstantDataSequential>(c)) {
       std::vector<ref<Expr> > kids;
@@ -1073,7 +1034,6 @@ ref<klee::ConstantExpr> Executor::evalConstant(const Constant *c) {
       }
       ref<Expr> res = ConcatExpr::createN(kids.size(), kids.data());
       return cast<ConstantExpr>(res);
-#endif
     } else if (const ConstantStruct *cs = dyn_cast<ConstantStruct>(c)) {
       const StructLayout *sl = kmodule->targetData->getStructLayout(cs->getType());
       llvm::SmallVector<ref<Expr>, 4> kids;
@@ -1581,7 +1541,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
       }
 
       if (!isVoidReturn) {
-        LLVM_TYPE_Q Type *t = caller->getType();
+        Type *t = caller->getType();
         if (t != Type::getVoidTy(i->getContext())) {
           // may need to do coercion due to bitcasts
           Expr::Width from = result->getWidth();
@@ -1592,13 +1552,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
                            CallSite(cast<CallInst>(caller)));
 
             // XXX need to check other param attrs ?
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
       bool isSExt = cs.paramHasAttr(0, llvm::Attribute::SExt);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
-	    bool isSExt = cs.paramHasAttr(0, llvm::Attributes::SExt);
-#else
-	    bool isSExt = cs.paramHasAttr(0, llvm::Attribute::SExt);
-#endif
             if (isSExt) {
               result = SExtExpr::create(result, to);
             } else {
@@ -1619,29 +1573,6 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     }      
     break;
   }
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
-  case Instruction::Unwind: {
-    for (;;) {
-      KInstruction *kcaller = state.stack.back().caller;
-      state.popFrame();
-
-      if (statsTracker)
-        statsTracker->framePopped(state);
-
-      if (state.stack.empty()) {
-        terminateStateOnExecError(state, "unwind from initial stack frame");
-        break;
-      } else {
-        Instruction *caller = kcaller->inst;
-        if (InvokeInst *ii = dyn_cast<InvokeInst>(caller)) {
-          transferToBasicBlock(ii->getUnwindDest(), caller->getParent(), state);
-          break;
-        }
-      }
-    }
-    break;
-  }
-#endif
   case Instruction::Br: {
     BranchInst *bi = cast<BranchInst>(i);
     if (bi->isUnconditional()) {
@@ -1676,14 +1607,9 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     if (ConstantExpr *CE = dyn_cast<ConstantExpr>(cond)) {
       // Somewhat gross to create these all the time, but fine till we
       // switch to an internal rep.
-      LLVM_TYPE_Q llvm::IntegerType *Ty = 
-        cast<IntegerType>(si->getCondition()->getType());
+      llvm::IntegerType *Ty = cast<IntegerType>(si->getCondition()->getType());
       ConstantInt *ci = ConstantInt::get(Ty, CE->getZExtValue());
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
       unsigned index = si->findCaseValue(ci).getSuccessorIndex();
-#else
-      unsigned index = si->findCaseValue(ci);
-#endif
       transferToBasicBlock(si->getSuccessor(index), si->getParent(), state);
     } else {
       // Handle possible different branch targets
@@ -1699,20 +1625,11 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
       std::map<ref<Expr>, BasicBlock *> expressionOrder;
 
       // Iterate through all non-default cases and order them by expressions
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
       for (SwitchInst::CaseIt i = si->case_begin(), e = si->case_end(); i != e;
            ++i) {
         ref<Expr> value = evalConstant(i.getCaseValue());
-#else
-      for (unsigned i = 1, cases = si->getNumCases(); i < cases; ++i) {
-        ref<Expr> value = evalConstant(si->getCaseValue(i));
-#endif
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
         BasicBlock *caseSuccessor = i.getCaseSuccessor();
-#else
-        BasicBlock *caseSuccessor = si->getSuccessor(i);
-#endif
         expressionOrder.insert(std::make_pair(value, caseSuccessor));
       }
 
@@ -1848,13 +1765,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
 
             if (from != to) {
               // XXX need to check other param attrs ?
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
               bool isSExt = cs.paramHasAttr(i+1, llvm::Attribute::SExt);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
-	      bool isSExt = cs.paramHasAttr(i+1, llvm::Attributes::SExt);
-#else
-	      bool isSExt = cs.paramHasAttr(i+1, llvm::Attribute::SExt);
-#endif
               if (isSExt) {
                 arguments[i] = SExtExpr::create(arguments[i], to);
               } else {
@@ -1910,11 +1821,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     break;
   }
   case Instruction::PHI: {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
     ref<Expr> result = eval(ki, state.incomingBBIndex, state).value;
-#else
-    ref<Expr> result = eval(ki, state.incomingBBIndex * 2, state).value;
-#endif
     bindLocal(ki, state, result);
     break;
   }
@@ -2233,13 +2140,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
         !fpWidthToSemantics(right->getWidth()))
       return terminateStateOnExecError(state, "Unsupported FAdd operation");
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
     Res.add(APFloat(*fpWidthToSemantics(right->getWidth()),right->getAPValue()), APFloat::rmNearestTiesToEven);
-#else
-    llvm::APFloat Res(left->getAPValue());
-    Res.add(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
-#endif
     bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
     break;
   }
@@ -2252,13 +2154,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     if (!fpWidthToSemantics(left->getWidth()) ||
         !fpWidthToSemantics(right->getWidth()))
       return terminateStateOnExecError(state, "Unsupported FSub operation");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
     Res.subtract(APFloat(*fpWidthToSemantics(right->getWidth()), right->getAPValue()), APFloat::rmNearestTiesToEven);
-#else
-    llvm::APFloat Res(left->getAPValue());
-    Res.subtract(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
-#endif
     bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
     break;
   }
@@ -2272,13 +2169,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
         !fpWidthToSemantics(right->getWidth()))
       return terminateStateOnExecError(state, "Unsupported FMul operation");
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
     Res.multiply(APFloat(*fpWidthToSemantics(right->getWidth()), right->getAPValue()), APFloat::rmNearestTiesToEven);
-#else
-    llvm::APFloat Res(left->getAPValue());
-    Res.multiply(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
-#endif
     bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
     break;
   }
@@ -2292,13 +2184,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
         !fpWidthToSemantics(right->getWidth()))
       return terminateStateOnExecError(state, "Unsupported FDiv operation");
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
     Res.divide(APFloat(*fpWidthToSemantics(right->getWidth()), right->getAPValue()), APFloat::rmNearestTiesToEven);
-#else
-    llvm::APFloat Res(left->getAPValue());
-    Res.divide(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
-#endif
     bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
     break;
   }
@@ -2311,14 +2198,9 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     if (!fpWidthToSemantics(left->getWidth()) ||
         !fpWidthToSemantics(right->getWidth()))
       return terminateStateOnExecError(state, "Unsupported FRem operation");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(left->getWidth()), left->getAPValue());
     Res.mod(APFloat(*fpWidthToSemantics(right->getWidth()),right->getAPValue()),
             APFloat::rmNearestTiesToEven);
-#else
-    llvm::APFloat Res(left->getAPValue());
-    Res.mod(APFloat(right->getAPValue()), APFloat::rmNearestTiesToEven);
-#endif
     bindLocal(ki, state, ConstantExpr::alloc(Res.bitcastToAPInt()));
     break;
   }
@@ -2331,11 +2213,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     if (!fpWidthToSemantics(arg->getWidth()) || resultType > arg->getWidth())
       return terminateStateOnExecError(state, "Unsupported FPTrunc operation");
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(arg->getWidth()), arg->getAPValue());
-#else
-    llvm::APFloat Res(arg->getAPValue());
-#endif
     bool losesInfo = false;
     Res.convert(*fpWidthToSemantics(resultType),
                 llvm::APFloat::rmNearestTiesToEven,
@@ -2351,11 +2229,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
                                         "floating point");
     if (!fpWidthToSemantics(arg->getWidth()) || arg->getWidth() > resultType)
       return terminateStateOnExecError(state, "Unsupported FPExt operation");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Res(*fpWidthToSemantics(arg->getWidth()), arg->getAPValue());
-#else
-    llvm::APFloat Res(arg->getAPValue());
-#endif
     bool losesInfo = false;
     Res.convert(*fpWidthToSemantics(resultType),
                 llvm::APFloat::rmNearestTiesToEven,
@@ -2372,11 +2246,7 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     if (!fpWidthToSemantics(arg->getWidth()) || resultType > 64)
       return terminateStateOnExecError(state, "Unsupported FPToUI operation");
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Arg(*fpWidthToSemantics(arg->getWidth()), arg->getAPValue());
-#else
-    llvm::APFloat Arg(arg->getAPValue());
-#endif
     uint64_t value = 0;
     bool isExact = true;
     Arg.convertToInteger(&value, resultType, false,
@@ -2392,12 +2262,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
                                        "floating point");
     if (!fpWidthToSemantics(arg->getWidth()) || resultType > 64)
       return terminateStateOnExecError(state, "Unsupported FPToSI operation");
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     llvm::APFloat Arg(*fpWidthToSemantics(arg->getWidth()), arg->getAPValue());
-#else
-    llvm::APFloat Arg(arg->getAPValue());
 
-#endif
     uint64_t value = 0;
     bool isExact = true;
     Arg.convertToInteger(&value, resultType, true,
@@ -2448,13 +2314,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
         !fpWidthToSemantics(right->getWidth()))
       return terminateStateOnExecError(state, "Unsupported FCmp operation");
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
     APFloat LHS(*fpWidthToSemantics(left->getWidth()),left->getAPValue());
     APFloat RHS(*fpWidthToSemantics(right->getWidth()),right->getAPValue());
-#else
-    APFloat LHS(left->getAPValue());
-    APFloat RHS(right->getAPValue());
-#endif
     APFloat::cmpResult CmpRes = LHS.compare(RHS);
 
     bool Result = false;
@@ -2572,12 +2433,10 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) {
     bindLocal(ki, state, result);
     break;
   }
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
   case Instruction::Fence: {
     // Ignore for now
     break;
   }
-#endif
   case Instruction::InsertElement: {
     InsertElementInst *iei = cast<InsertElementInst>(i);
     ref<Expr> vec = eval(ki, 0, state).value;
@@ -2697,7 +2556,7 @@ void Executor::computeOffsets(KGEPInstruction *kgepi, TypeIt ib, TypeIt ie) {
     ConstantExpr::alloc(0, Context::get().getPointerWidth());
   uint64_t index = 1;
   for (TypeIt ii = ib; ii != ie; ++ii) {
-    if (LLVM_TYPE_Q StructType *st = dyn_cast<StructType>(*ii)) {
+    if (StructType *st = dyn_cast<StructType>(*ii)) {
       const StructLayout *sl = kmodule->targetData->getStructLayout(st);
       const ConstantInt *ci = cast<ConstantInt>(ii.getOperand());
       uint64_t addend = sl->getElementOffset((unsigned) ci->getZExtValue());
@@ -3189,7 +3048,7 @@ void Executor::callExternalFunction(ExecutionState &state,
     return;
   }
 
-  LLVM_TYPE_Q Type *resultType = target->inst->getType();
+  Type *resultType = target->inst->getType();
   if (resultType != Type::getVoidTy(function->getContext())) {
     ref<Expr> e = ConstantExpr::fromMemory((void*) args, 
                                            getWidthForLLVMType(resultType));
@@ -3860,7 +3719,7 @@ void Executor::doImpliedValueConcretization(ExecutionState &state,
   }
 }
 
-Expr::Width Executor::getWidthForLLVMType(LLVM_TYPE_Q llvm::Type *type) const {
+Expr::Width Executor::getWidthForLLVMType(llvm::Type *type) const {
   return kmodule->targetData->getTypeSizeInBits(type);
 }
 
@@ -3869,13 +3728,13 @@ size_t Executor::getAllocationAlignment(const llvm::Value *allocSite) const {
   // and should fetch the default from elsewhere.
   const size_t forcedAlignment = 8;
   size_t alignment = 0;
-  LLVM_TYPE_Q llvm::Type *type = NULL;
+  llvm::Type *type = NULL;
   std::string allocationSiteName(allocSite->getName().str());
   if (const GlobalValue *GV = dyn_cast<GlobalValue>(allocSite)) {
     alignment = GV->getAlignment();
     if (const GlobalVariable *globalVar = dyn_cast<GlobalVariable>(GV)) {
       // All GlobalVariables's have pointer type
-      LLVM_TYPE_Q llvm::PointerType *ptrType =
+      llvm::PointerType *ptrType =
           dyn_cast<llvm::PointerType>(globalVar->getType());
       assert(ptrType && "globalVar's type is not a pointer");
       type = ptrType->getElementType();
diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h
index b3bb6864..b8411a20 100644
--- a/lib/Core/Executor.h
+++ b/lib/Core/Executor.h
@@ -42,11 +42,7 @@ namespace llvm {
   class GlobalValue;
   class Instruction;
   class LLVMContext;
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-  class TargetData;
-#else
   class DataLayout;
-#endif
   class Twine;
   class Value;
 }
@@ -509,7 +505,7 @@ public:
   virtual void getCoveredLines(const ExecutionState &state,
                                std::map<const std::string*, std::set<unsigned> > &res);
 
-  Expr::Width getWidthForLLVMType(LLVM_TYPE_Q llvm::Type *type) const;
+  Expr::Width getWidthForLLVMType(llvm::Type *type) const;
   size_t getAllocationAlignment(const llvm::Value *allocSite) const;
 };
   
diff --git a/lib/Core/ExecutorTimers.cpp b/lib/Core/ExecutorTimers.cpp
index f1c45105..dd0d824e 100644
--- a/lib/Core/ExecutorTimers.cpp
+++ b/lib/Core/ExecutorTimers.cpp
@@ -20,12 +20,7 @@
 #include "klee/Internal/System/Time.h"
 #include "klee/Internal/Support/ErrorHandling.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
-#else
-#include "llvm/Function.h"
-#endif
-
 #include "llvm/Support/CommandLine.h"
 
 #include <unistd.h>
diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp
index b91b5dee..bd7c0711 100644
--- a/lib/Core/ExecutorUtil.cpp
+++ b/lib/Core/ExecutorUtil.cpp
@@ -20,23 +20,11 @@
 
 #include "klee/util/GetElementPtrTypeIterator.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Constants.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/DataLayout.h"
-#else
-#include "llvm/Constants.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#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 <cassert>
 
@@ -46,7 +34,7 @@ using namespace llvm;
 namespace klee {
 
   ref<ConstantExpr> Executor::evalConstantExpr(const llvm::ConstantExpr *ce) {
-    LLVM_TYPE_Q llvm::Type *type = ce->getType();
+    llvm::Type *type = ce->getType();
 
     ref<ConstantExpr> op1(0), op2(0), op3(0);
     int numOperands = ce->getNumOperands();
@@ -95,7 +83,7 @@ namespace klee {
         ref<ConstantExpr> addend = 
           ConstantExpr::alloc(0, Context::get().getPointerWidth());
 
-        if (LLVM_TYPE_Q StructType *st = dyn_cast<StructType>(*ii)) {
+        if (StructType *st = dyn_cast<StructType>(*ii)) {
           const StructLayout *sl = kmodule->targetData->getStructLayout(st);
           const ConstantInt *ci = cast<ConstantInt>(ii.getOperand());
 
@@ -153,11 +141,7 @@ namespace klee {
     case Instruction::FCmp:
       assert(0 && "floating point ConstantExprs unsupported");
     }
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
     llvm_unreachable("Unsupported expression in evalConstantExpr");
-#else
-    assert(0 && "Unsupported expression in evalConstantExpr");
-#endif
     return op1;
   }
 }
diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp
index df0dd9a9..6c54d34b 100644
--- a/lib/Core/ExternalDispatcher.cpp
+++ b/lib/Core/ExternalDispatcher.cpp
@@ -10,19 +10,11 @@
 #include "ExternalDispatcher.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/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
-#else
-#include "llvm/Constants.h"
-#include "llvm/DerivedTypes.h"
-#include "llvm/Instructions.h"
-#include "llvm/LLVMContext.h"
-#include "llvm/Module.h"
-#endif
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 6)
 #include "llvm/ExecutionEngine/MCJIT.h"
 #else
@@ -33,11 +25,7 @@
 #include "llvm/Support/DynamicLibrary.h"
 #include "llvm/Support/raw_ostream.h"
 
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 0)
-#include "llvm/Target/TargetSelect.h"
-#else
 #include "llvm/Support/TargetSelect.h"
-#endif
 
 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
 #include "llvm/Support/CallSite.h"
@@ -297,7 +285,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
 
   Value **args = new Value *[cs.arg_size()];
 
-  std::vector<LLVM_TYPE_Q Type *> nullary;
+  std::vector<Type *> nullary;
 
   // MCJIT functions need unique names, or wrong function can be called.
   // The module identifier is included because for the MCJIT we need
@@ -318,7 +306,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
   Instruction *argI64s = new LoadInst(argI64sp, "args", dBB);
 
   // Get the target function type.
-  LLVM_TYPE_Q FunctionType *FTy = cast<FunctionType>(
+  FunctionType *FTy = cast<FunctionType>(
       cast<PointerType>(target->getType())->getElementType());
 
   // Each argument will be passed by writing it into gTheArgsP[i].
@@ -328,7 +316,7 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
     // Determine the type the argument will be passed as. This accomodates for
     // the corresponding code in Executor.cpp for handling calls to bitcasted
     // functions.
-    LLVM_TYPE_Q Type *argTy =
+    Type *argTy =
         (i < FTy->getNumParams() ? FTy->getParamType(i) : (*ai)->getType());
     Instruction *argI64p = GetElementPtrInst::Create(
         argI64s, ConstantInt::get(Type::getInt32Ty(ctx), idx), "", dBB);
@@ -343,13 +331,8 @@ Function *ExternalDispatcherImpl::createDispatcher(Function *target,
 
   Constant *dispatchTarget = module->getOrInsertFunction(
       target->getName(), FTy, target->getAttributes());
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 0)
   Instruction *result = CallInst::Create(
       dispatchTarget, llvm::ArrayRef<Value *>(args, args + i), "", dBB);
-#else
-  Instruction *result =
-      CallInst::Create(dispatchTarget, args, args + i, "", dBB);
-#endif
   if (result->getType() != Type::getVoidTy(ctx)) {
     Instruction *resp = new BitCastInst(
         argI64s, PointerType::getUnqual(result->getType()), "", dBB);
diff --git a/lib/Core/Memory.cpp b/lib/Core/Memory.cpp
index 72f0a1fb..0d354bf3 100644
--- a/lib/Core/Memory.cpp
+++ b/lib/Core/Memory.cpp
@@ -19,15 +19,9 @@
 #include "ObjectHolder.h"
 #include "MemoryManager.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
-#include <llvm/IR/Function.h>
-#include <llvm/IR/Instruction.h>
-#include <llvm/IR/Value.h>
-#else
-#include <llvm/Function.h>
-#include <llvm/Instruction.h>
-#include <llvm/Value.h>
-#endif
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Instruction.h"
+#include "llvm/IR/Value.h"
 
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
diff --git a/lib/Core/Searcher.cpp b/lib/Core/Searcher.cpp
index d15226b3..0e7aa685 100644
--- a/lib/Core/Searcher.cpp
+++ b/lib/Core/Searcher.cpp
@@ -24,15 +24,9 @@
 #include "klee/Internal/Support/ModuleUtil.h"
 #include "klee/Internal/System/Time.h"
 #include "klee/Internal/Support/ErrorHandling.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #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/Support/CommandLine.h"
 
 #if LLVM_VERSION_CODE < LLVM_VERSION(3, 5)
diff --git a/lib/Core/SpecialFunctionHandler.cpp b/lib/Core/SpecialFunctionHandler.cpp
index 0ecbdd07..aaa26922 100644
--- a/lib/Core/SpecialFunctionHandler.cpp
+++ b/lib/Core/SpecialFunctionHandler.cpp
@@ -23,20 +23,9 @@
 
 #include "klee/CommandLine.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
 #include "llvm/IR/Module.h"
-#else
-#include "llvm/Module.h"
-#endif
 #include "llvm/ADT/Twine.h"
-
-#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
-#include "llvm/Target/TargetData.h"
-#elif LLVM_VERSION_CODE <= LLVM_VERSION(3, 2)
-#include "llvm/DataLayout.h"
-#else
 #include "llvm/IR/DataLayout.h"
-#endif
 
 #include <errno.h>
 
@@ -187,13 +176,7 @@ void SpecialFunctionHandler::prepare() {
       // Make sure NoReturn attribute is set, for optimization and
       // coverage counting.
       if (hi.doesNotReturn)
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
-        f->addFnAttr(Attribute::NoReturn);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 2)
-        f->addFnAttr(Attributes::NoReturn);
-#else
         f->addFnAttr(Attribute::NoReturn);
-#endif
 
       // Change to a declaration since we handle internally (simplifies
       // module and allows deleting dead code).
diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp
index addb3de6..3a87f57a 100644
--- a/lib/Core/StatsTracker.cpp
+++ b/lib/Core/StatsTracker.cpp
@@ -27,7 +27,6 @@
 #include "MemoryManager.h"
 #include "UserSearcher.h"
 
-#if LLVM_VERSION_CODE > LLVM_VERSION(3, 2)
 #include "llvm/IR/BasicBlock.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/Instructions.h"
@@ -35,15 +34,6 @@
 #include "llvm/IR/InlineAsm.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Type.h"
-#else
-#include "llvm/BasicBlock.h"
-#include "llvm/Function.h"
-#include "llvm/Instructions.h"
-#include "llvm/IntrinsicInst.h"
-#include "llvm/InlineAsm.h"
-#include "llvm/Module.h"
-#include "llvm/Type.h"
-#endif
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Path.h"
@@ -743,9 +733,6 @@ void StatsTracker::computeReachableUncovered() {
           sm.setIndexedValue(stats::minDistToReturn, 
                              id, 
                              isa<ReturnInst>(inst)
-#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
-                             || isa<UnwindInst>(inst)
-#endif
                              );
         }
       }
diff --git a/lib/Expr/Constraints.cpp b/lib/Expr/Constraints.cpp
index dbdfd999..1b3ad983 100644
--- a/lib/Expr/Constraints.cpp
+++ b/lib/Expr/Constraints.cpp
@@ -11,13 +11,10 @@
 
 #include "klee/util/ExprPPrinter.h"
 #include "klee/util/ExprVisitor.h"
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#include "klee/Internal/Module/KModule.h"
+
 #include "llvm/IR/Function.h"
-#else
-#include "llvm/Function.h"
-#endif
 #include "llvm/Support/CommandLine.h"
-#include "klee/Internal/Module/KModule.h"
 
 #include <map>
 
diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp
index ac50dda2..f73d1614 100644
--- a/lib/Expr/Expr.cpp
+++ b/lib/Expr/Expr.cpp
@@ -10,9 +10,7 @@
 #include "klee/Expr.h"
 #include "klee/Config/Version.h"
 
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
 #include "llvm/ADT/Hashing.h"
-#endif
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/raw_ostream.h"
 // FIXME: We shouldn't need this once fast constant support moves into
@@ -184,11 +182,7 @@ unsigned Expr::computeHash() {
 }
 
 unsigned ConstantExpr::computeHash() {
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1)
   hashValue = hash_value(value) ^ (getWidth() * MAGIC_HASH_CONSTANT);
-#else
-  hashValue = value.getHashValue() ^ (getWidth() * MAGIC_HASH_CONSTANT);
-#endif
   return hashValue;
 }
 
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);
diff --git a/lib/Support/CompressionStream.cpp b/lib/Support/CompressionStream.cpp
index 36303878..3cd5bc86 100644
--- a/lib/Support/CompressionStream.cpp
+++ b/lib/Support/CompressionStream.cpp
@@ -10,8 +10,7 @@
 #include "klee/Config/Version.h"
 #ifdef HAVE_ZLIB_H
 #include "klee/Internal/Support/CompressionStream.h"
-#if (LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) \
-    && LLVM_VERSION_CODE <= LLVM_VERSION(3, 4))
+#if (LLVM_VERSION_CODE == LLVM_VERSION(3, 4))
 #include "llvm/Support/system_error.h"
 #else
 #include "llvm/Support/FileSystem.h"
@@ -27,12 +26,11 @@ compressed_fd_ostream::compressed_fd_ostream(const char *Filename,
                                              std::string &ErrorInfo)
     : llvm::raw_ostream(), pos(0) {
   ErrorInfo = "";
-#if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
   // Open file in binary mode
 #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
   std::error_code EC =
       llvm::sys::fs::openFileForWrite(Filename, FD, llvm::sys::fs::F_None);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 3)
+#else
   llvm::error_code EC =
       llvm::sys::fs::openFileForWrite(Filename, FD, llvm::sys::fs::F_Binary);
 #endif
@@ -40,13 +38,6 @@ compressed_fd_ostream::compressed_fd_ostream(const char *Filename,
     ErrorInfo = EC.message();
     FD = -1;
   }
-#else
-  FD = ::open(Filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-  if (FD < 0) {
-    ErrorInfo = "Could not open file.";
-    FD = -1;
-  }
-#endif
   // Initialize the compression library
   strm.zalloc = 0;
   strm.zfree = 0;
diff --git a/lib/Support/FileHandling.cpp b/lib/Support/FileHandling.cpp
index 092a1af0..e5ead9f7 100644
--- a/lib/Support/FileHandling.cpp
+++ b/lib/Support/FileHandling.cpp
@@ -27,11 +27,8 @@ llvm::raw_fd_ostream *klee_open_output_file(std::string &path,
     error = ec.message();
 #elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 5)
   f = new llvm::raw_fd_ostream(path.c_str(), error, llvm::sys::fs::F_None);
-#elif LLVM_VERSION_CODE >= LLVM_VERSION(3, 4)
-  f = new llvm::raw_fd_ostream(path.c_str(), error, llvm::sys::fs::F_Binary);
 #else
-  f = new llvm::raw_fd_ostream(path.c_str(), error,
-                               llvm::raw_fd_ostream::F_Binary);
+  f = new llvm::raw_fd_ostream(path.c_str(), error, llvm::sys::fs::F_Binary);
 #endif
   if (!error.empty()) {
     if (f)