diff options
author | Martin Nowack <martin@se.inf.tu-dresden.de> | 2013-12-05 21:48:38 +0100 |
---|---|---|
committer | Martin Nowack <martin@se.inf.tu-dresden.de> | 2013-12-06 11:46:16 +0100 |
commit | bf6df4192e9404432ff8c787475b352d475ceb85 (patch) | |
tree | 0cec3037b3e34f07e07b9f01e36199cca855823d /lib/Module | |
parent | 6d19d31eed55e18709c95363beafe8f679d6070c (diff) | |
download | klee-bf6df4192e9404432ff8c787475b352d475ceb85.tar.gz |
Deprecate LLVM 2.8 and lower
Diffstat (limited to 'lib/Module')
-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 | 41 | ||||
-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 |
9 files changed, 2 insertions, 208 deletions
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..49e6cb50 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> @@ -435,38 +427,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 +458,6 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, } } delete ros; -#endif delete os; } 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) { |