diff options
-rw-r--r-- | include/klee/Internal/Module/KInstruction.h | 6 | ||||
-rw-r--r-- | include/klee/Statistic.h | 6 | ||||
-rw-r--r-- | include/klee/util/Bits.h | 6 | ||||
-rw-r--r-- | include/klee/util/GetElementPtrTypeIterator.h | 3 | ||||
-rw-r--r-- | lib/Core/Executor.cpp | 4 | ||||
-rw-r--r-- | lib/Core/ExternalDispatcher.cpp | 4 | ||||
-rw-r--r-- | lib/Core/StatsTracker.cpp | 8 | ||||
-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/KModule.cpp | 10 | ||||
-rw-r--r-- | lib/Module/ModuleUtil.cpp | 4 | ||||
-rw-r--r-- | lib/Module/Optimize.cpp | 5 | ||||
-rw-r--r-- | lib/Module/RaiseAsm.cpp | 2 | ||||
-rw-r--r-- | lib/Support/Time.cpp | 5 | ||||
-rw-r--r-- | lib/Support/Timer.cpp | 5 | ||||
-rw-r--r-- | tools/kleaver/main.cpp | 42 | ||||
-rw-r--r-- | tools/klee/main.cpp | 24 |
18 files changed, 134 insertions, 16 deletions
diff --git a/include/klee/Internal/Module/KInstruction.h b/include/klee/Internal/Module/KInstruction.h index b35cf107..f6becd4a 100644 --- a/include/klee/Internal/Module/KInstruction.h +++ b/include/klee/Internal/Module/KInstruction.h @@ -11,10 +11,10 @@ #define KLEE_KINSTRUCTION_H #include "klee/Config/config.h" -#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) -#include "llvm/Support/DataTypes.h" -#else +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/DataTypes.h" +#else +#include "llvm/Support/DataTypes.h" #endif #include <vector> diff --git a/include/klee/Statistic.h b/include/klee/Statistic.h index 7ade8dd0..6261fd95 100644 --- a/include/klee/Statistic.h +++ b/include/klee/Statistic.h @@ -11,10 +11,10 @@ #define KLEE_STATISTIC_H #include "klee/Config/config.h" -#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) -#include "llvm/Support/DataTypes.h" -#else +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/DataTypes.h" +#else +#include "llvm/Support/DataTypes.h" #endif #include <string> diff --git a/include/klee/util/Bits.h b/include/klee/util/Bits.h index db45acac..06703604 100644 --- a/include/klee/util/Bits.h +++ b/include/klee/util/Bits.h @@ -11,10 +11,10 @@ #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 +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/DataTypes.h" +#else +#include "llvm/Support/DataTypes.h" #endif namespace klee { diff --git a/include/klee/util/GetElementPtrTypeIterator.h b/include/klee/util/GetElementPtrTypeIterator.h index 690aaa95..c552595c 100644 --- a/include/klee/util/GetElementPtrTypeIterator.h +++ b/include/klee/util/GetElementPtrTypeIterator.h @@ -21,6 +21,9 @@ #include "llvm/User.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" +#if (LLVM_VERSION_MAJOR > 2) +#include "llvm/Constants.h" +#endif namespace klee { template<typename ItTy = llvm::User::const_op_iterator> diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp index 2baf61e9..aa0b43d2 100644 --- a/lib/Core/Executor.cpp +++ b/lib/Core/Executor.cpp @@ -58,7 +58,11 @@ #include "llvm/Support/CallSite.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/raw_ostream.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/Process.h" +#else +#include "llvm/Support/Process.h" +#endif #include "llvm/Target/TargetData.h" #include <cassert> diff --git a/lib/Core/ExternalDispatcher.cpp b/lib/Core/ExternalDispatcher.cpp index 665a0461..bc68ce0d 100644 --- a/lib/Core/ExternalDispatcher.cpp +++ b/lib/Core/ExternalDispatcher.cpp @@ -30,7 +30,11 @@ #include "llvm/ExecutionEngine/JIT.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "llvm/Support/CallSite.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/DynamicLibrary.h" +#else +#include "llvm/Support/DynamicLibrary.h" +#endif #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetSelect.h" #include <setjmp.h> diff --git a/lib/Core/StatsTracker.cpp b/lib/Core/StatsTracker.cpp index 8d2ec479..03d5e926 100644 --- a/lib/Core/StatsTracker.cpp +++ b/lib/Core/StatsTracker.cpp @@ -35,8 +35,16 @@ #include "llvm/Type.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/CFG.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/Process.h" +#else +#include "llvm/Support/Process.h" +#endif +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/Path.h" +#else +#include "llvm/Support/Path.h" +#endif #include <iostream> #include <fstream> diff --git a/lib/Core/TimingSolver.cpp b/lib/Core/TimingSolver.cpp index 542a3c8e..d0aa3f6a 100644 --- a/lib/Core/TimingSolver.cpp +++ b/lib/Core/TimingSolver.cpp @@ -15,7 +15,11 @@ #include "CoreStats.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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 71e64325..e02a7e49 100644 --- a/lib/Expr/Expr.cpp +++ b/lib/Expr/Expr.cpp @@ -336,7 +336,11 @@ void ConstantExpr::toString(std::string &Res) const { ref<ConstantExpr> ConstantExpr::Concat(const ref<ConstantExpr> &RHS) { Expr::Width W = getWidth() + RHS->getWidth(); APInt Tmp(value); +#if (LLVM_VERSION_MAJOR < 3) 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 caeeabd7..a41c5624 100644 --- a/lib/Expr/Parser.cpp +++ b/lib/Expr/Parser.cpp @@ -1496,9 +1496,17 @@ ExprResult ParserImpl::ParseNumberToken(Expr::Width Type, const Token &Tok) { Val = -Val; if (Type < Val.getBitWidth()) +#if (LLVM_VERSION_MAJOR < 3) Val.trunc(Type); +#else + Val=Val.trunc(Type); +#endif else if (Type > Val.getBitWidth()) +#if (LLVM_VERSION_MAJOR < 3) Val.zext(Type); +#else + Val=Val.zext(Type); +#endif return ExprResult(Builder->Constant(Val)); } diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp index 8842febb..0364127d 100644 --- a/lib/Module/KModule.cpp +++ b/lib/Module/KModule.cpp @@ -34,7 +34,11 @@ #if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 7) #include "llvm/Support/raw_os_ostream.h" #endif +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/Path.h" +#else +#include "llvm/Support/Path.h" +#endif #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Scalar.h" @@ -226,7 +230,11 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts, BasicBlock *exit = BasicBlock::Create(getGlobalContext(), "exit", f); PHINode *result = 0; if (f->getReturnType() != Type::getVoidTy(getGlobalContext())) - result = PHINode::Create(f->getReturnType(), "retval", exit); +#if (LLVM_VERSION_MAJOR > 2) + result = PHINode::Create(f->getReturnType(), 0, "retval", exit); +#else + result = PHINode::Create(f->getReturnType(), "retval", exit); +#endif CallInst::Create(mergeFn, "", exit); ReturnInst::Create(getGlobalContext(), result, exit); diff --git a/lib/Module/ModuleUtil.cpp b/lib/Module/ModuleUtil.cpp index 935dfa62..11f2b2c5 100644 --- a/lib/Module/ModuleUtil.cpp +++ b/lib/Module/ModuleUtil.cpp @@ -25,7 +25,11 @@ #include "llvm/Support/InstIterator.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Analysis/ValueTracking.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/Path.h" +#else +#include "llvm/Support/Path.h" +#endif #include <map> #include <iostream> diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp index 1eadec26..633c21a1 100644 --- a/lib/Module/Optimize.cpp +++ b/lib/Module/Optimize.cpp @@ -15,13 +15,18 @@ // //===----------------------------------------------------------------------===// +#include "klee/Config/config.h" #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Analysis/Passes.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Support/CommandLine.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/DynamicLibrary.h" +#else +#include "llvm/Support/DynamicLibrary.h" +#endif #include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Transforms/IPO.h" diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp index 11c89009..76a4f242 100644 --- a/lib/Module/RaiseAsm.cpp +++ b/lib/Module/RaiseAsm.cpp @@ -16,7 +16,7 @@ #endif #if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR >= 9) #include "llvm/Support/raw_ostream.h" -#include "llvm/System/Host.h" +#include "llvm/Support/Host.h" #include "llvm/Target/TargetLowering.h" #include "llvm/Target/TargetRegistry.h" #endif diff --git a/lib/Support/Time.cpp b/lib/Support/Time.cpp index 0ec8d9d7..ebcc390a 100644 --- a/lib/Support/Time.cpp +++ b/lib/Support/Time.cpp @@ -7,9 +7,14 @@ // //===----------------------------------------------------------------------===// +#include "klee/Config/config.h" #include "klee/Internal/System/Time.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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 cddb0707..c51815aa 100644 --- a/lib/Support/Timer.cpp +++ b/lib/Support/Timer.cpp @@ -7,9 +7,14 @@ // //===----------------------------------------------------------------------===// +#include "klee/Config/config.h" #include "klee/Internal/Support/Timer.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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 c489612f..0581ea27 100644 --- a/tools/kleaver/main.cpp +++ b/tools/kleaver/main.cpp @@ -17,7 +17,20 @@ #include "llvm/Support/ManagedStatic.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/raw_ostream.h" + +// FIXME: Ugh, this is gross. But otherwise our config.h conflicts with LLVMs. +#undef PACKAGE_BUGREPORT +#undef PACKAGE_NAME +#undef PACKAGE_STRING +#undef PACKAGE_TARNAME +#undef PACKAGE_VERSION + +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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; @@ -269,12 +282,22 @@ int main(int argc, char **argv) { llvm::cl::ParseCommandLineOptions(argc, argv); std::string ErrorStr; + +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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) { case DefaultBuilder: @@ -293,23 +316,38 @@ int main(int argc, char **argv) { switch (ToolAction) { case PrintTokens: +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) PrintInputTokens(MB); +#else + PrintInputTokens(MB.get()); +#endif break; case PrintAST: +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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_MAJOR == 2 && LLVM_VERSION_MINOR < 9) success = EvaluateInputAST(InputFile=="-" ? "<stdin>" : InputFile.c_str(), MB, Builder); +#else + success = EvaluateInputAST(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_MAJOR == 2 && LLVM_VERSION_MINOR < 9) delete MB; - +#endif llvm::llvm_shutdown(); return success ? 0 : 1; } diff --git a/tools/klee/main.cpp b/tools/klee/main.cpp index c3188259..e37eb00a 100644 --- a/tools/klee/main.cpp +++ b/tools/klee/main.cpp @@ -37,7 +37,12 @@ #undef PACKAGE_TARNAME #undef PACKAGE_VERSION #include "llvm/Target/TargetSelect.h" +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) #include "llvm/System/Signals.h" +#else +#include "llvm/Support/Signals.h" +#include "llvm/Support/system_error.h" +#endif #include <iostream> #include <fstream> #include <cerrno> @@ -1157,14 +1162,25 @@ int main(int argc, char **argv, char **envp) { Module *mainModule = MP->materializeModule(); MP->releaseModule(); delete MP; -#else +#endif std::string ErrorMsg; Module *mainModule = 0; +#if (LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 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) { + klee_error("error loading program '%s': %s", InputFile.c_str(), + ec.message().c_str()); + } + mainModule = getLazyBitcodeModule(BufferPtr.get(), getGlobalContext(), &ErrorMsg); + +#endif if (mainModule) { if (mainModule->MaterializeAllPermanently(&ErrorMsg)) { delete mainModule; @@ -1174,8 +1190,7 @@ 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) InitEnv = true; @@ -1449,6 +1464,9 @@ int main(int argc, char **argv, char **envp) { std::cerr << stats.str(); handler->getInfoStream() << stats.str(); +#if !(LLVM_VERSION_MAJOR == 2 && LLVM_VERSION_MINOR < 9) + BufferPtr.take(); +#endif delete handler; return 0; |