diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-14 05:08:59 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-14 05:08:59 +0000 |
commit | c70345caa213288aa748070f7a03c84fbdf89b5c (patch) | |
tree | 75252446281ec8c9c0a750461b8751fdd73566a8 | |
parent | 5099d8124393dcd577c2dd091834a17fe2d9fcdb (diff) | |
download | klee-c70345caa213288aa748070f7a03c84fbdf89b5c.tar.gz |
Update for 2.7.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@98467 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | Makefile.common | 7 | ||||
-rw-r--r-- | include/klee/Internal/Module/InstructionInfoTable.h | 2 | ||||
-rw-r--r-- | include/klee/Internal/Module/KInstruction.h | 5 | ||||
-rw-r--r-- | include/klee/Statistic.h | 5 | ||||
-rw-r--r-- | include/klee/util/Bits.h | 5 | ||||
-rw-r--r-- | lib/Core/Executor.cpp | 18 | ||||
-rw-r--r-- | lib/Core/ExecutorUtil.cpp | 2 | ||||
-rw-r--r-- | lib/Core/ExternalDispatcher.cpp | 26 | ||||
-rw-r--r-- | lib/Core/StatsTracker.cpp | 5 | ||||
-rw-r--r-- | lib/Module/Checks.cpp | 3 | ||||
-rw-r--r-- | lib/Module/InstructionInfoTable.cpp | 54 | ||||
-rw-r--r-- | lib/Module/IntrinsicCleaner.cpp | 5 | ||||
-rw-r--r-- | lib/Module/KModule.cpp | 7 | ||||
-rw-r--r-- | lib/Module/LowerSwitch.cpp | 3 | ||||
-rw-r--r-- | lib/Module/Optimize.cpp | 6 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 3 | ||||
-rw-r--r-- | test/Makefile | 6 | ||||
-rw-r--r-- | test/lib/llvm.exp | 6 | ||||
-rw-r--r-- | tools/klee/main.cpp | 32 |
19 files changed, 169 insertions, 31 deletions
diff --git a/Makefile.common b/Makefile.common index 5b093e6b..4cbe3302 100644 --- a/Makefile.common +++ b/Makefile.common @@ -20,7 +20,12 @@ endif include $(LLVM_SRC_ROOT)/Makefile.rules +# LLVMCC was added in 2.7. +ifeq ($(LLVMCC),) +LLVMCC := $(LLVMGCC) +LLVMCXX := $(LLVMGXX) +endif + LD.Flags += -L$(PROJ_SRC_ROOT)/stp/lib -CXX.Flags += -DLLVM_23 CXX.Flags += -I$(PROJ_SRC_ROOT)/stp/include CXX.Flags += -DKLEE_DIR=\"$(PROJ_SRC_ROOT)\" diff --git a/include/klee/Internal/Module/InstructionInfoTable.h b/include/klee/Internal/Module/InstructionInfoTable.h index c93f5ddb..98af6ac9 100644 --- a/include/klee/Internal/Module/InstructionInfoTable.h +++ b/include/klee/Internal/Module/InstructionInfoTable.h @@ -55,6 +55,8 @@ namespace klee { private: const std::string *internString(std::string s); + bool getInstructionDebugInfo(const llvm::Instruction *I, + const std::string *&File, unsigned &Line); public: InstructionInfoTable(llvm::Module *m); diff --git a/include/klee/Internal/Module/KInstruction.h b/include/klee/Internal/Module/KInstruction.h index 89b9dbfc..b35cf107 100644 --- a/include/klee/Internal/Module/KInstruction.h +++ b/include/klee/Internal/Module/KInstruction.h @@ -10,7 +10,12 @@ #ifndef KLEE_KINSTRUCTION_H #define KLEE_KINSTRUCTION_H +#include "klee/Config/config.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/Support/DataTypes.h" +#else +#include "llvm/System/DataTypes.h" +#endif #include <vector> namespace llvm { diff --git a/include/klee/Statistic.h b/include/klee/Statistic.h index 6baaedf4..7ade8dd0 100644 --- a/include/klee/Statistic.h +++ b/include/klee/Statistic.h @@ -10,7 +10,12 @@ #ifndef KLEE_STATISTIC_H #define KLEE_STATISTIC_H +#include "klee/Config/config.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/Support/DataTypes.h" +#else +#include "llvm/System/DataTypes.h" +#endif #include <string> namespace klee { diff --git a/include/klee/util/Bits.h b/include/klee/util/Bits.h index ffbda09e..db45acac 100644 --- a/include/klee/util/Bits.h +++ b/include/klee/util/Bits.h @@ -10,7 +10,12 @@ #ifndef KLEE_UTIL_BITS_H #define KLEE_UTIL_BITS_H +#include "klee/Config/config.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/Support/DataTypes.h" +#else +#include "llvm/System/DataTypes.h" +#endif namespace klee { namespace bits32 { diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 26c082af..ce80ea37 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -49,6 +49,9 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include "llvm/Module.h" #include "llvm/ADT/StringExtras.h" #include "llvm/Support/CallSite.h" @@ -1279,6 +1282,7 @@ Function* Executor::getCalledFunction(CallSite &cs, ExecutionState &state) { } static bool isDebugIntrinsic(const Function *f, KModule *KM) { +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) // Fast path, getIntrinsicID is slow. if (f == KM->dbgStopPointFn) return true; @@ -1294,6 +1298,9 @@ static bool isDebugIntrinsic(const Function *f, KModule *KM) { default: return false; } +#else + return false; +#endif } void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { @@ -1807,9 +1814,14 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { } // Memory instructions... - case Instruction::Alloca: - case Instruction::Malloc: { +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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); @@ -1822,10 +1834,12 @@ void Executor::executeInstruction(ExecutionState &state, KInstruction *ki) { executeAlloc(state, size, isLocal, ki); break; } +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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 32fee991..d2878878 100644 --- a/lib/Core/ExecutorUtil.cpp +++ b/lib/Core/ExecutorUtil.cpp @@ -21,7 +21,9 @@ #include "llvm/Function.h" #include "llvm/Instructions.h" #include "llvm/Module.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/ModuleProvider.h" +#endif #include "llvm/Support/CallSite.h" #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Target/TargetData.h" diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index 94dad33c..f746e6fa 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -8,12 +8,25 @@ //===----------------------------------------------------------------------===// #include "ExternalDispatcher.h" +#include "klee/Config/config.h" + +// Ugh. +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION #include "llvm/Module.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/ModuleProvider.h" +#endif +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Support/CallSite.h" @@ -68,10 +81,16 @@ void *ExternalDispatcher::resolveSymbol(const std::string &name) { ExternalDispatcher::ExternalDispatcher() { dispatchModule = new Module("ExternalDispatcher", getGlobalContext()); +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) ExistingModuleProvider* MP = new ExistingModuleProvider(dispatchModule); - +#endif + std::string error; +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) executionEngine = ExecutionEngine::createJIT(MP, &error); +#else + executionEngine = ExecutionEngine::createJIT(dispatchModule, &error); +#endif if (!executionEngine) { std::cerr << "unable to make jit: " << error << "\n"; abort(); @@ -229,7 +248,10 @@ Function *ExternalDispatcher::createDispatcher(Function *target, Instruction *in args[i] = new LoadInst(argp, "", dBB); } - Instruction *result = CallInst::Create(target, args, args+i, "", dBB); + Constant *dispatchTarget = + dispatchModule->getOrInsertFunction(target->getName(), FTy, + target->getAttributes()); + Instruction *result = CallInst::Create(dispatchTarget, args, args+i, "", dBB); if (result->getType() != Type::getVoidTy(getGlobalContext())) { Instruction *resp = new BitCastInst(argI64s, PointerType::getUnqual(result->getType()), diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index 3437e10c..d84db648 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -269,7 +269,12 @@ void StatsTracker::stepInstruction(ExecutionState &es) { if (!theStatisticManager->getIndexedValue(stats::coveredInstructions, ii.id)) { // Checking for actual stoppoints avoids inconsistencies due // to line number propogation. + // + // FIXME: This trick no longer works, we should fix this in the line + // number propogation. +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) if (isa<DbgStopPointInst>(inst)) +#endif es.coveredLines[&ii.file].insert(ii.line); es.coveredNew = true; es.instsSinceCovNew = 1; diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp index ee7029c7..2edcf940 100644 --- a/lib/Module/Checks.cpp +++ b/lib/Module/Checks.cpp @@ -16,6 +16,9 @@ #include "llvm/Instruction.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Type.h" diff --git a/lib/Module/InstructionInfoTable.cpp b/lib/Module/InstructionInfoTable.cpp index 196d9dc7..2efe981b 100644 --- a/lib/Module/InstructionInfoTable.cpp +++ b/lib/Module/InstructionInfoTable.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +#include "klee/Config/config.h" #include "klee/Internal/Module/InstructionInfoTable.h" #include "llvm/Function.h" @@ -18,6 +19,9 @@ #include "llvm/Support/CFG.h" #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/Analysis/DebugInfo.h" +#endif #include "llvm/Analysis/ValueTracking.h" #include <map> @@ -59,7 +63,8 @@ static void buildInstructionToLineMap(Module *m, } } -static std::string getDSPIPath(DbgStopPointInst *dspi) { +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +static std::string getDSPIPath(const DbgStopPointInst *dspi) { std::string dir, file; bool res = GetConstantStringInfo(dspi->getDirectory(), dir); assert(res && "GetConstantStringInfo failed"); @@ -73,6 +78,40 @@ static std::string getDSPIPath(DbgStopPointInst *dspi) { return dir + "/" + file; } } +#else +static std::string getDSPIPath(DILocation Loc) { + std::string dir = Loc.getDirectory(); + std::string file = Loc.getFilename(); + if (dir.empty()) { + return file; + } else if (*dir.rbegin() == '/') { + return dir + file; + } else { + return dir + "/" + file; + } +} +#endif + +bool InstructionInfoTable::getInstructionDebugInfo(const llvm::Instruction *I, + const std::string *&File, + unsigned &Line) { +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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; +} InstructionInfoTable::InstructionInfoTable(Module *m) : dummyString(""), dummyInfo(0, dummyString, 0, 0) { @@ -89,13 +128,9 @@ InstructionInfoTable::InstructionInfoTable(Module *m) // following the CFG, but it is not clear that it ever matters in // practice. for (inst_iterator it = inst_begin(fnIt), ie = inst_end(fnIt); - it != ie; ++it) { - if (DbgStopPointInst *dspi = dyn_cast<DbgStopPointInst>(&*it)) { - initialFile = internString(getDSPIPath(dspi)); - initialLine = dspi->getLine(); + it != ie; ++it) + if (getInstructionDebugInfo(&*it, initialFile, initialLine)) break; - } - } typedef std::map<BasicBlock*, std::pair<const std::string*,unsigned> > sourceinfo_ty; @@ -129,10 +164,7 @@ InstructionInfoTable::InstructionInfoTable(Module *m) lineTable.find(instr); if (ltit!=lineTable.end()) assemblyLine = ltit->second; - if (DbgStopPointInst *dspi = dyn_cast<DbgStopPointInst>(instr)) { - file = internString(getDSPIPath(dspi)); - line = dspi->getLine(); - } + getInstructionDebugInfo(instr, file, line); infos.insert(std::make_pair(instr, InstructionInfo(id++, *file, diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp index a73d8ca6..4d44f800 100644 --- a/lib/Module/IntrinsicCleaner.cpp +++ b/lib/Module/IntrinsicCleaner.cpp @@ -16,6 +16,9 @@ #include "llvm/Instruction.h" #include "llvm/Instructions.h" #include "llvm/IntrinsicInst.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include "llvm/Module.h" #include "llvm/Pass.h" #include "llvm/Type.h" @@ -85,6 +88,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) { break; } +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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 @@ -117,6 +121,7 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) { case Intrinsic::dbg_region_start: case Intrinsic::dbg_region_end: case Intrinsic::dbg_func_start: +#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 108adabd..76291cdc 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -22,12 +22,15 @@ #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Instructions.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/ValueSymbolTable.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" -#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR == 6) +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/Support/raw_os_ostream.h" #endif #include "llvm/System/Path.h" @@ -329,7 +332,7 @@ 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_MAJOR == 2 && LLVM_VERSION_MINOR == 6) +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 6) // We have an option for this in case the user wants a .ll they // can compile. if (NoTruncateSourceLines) { diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp index 381ebd29..7d6920be 100644 --- a/lib/Module/LowerSwitch.cpp +++ b/lib/Module/LowerSwitch.cpp @@ -15,6 +15,9 @@ //===----------------------------------------------------------------------===// #include "Passes.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include <algorithm> using namespace llvm; diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index 83e67292..affe9392 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -94,7 +94,9 @@ static void AddStandardCompilePasses(PassManager &PM) { if (DisableOptimizations) return; +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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 @@ -117,7 +119,9 @@ 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_MAJOR == 2 && LLVM_VERSION_MINOR < 7) addPass(PM, createCondPropagationPass()); // Propagate conditionals +#endif addPass(PM, createTailCallEliminationPass()); // Eliminate tail calls addPass(PM, createCFGSimplificationPass()); // Merge & remove BBs @@ -139,7 +143,9 @@ static void AddStandardCompilePasses(PassManager &PM) { // Run instcombine after redundancy elimination to exploit opportunities // opened up by them. addPass(PM, createInstructionCombiningPass()); +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) addPass(PM, createCondPropagationPass()); // Propagate conditionals +#endif addPass(PM, createDeadStoreEliminationPass()); // Delete dead stores addPass(PM, createAggressiveDCEPass()); // Delete dead instructions diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index b62338a6..42940fda 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -10,6 +10,9 @@ #include "Passes.h" #include "llvm/InlineAsm.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif using namespace llvm; using namespace klee; diff --git a/test/Makefile b/test/Makefile index 3cd461d7..01def0f1 100644 --- a/test/Makefile +++ b/test/Makefile @@ -89,10 +89,8 @@ site.exp: Makefile $(LEVEL)/Makefile.config @echo 'set compile_c "$(CC) $(CPP.Flags) $(C.Flags) $(CompileCommonOpts) -c "' >>site.tmp @echo 'set compile_cxx "$(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) - c"' >> site.tmp @echo 'set link "$(CXX) $(CPP.Flags) $(CXX.Flags) $(CompileCommonOpts) $(LD.Flags)"' >>site.tmp - @echo 'set llvmgcc "$(LLVMGCC)"' >> site.tmp - @echo 'set llvmgxx "$(LLVMGCC)"' >> site.tmp - @echo 'set llvmgccmajvers "$(LLVMGCC_MAJVERS)"' >> site.tmp - @echo 'set shlibext "$(SHLIBEXT)"' >> site.tmp + @echo 'set llvmgcc "$(LLVMCC)"' >> site.tmp + @echo 'set llvmgxx "$(LLVMCXX)"' >> site.tmp @echo '## All variables above are generated by configure. Do Not Edit ## ' >>site.tmp @test ! -f site.exp || \ sed '1,/^## All variables above are.*##/ d' site.exp >> site.tmp diff --git a/test/lib/llvm.exp b/test/lib/llvm.exp index 2857dd82..158cc54c 100644 --- a/test/lib/llvm.exp +++ b/test/lib/llvm.exp @@ -43,8 +43,8 @@ proc execOneLine { test PRS outcome lineno line } { # cases. proc substitute { line test tmpFile } { global srcroot objroot srcdir objdir subdir target_triplet prcontext - global llvmgcc llvmgxx llvmgcc_version llvmgccmajvers - global gccpath gxxpath compile_c compile_cxx link shlibext llvmlibsdir + global llvmgcc llvmgxx llvmgcc_version + global gccpath gxxpath compile_c compile_cxx link llvmlibsdir global llvmtoolsdir set path [file join $srcdir $subdir] @@ -63,8 +63,6 @@ proc substitute { line test tmpFile } { regsub -all {%compile_cxx} $new_line "$compile_cxx" new_line #replace %link with C++ link command regsub -all {%link} $new_line "$link" new_line - #replace %shlibext with shared library extension - regsub -all {%shlibext} $new_line "$shlibext" new_line #replace %llvmlibsdir with configure library directory regsub -all {%llvmlibsdir} $new_line "$llvmlibsdir" new_line #replace %klee with klee binary diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index b0b44bb8..08c33cae 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -15,11 +15,16 @@ #include "llvm/Constants.h" #include "llvm/Module.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/ModuleProvider.h" +#endif #include "llvm/Type.h" #include "llvm/InstrTypes.h" #include "llvm/Instruction.h" #include "llvm/Instructions.h" +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) +#include "llvm/LLVMContext.h" +#endif #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/ManagedStatic.h" @@ -516,10 +521,10 @@ 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_MAJOR == 2 && LLVM_VERSION_MINOR == 6) - std::string f = it->toString(); -#else +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR == 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); @@ -1137,6 +1142,7 @@ int main(int argc, char **argv, char **envp) { sys::SetInterruptFunction(interrupt_handle); // Load the bytecode... +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) std::string ErrorMsg; ModuleProvider *MP = 0; if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorMsg)) { @@ -1150,8 +1156,24 @@ int main(int argc, char **argv, char **envp) { Module *mainModule = MP->materializeModule(); MP->releaseModule(); delete MP; - - assert(mainModule && "unable to materialize"); +#else + std::string ErrorMsg; + Module *mainModule = 0; + MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile, &ErrorMsg); + if (Buffer) { + mainModule = getLazyBitcodeModule(Buffer, getGlobalContext(), &ErrorMsg); + if (!mainModule) delete Buffer; + } + if (mainModule) { + if (mainModule->MaterializeAllPermanently(&ErrorMsg)) { + delete mainModule; + mainModule = 0; + } + } + if (!mainModule) + klee_error("error loading program '%s': %s", InputFile.c_str(), + ErrorMsg.c_str()); +#endif if (WithPOSIXRuntime) InitEnv = true; |