diff options
-rw-r--r-- | include/klee/Internal/Module/KInstruction.h | 4 | ||||
-rw-r--r-- | include/klee/Statistic.h | 4 | ||||
-rw-r--r-- | include/klee/util/Bits.h | 4 | ||||
-rw-r--r-- | lib/Core/Executor.cpp | 37 | ||||
-rw-r--r-- | lib/Core/ExecutorUtil.cpp | 3 | ||||
-rw-r--r-- | lib/Core/ExternalDispatcher.cpp | 16 | ||||
-rw-r--r-- | lib/Core/StatsTracker.cpp | 11 | ||||
-rw-r--r-- | lib/Core/TimingSolver.cpp | 4 | ||||
-rw-r--r-- | lib/Expr/Expr.cpp | 4 | ||||
-rw-r--r-- | lib/Expr/Parser.cpp | 8 | ||||
-rw-r--r-- | lib/Module/Checks.cpp | 2 | ||||
-rw-r--r-- | lib/Module/InstructionInfoTable.cpp | 27 | ||||
-rw-r--r-- | lib/Module/IntrinsicCleaner.cpp | 47 | ||||
-rw-r--r-- | lib/Module/KModule.cpp | 43 | ||||
-rw-r--r-- | lib/Module/LowerSwitch.cpp | 2 | ||||
-rw-r--r-- | lib/Module/ModuleUtil.cpp | 13 | ||||
-rw-r--r-- | lib/Module/Optimize.cpp | 16 | ||||
-rw-r--r-- | lib/Module/Passes.h | 26 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 36 | ||||
-rw-r--r-- | lib/Support/Time.cpp | 4 | ||||
-rw-r--r-- | lib/Support/Timer.cpp | 4 | ||||
-rw-r--r-- | tools/kleaver/main.cpp | 33 | ||||
-rw-r--r-- | tools/klee/main.cpp | 39 |
23 files changed, 3 insertions, 384 deletions
diff --git a/include/klee/Internal/Module/KInstruction.h b/include/klee/Internal/Module/KInstruction.h index 20db560d..fc86070b 100644 --- a/include/klee/Internal/Module/KInstruction.h +++ b/include/klee/Internal/Module/KInstruction.h @@ -11,11 +11,7 @@ #define KLEE_KINSTRUCTION_H #include "klee/Config/Version.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) && LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) -#include "llvm/System/DataTypes.h" -#else #include "llvm/Support/DataTypes.h" -#endif #include <vector> namespace llvm { diff --git a/include/klee/Statistic.h b/include/klee/Statistic.h index 1e5b1c92..6b8fb165 100644 --- a/include/klee/Statistic.h +++ b/include/klee/Statistic.h @@ -11,11 +11,7 @@ #define KLEE_STATISTIC_H #include "klee/Config/Version.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) && LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) -#include "llvm/System/DataTypes.h" -#else #include "llvm/Support/DataTypes.h" -#endif #include <string> namespace klee { diff --git a/include/klee/util/Bits.h b/include/klee/util/Bits.h index aa78e534..f228b289 100644 --- a/include/klee/util/Bits.h +++ b/include/klee/util/Bits.h @@ -11,11 +11,7 @@ #define KLEE_UTIL_BITS_H #include "klee/Config/Version.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) && LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) -#include "llvm/System/DataTypes.h" -#else #include "llvm/Support/DataTypes.h" -#endif namespace klee { namespace bits32 { diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index eadc685b..ef55f21f 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -67,9 +67,7 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" -#endif #include "llvm/Module.h" #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1) #include "llvm/Target/TargetData.h" @@ -83,11 +81,7 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Process.h" -#else #include "llvm/Support/Process.h" -#endif #include <cassert> #include <algorithm> @@ -1404,26 +1398,9 @@ Function* Executor::getTargetFunction(Value *calledVal, ExecutionState &state) { } } +/// TODO remove? static bool isDebugIntrinsic(const Function *f, KModule *KM) { -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - // Fast path, getIntrinsicID is slow. - if (f == KM->dbgStopPointFn) - return true; - - switch (f->getIntrinsicID()) { - case Intrinsic::dbg_stoppoint: - case Intrinsic::dbg_region_start: - case Intrinsic::dbg_region_end: - case Intrinsic::dbg_func_start: - case Intrinsic::dbg_declare: - return true; - - default: - return false; - } -#else return false; -#endif } static inline const llvm::fltSemantics * fpWidthToSemantics(unsigned width) { @@ -1973,14 +1950,8 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { } // Memory instructions... -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - case Instruction::Malloc: - case Instruction::Alloca: { - AllocationInst *ai = cast<AllocationInst>(i); -#else case Instruction::Alloca: { AllocaInst *ai = cast<AllocaInst>(i); -#endif unsigned elementSize = kmodule->targetData->getTypeStoreSize(ai->getAllocatedType()); ref<Expr> size = Expr::createPointer(elementSize); @@ -1993,12 +1964,6 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { executeAlloc(state, size, isLocal, ki); break; } -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - case Instruction::Free: { - executeFree(state, eval(ki, 0, state).value); - break; - } -#endif case Instruction::Load: { ref<Expr> base = eval(ki, 0, state).value; diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp index 9e83b32c..0d828ec4 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -31,9 +31,6 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Module.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) -#include "llvm/ModuleProvider.h" -#endif #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1) #include "llvm/Target/TargetData.h" #else diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index 344811d4..2dc16767 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -28,21 +28,12 @@ #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) -#include "llvm/ModuleProvider.h" -#endif -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" #endif -#endif #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Support/CallSite.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/DynamicLibrary.h" -#else #include "llvm/Support/DynamicLibrary.h" -#endif #include "llvm/Support/raw_ostream.h" #if LLVM_VERSION_CODE < LLVM_VERSION(3, 0) #include "llvm/Target/TargetSelect.h" @@ -97,16 +88,9 @@ void *ExternalDispatcher::resolveSymbol(const std::string &name) { ExternalDispatcher::ExternalDispatcher() { dispatchModule = new Module("ExternalDispatcher", getGlobalContext()); -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - ExistingModuleProvider* MP = new ExistingModuleProvider(dispatchModule); -#endif std::string error; -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - executionEngine = ExecutionEngine::createJIT(MP, &error); -#else executionEngine = ExecutionEngine::createJIT(dispatchModule, &error); -#endif if (!executionEngine) { std::cerr << "unable to make jit: " << error << "\n"; abort(); diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index b5f38b2e..8161a52c 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -47,19 +47,11 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/CFG.h" #include "llvm/Support/raw_os_ostream.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Process.h" -#else #include "llvm/Support/Process.h" -#endif -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Path.h" -#else #include "llvm/Support/Path.h" #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1) #include "llvm/Support/FileSystem.h" #endif -#endif #include <iostream> #include <fstream> @@ -305,9 +297,6 @@ void StatsTracker::stepInstruction(ExecutionState &es) { // // FIXME: This trick no longer works, we should fix this in the line // number propogation. -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - if (isa<DbgStopPointInst>(inst)) -#endif es.coveredLines[&ii.file].insert(ii.line); es.coveredNew = true; es.instsSinceCovNew = 1; diff --git a/lib/Core/TimingSolver.cpp b/lib/Core/TimingSolver.cpp index d2c07f46..037b23f3 100644 --- a/lib/Core/TimingSolver.cpp +++ b/lib/Core/TimingSolver.cpp @@ -16,11 +16,7 @@ #include "CoreStats.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Process.h" -#else #include "llvm/Support/Process.h" -#endif using namespace klee; using namespace llvm; diff --git a/lib/Expr/Expr.cpp b/lib/Expr/Expr.cpp index a28ad907..82c60205 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -354,11 +354,7 @@ void ConstantExpr::toString(std::string &Res, unsigned radix) const { ref<ConstantExpr> ConstantExpr::Concat(const ref<ConstantExpr> &RHS) { Expr::Width W = getWidth() + RHS->getWidth(); APInt Tmp(value); -#if LLVM_VERSION_CODE <= LLVM_VERSION(2, 8) - Tmp.zext(W); -#else Tmp=Tmp.zext(W); -#endif Tmp <<= RHS->getWidth(); Tmp |= APInt(RHS->value).zext(W); diff --git a/lib/Expr/Parser.cpp b/lib/Expr/Parser.cpp index 3871286e..5b3e96b7 100644 --- a/lib/Expr/Parser.cpp +++ b/lib/Expr/Parser.cpp @@ -1496,17 +1496,9 @@ ExprResult ParserImpl::ParseNumberToken(Expr::Width Type, const Token &Tok) { Val = -Val; if (Type < Val.getBitWidth()) -#if LLVM_VERSION_CODE <= LLVM_VERSION(2, 8) - Val.trunc(Type); -#else Val=Val.trunc(Type); -#endif else if (Type > Val.getBitWidth()) -#if LLVM_VERSION_CODE <= LLVM_VERSION(2, 8) - Val.zext(Type); -#else Val=Val.zext(Type); -#endif return ExprResult(Builder->Constant(Val)); } diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp index c6fc9d3a..79fd4afc 100644 --- a/lib/Module/Checks.cpp +++ b/lib/Module/Checks.cpp @@ -34,9 +34,7 @@ #include "llvm/Module.h" #include "llvm/Type.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" -#endif #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1) #include "llvm/Target/TargetData.h" diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp index 9d4053d4..301db1ff 100644 --- a/lib/Module/InstructionInfoTable.cpp +++ b/lib/Module/InstructionInfoTable.cpp @@ -22,18 +22,14 @@ #include "llvm/Module.h" #endif #include "llvm/Linker.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) -#include "llvm/Assembly/AsmAnnotationWriter.h" -#else #include "llvm/Assembly/AssemblyAnnotationWriter.h" #include "llvm/Support/FormattedStream.h" -#endif #include "llvm/Support/CFG.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2) #include "llvm/DebugInfo.h" -#elif LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) +#else #include "llvm/Analysis/DebugInfo.h" #endif #include "llvm/Analysis/ValueTracking.h" @@ -46,12 +42,8 @@ using namespace klee; class InstructionToLineAnnotator : public llvm::AssemblyAnnotationWriter { public: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - void emitInstructionAnnot(const Instruction *i, llvm::raw_ostream &os) { -#else void emitInstructionAnnot(const Instruction *i, llvm::formatted_raw_ostream &os) { -#endif os << "%%%"; os << (uintptr_t) i; } @@ -83,18 +75,9 @@ static void buildInstructionToLineMap(Module *m, } } -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) -static std::string getDSPIPath(const DbgStopPointInst *dspi) { - std::string dir, file; - bool res = GetConstantStringInfo(dspi->getDirectory(), dir); - assert(res && "GetConstantStringInfo failed"); - res = GetConstantStringInfo(dspi->getFileName(), file); - assert(res && "GetConstantStringInfo failed"); -#else static std::string getDSPIPath(DILocation Loc) { std::string dir = Loc.getDirectory(); std::string file = Loc.getFilename(); -#endif if (dir.empty() || file[0] == '/') { return file; } else if (*dir.rbegin() == '/') { @@ -107,20 +90,12 @@ static std::string getDSPIPath(DILocation Loc) { bool InstructionInfoTable::getInstructionDebugInfo(const llvm::Instruction *I, const std::string *&File, unsigned &Line) { -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - if (const DbgStopPointInst *dspi = dyn_cast<DbgStopPointInst>(I)) { - File = internString(getDSPIPath(dspi)); - Line = dspi->getLine(); - return true; - } -#else if (MDNode *N = I->getMetadata("dbg")) { DILocation Loc(N); File = internString(getDSPIPath(Loc)); Line = Loc.getLineNumber(); return true; } -#endif return false; } diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index 56d06d30..0f095269 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -30,9 +30,7 @@ #include "llvm/Instruction.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" -#endif #include "llvm/Module.h" #include "llvm/Type.h" #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 2) @@ -90,13 +88,8 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { // FIXME: This is much more target dependent than just the word size, // however this works for x86-32 and x86-64. case Intrinsic::vacopy: { // (dst, src) -> *((i8**) dst) = *((i8**) src) -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - Value *dst = ii->getOperand(1); - Value *src = ii->getOperand(2); -#else Value *dst = ii->getArgOperand(0); Value *src = ii->getArgOperand(1); -#endif if (WordSize == 4) { Type *i8pp = PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext()))); @@ -127,13 +120,8 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { case Intrinsic::umul_with_overflow: { IRBuilder<> builder(ii->getParent(), ii); -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - Value *op1 = ii->getOperand(1); - Value *op2 = ii->getOperand(2); -#else Value *op1 = ii->getArgOperand(0); Value *op2 = ii->getArgOperand(1); -#endif Value *result = 0; if (ii->getIntrinsicID() == Intrinsic::uadd_with_overflow) @@ -154,42 +142,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b, Module &M) { break; } -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - case Intrinsic::dbg_stoppoint: { - // We can remove this stoppoint if the next instruction is - // sure to be another stoppoint. This is nice for cleanliness - // but also important for switch statements where it can allow - // the targets to be joined. - bool erase = false; - if (isa<DbgStopPointInst>(i) || - isa<UnreachableInst>(i)) { - erase = true; - } else if (isa<BranchInst>(i) || - isa<SwitchInst>(i)) { - BasicBlock *bb = i->getParent(); - erase = true; - for (succ_iterator it=succ_begin(bb), ie=succ_end(bb); - it!=ie; ++it) { - if (!isa<DbgStopPointInst>(it->getFirstNonPHI())) { - erase = false; - break; - } - } - } - - if (erase) { - ii->eraseFromParent(); - dirty = true; - } - break; - } - - case Intrinsic::dbg_region_start: - case Intrinsic::dbg_region_end: - case Intrinsic::dbg_func_start: -#else case Intrinsic::dbg_value: -#endif case Intrinsic::dbg_declare: // Remove these regardless of lower intrinsics flag. This can // be removed once IntrinsicLowering is fixed to not have bad diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 7b23a9c9..d889b51f 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -30,9 +30,7 @@ #include "llvm/IR/DataLayout.h" #else #include "llvm/Instructions.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" -#endif #include "llvm/Module.h" #include "llvm/ValueSymbolTable.h" #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1) @@ -47,14 +45,8 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/Support/raw_os_ostream.h" -#endif -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Path.h" -#else #include "llvm/Support/Path.h" -#endif #include "llvm/Transforms/Scalar.h" #include <llvm/Transforms/Utils/Cloning.h> @@ -113,7 +105,6 @@ KModule::KModule(Module *_module) #else targetData(new DataLayout(module)), #endif - dbgStopPointFn(0), kleeMergeFn(0), infos(0), constantTable(0) { @@ -435,38 +426,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, std::ostream *os = ih->openOutputFile("assembly.ll"); assert(os && os->good() && "unable to open source output"); -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 6) - // We have an option for this in case the user wants a .ll they - // can compile. - if (NoTruncateSourceLines) { - os << *module; - } else { - bool truncated = false; - std::string string; - llvm::raw_string_ostream rss(string); - rss << *module; - rss.flush(); - const char *position = string.c_str(); - - for (;;) { - const char *end = index(position, '\n'); - if (!end) { - os << position; - break; - } else { - unsigned count = (end - position) + 1; - if (count<255) { - os->write(position, count); - } else { - os->write(position, 254); - os << "\n"; - truncated = true; - } - position = end+1; - } - } - } -#else llvm::raw_os_ostream *ros = new llvm::raw_os_ostream(*os); // We have an option for this in case the user wants a .ll they @@ -498,7 +457,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, } } delete ros; -#endif delete os; } @@ -511,7 +469,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, delete f; } - dbgStopPointFn = module->getFunction("llvm.dbg.stoppoint"); kleeMergeFn = module->getFunction("klee_merge"); /* Build shadow structures */ diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp index e1a5d5b2..a98b84ad 100644 --- a/lib/Module/LowerSwitch.cpp +++ b/lib/Module/LowerSwitch.cpp @@ -18,7 +18,7 @@ #include "klee/Config/Version.h" #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) #include "llvm/IR/LLVMContext.h" -#elif LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) +#else #include "llvm/LLVMContext.h" #endif #include <algorithm> diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 43eef0b7..fcdfa35a 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -27,21 +27,13 @@ #endif #include "llvm/Linker.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) -#include "llvm/Assembly/AsmAnnotationWriter.h" -#else #include "llvm/Assembly/AssemblyAnnotationWriter.h" -#endif #include "llvm/Support/CFG.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Analysis/ValueTracking.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Path.h" -#else #include "llvm/Support/Path.h" -#endif #include <map> #include <iostream> @@ -99,13 +91,8 @@ Function *klee::getDirectCallTarget(CallSite cs) { } static bool valueIsOnlyCalled(const Value *v) { -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - for (Value::use_const_iterator it = v->use_begin(), ie = v->use_end(); - it != ie; ++it) { -#else for (Value::const_use_iterator it = v->use_begin(), ie = v->use_end(); it != ie; ++it) { -#endif if (const Instruction *instr = dyn_cast<Instruction>(*it)) { if (instr->getOpcode()==0) continue; // XXX function numbering inst if (!isa<CallInst>(instr) && !isa<InvokeInst>(instr)) return false; diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index 83ee93ee..41a106f1 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -21,11 +21,7 @@ #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Support/CommandLine.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/DynamicLibrary.h" -#else #include "llvm/Support/DynamicLibrary.h" -#endif #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 3) #include "llvm/IR/Module.h" @@ -112,9 +108,6 @@ static void AddStandardCompilePasses(PassManager &PM) { if (DisableOptimizations) return; -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - addPass(PM, createRaiseAllocationsPass()); // call %malloc -> malloc inst -#endif addPass(PM, createCFGSimplificationPass()); // Clean up disgusting code addPass(PM, createPromoteMemoryToRegisterPass());// Kill useless allocas addPass(PM, createGlobalOptimizerPass()); // Optimize out global vars @@ -137,9 +130,6 @@ static void AddStandardCompilePasses(PassManager &PM) { addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs addPass(PM, createScalarReplAggregatesPass()); // Break up aggregate allocas addPass(PM, createInstructionCombiningPass()); // Combine silly seq's -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - addPass(PM, createCondPropagationPass()); // Propagate conditionals -#endif addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs @@ -147,9 +137,6 @@ static void AddStandardCompilePasses(PassManager &PM) { addPass(PM, createLoopRotatePass()); addPass(PM, createLICMPass()); // Hoist loop invariants addPass(PM, createLoopUnswitchPass()); // Unswitch loops. -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - addPass(PM, createLoopIndexSplitPass()); // Index split loops. -#endif // FIXME : Removing instcombine causes nestedloop regression. addPass(PM, createInstructionCombiningPass()); addPass(PM, createIndVarSimplifyPass()); // Canonicalize indvars @@ -163,9 +150,6 @@ static void AddStandardCompilePasses(PassManager &PM) { // Run instcombine after redundancy elimination to exploit opportunities // opened up by them. addPass(PM, createInstructionCombiningPass()); -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - addPass(PM, createCondPropagationPass()); // Propagate conditionals -#endif addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores addPass(PM, createAggressiveDCEPass()); // Delete dead instructions diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h index c6e09f0f..accb64d0 100644 --- a/lib/Module/Passes.h +++ b/lib/Module/Passes.h @@ -44,9 +44,7 @@ namespace klee { class RaiseAsmPass : public llvm::ModulePass { static char ID; -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9) const llvm::TargetLowering *TLI; -#endif llvm::Function *getIntrinsic(llvm::Module &M, unsigned IID, @@ -61,11 +59,7 @@ class RaiseAsmPass : public llvm::ModulePass { bool runOnInstruction(llvm::Module &M, llvm::Instruction *I); public: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - RaiseAsmPass() : llvm::ModulePass((intptr_t) &ID) {} -#else RaiseAsmPass() : llvm::ModulePass(ID), TLI(0) {} -#endif virtual bool runOnModule(llvm::Module &M); }; @@ -90,11 +84,7 @@ public: IntrinsicCleanerPass(const llvm::DataLayout &TD, #endif bool LI=true) -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - : llvm::ModulePass((intptr_t) &ID), -#else : llvm::ModulePass(ID), -#endif #if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1) TargetData(TD), #else @@ -123,11 +113,7 @@ class PhiCleanerPass : public llvm::FunctionPass { static char ID; public: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - PhiCleanerPass() : llvm::FunctionPass((intptr_t) &ID) {} -#else PhiCleanerPass() : llvm::FunctionPass(ID) {} -#endif virtual bool runOnFunction(llvm::Function &f); }; @@ -135,11 +121,7 @@ public: class DivCheckPass : public llvm::ModulePass { static char ID; public: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - DivCheckPass(): ModulePass((intptr_t) &ID) {} -#else DivCheckPass(): ModulePass(ID) {} -#endif virtual bool runOnModule(llvm::Module &M); }; @@ -160,11 +142,7 @@ public: class OvershiftCheckPass : public llvm::ModulePass { static char ID; public: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - OvershiftCheckPass(): ModulePass((intptr_t) &ID) {} -#else OvershiftCheckPass(): ModulePass(ID) {} -#endif virtual bool runOnModule(llvm::Module &M); }; @@ -174,11 +152,7 @@ public: class LowerSwitchPass : public llvm::FunctionPass { public: static char ID; // Pass identification, replacement for typeid -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - LowerSwitchPass() : FunctionPass((intptr_t) &ID) {} -#else LowerSwitchPass() : FunctionPass(ID) {} -#endif virtual bool runOnFunction(llvm::Function &F); diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index f15273e4..d9145a1e 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -14,12 +14,9 @@ #include "llvm/IR/LLVMContext.h" #else #include "llvm/InlineAsm.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" #endif -#endif -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9) #include "llvm/Support/raw_ostream.h" #include "llvm/Support/Host.h" #include "llvm/Target/TargetLowering.h" @@ -28,7 +25,6 @@ #else #include "llvm/Support/TargetRegistry.h" #endif -#endif using namespace llvm; using namespace klee; @@ -52,38 +48,8 @@ Function *RaiseAsmPass::getIntrinsic(llvm::Module &M, bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { if (CallInst *ci = dyn_cast<CallInst>(I)) { if (InlineAsm *ia = dyn_cast<InlineAsm>(ci->getCalledValue())) { -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9) (void) ia; return TLI && TLI->ExpandInlineAsm(ci); -#else - const std::string &as = ia->getAsmString(); - const std::string &cs = ia->getConstraintString(); - const llvm::Type *T = ci->getType(); - - // bswaps -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - unsigned NumOperands = ci->getNumOperands(); - llvm::Value *Arg0 = NumOperands > 1 ? ci->getOperand(1) : 0; -#else - unsigned NumOperands = ci->getNumArgOperands() + 1; - llvm::Value *Arg0 = NumOperands > 1 ? ci->getArgOperand(0) : 0; -#endif - if (Arg0 && T == Arg0->getType() && - ((T == llvm::Type::getInt16Ty(getGlobalContext()) && - as == "rorw $$8, ${0:w}" && - cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}") || - (T == llvm::Type::getInt32Ty(getGlobalContext()) && - as == "rorw $$8, ${0:w};rorl $$16, $0;rorw $$8, ${0:w}" && - cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}"))) { - Function *F = getIntrinsic(M, Intrinsic::bswap, Arg0->getType()); -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 8) - ci->setOperand(0, F); -#else - ci->setCalledFunction(F); -#endif - return true; - } -#endif } } @@ -93,7 +59,6 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) { bool RaiseAsmPass::runOnModule(Module &M) { bool changed = false; -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9) std::string Err; #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1) std::string HostTriple = llvm::sys::getDefaultTargetTriple(); @@ -115,7 +80,6 @@ bool RaiseAsmPass::runOnModule(Module &M) { #endif TLI = TM->getTargetLowering(); } -#endif for (Module::iterator fi = M.begin(), fe = M.end(); fi != fe; ++fi) { for (Function::iterator bi = fi->begin(), be = fi->end(); bi != be; ++bi) { diff --git a/lib/Support/Time.cpp b/lib/Support/Time.cpp index fb0e349c..909e07da 100644 --- a/lib/Support/Time.cpp +++ b/lib/Support/Time.cpp @@ -10,11 +10,7 @@ #include "klee/Config/Version.h" #include "klee/Internal/System/Time.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Process.h" -#else #include "llvm/Support/Process.h" -#endif using namespace llvm; using namespace klee; diff --git a/lib/Support/Timer.cpp b/lib/Support/Timer.cpp index 35922d4d..c61a90a3 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -10,11 +10,7 @@ #include "klee/Config/Version.h" #include "klee/Internal/Support/Timer.h" -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Process.h" -#else #include "llvm/Support/Process.h" -#endif using namespace klee; using namespace llvm; diff --git a/tools/kleaver/main.cpp b/tools/kleaver/main.cpp index f5bbfaf0..abc37d4b 100644 --- a/tools/kleaver/main.cpp +++ b/tools/kleaver/main.cpp @@ -34,12 +34,8 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Signals.h" -#else #include "llvm/Support/Signals.h" #include "llvm/Support/system_error.h" -#endif using namespace llvm; using namespace klee; @@ -459,20 +455,12 @@ int main(int argc, char **argv) { std::string ErrorStr; -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - MemoryBuffer *MB = MemoryBuffer::getFileOrSTDIN(InputFile.c_str(), &ErrorStr); - if (!MB) { - std::cerr << argv[0] << ": error: " << ErrorStr << "\n"; - return 1; - } -#else OwningPtr<MemoryBuffer> MB; error_code ec=MemoryBuffer::getFileOrSTDIN(InputFile.c_str(), MB); if (ec) { std::cerr << argv[0] << ": error: " << ec.message() << "\n"; return 1; } -#endif ExprBuilder *Builder = 0; switch (BuilderKind) { @@ -492,45 +480,24 @@ int main(int argc, char **argv) { switch (ToolAction) { case PrintTokens: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - PrintInputTokens(MB); -#else PrintInputTokens(MB.get()); -#endif break; case PrintAST: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - success = PrintInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), MB, - Builder); -#else success = PrintInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), MB.get(), Builder); -#endif break; case Evaluate: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - success = EvaluateInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), - MB, Builder); -#else success = EvaluateInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), MB.get(), Builder); -#endif break; case PrintSMTLIBv2: -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - success = printInputAsSMTLIBv2(InputFile=="-"? "<stdin>" : InputFile.c_str(), MB,Builder); -#else success = printInputAsSMTLIBv2(InputFile=="-"? "<stdin>" : InputFile.c_str(), MB.get(),Builder); -#endif break; default: std::cerr << argv[0] << ": error: Unknown program action!\n"; } delete Builder; -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - delete MB; -#endif llvm::llvm_shutdown(); return success ? 0 : 1; } diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index 0f5ce0c0..3616bfa6 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -28,14 +28,9 @@ #include "llvm/InstrTypes.h" #include "llvm/Instruction.h" #include "llvm/Instructions.h" -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 7) #include "llvm/LLVMContext.h" #include "llvm/Support/FileSystem.h" #endif -#endif -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) -#include "llvm/ModuleProvider.h" -#endif #include "llvm/Support/FileSystem.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/CommandLine.h" @@ -53,12 +48,8 @@ #else #include "llvm/Support/TargetSelect.h" #endif -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) -#include "llvm/System/Signals.h" -#else #include "llvm/Support/Signals.h" #include "llvm/Support/system_error.h" -#endif #include <dirent.h> #include <signal.h> @@ -571,11 +562,7 @@ void KleeHandler::getOutFiles(std::string path, } for (std::set<llvm::sys::Path>::iterator it = contents.begin(), ie = contents.end(); it != ie; ++it) { -#if LLVM_VERSION_CODE != LLVM_VERSION(2, 6) std::string f = it->str(); -#else - std::string f = it->toString(); -#endif if (f.substr(f.size()-6,f.size()) == ".ktest") { results.push_back(f); } @@ -750,7 +737,6 @@ static const char *modelledExternals[] = { "klee_warning_once", "klee_alias_function", "klee_stack_trace", - "llvm.dbg.stoppoint", #if LLVM_VERSION_CODE >= LLVM_VERSION(3, 1) "llvm.dbg.declare", "llvm.dbg.value", @@ -1216,28 +1202,7 @@ int main(int argc, char **argv, char **envp) { // Load the bytecode... std::string ErrorMsg; -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 7) - ModuleProvider *MP = 0; - if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorMsg)) { - MP = getBitcodeModuleProvider(Buffer, getGlobalContext(), &ErrorMsg); - if (!MP) delete Buffer; - } - - if (!MP) - klee_error("error loading program '%s': %s", InputFile.c_str(), ErrorMsg.c_str()); - - Module *mainModule = MP->materializeModule(); - MP->releaseModule(); - delete MP; -#else Module *mainModule = 0; -#if LLVM_VERSION_CODE < LLVM_VERSION(2, 9) - MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorMsg); - if (Buffer) { - mainModule = getLazyBitcodeModule(Buffer, getGlobalContext(), &ErrorMsg); - if (!mainModule) delete Buffer; - } -#else OwningPtr<MemoryBuffer> BufferPtr; error_code ec=MemoryBuffer::getFileOrSTDIN(InputFile.c_str(), BufferPtr); if (ec) { @@ -1246,7 +1211,6 @@ int main(int argc, char **argv, char **envp) { } mainModule = getLazyBitcodeModule(BufferPtr.get(), getGlobalContext(), &ErrorMsg); -#endif if (mainModule) { if (mainModule->MaterializeAllPermanently(&ErrorMsg)) { delete mainModule; @@ -1256,7 +1220,6 @@ int main(int argc, char **argv, char **envp) { if (!mainModule) klee_error("error loading program '%s': %s", InputFile.c_str(), ErrorMsg.c_str()); -#endif if (WithPOSIXRuntime) { int r = initEnv(mainModule); @@ -1540,9 +1503,7 @@ int main(int argc, char **argv, char **envp) { std::cerr << stats.str(); handler->getInfoStream() << stats.str(); -#if LLVM_VERSION_CODE >= LLVM_VERSION(2, 9) BufferPtr.take(); -#endif delete handler; return 0; |