about summary refs log tree commit diff homepage
path: root/lib/Core
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2010-03-14 05:08:59 +0000
committerDaniel Dunbar <daniel@zuster.org>2010-03-14 05:08:59 +0000
commitc70345caa213288aa748070f7a03c84fbdf89b5c (patch)
tree75252446281ec8c9c0a750461b8751fdd73566a8 /lib/Core
parent5099d8124393dcd577c2dd091834a17fe2d9fcdb (diff)
downloadklee-c70345caa213288aa748070f7a03c84fbdf89b5c.tar.gz
Update for 2.7.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@98467 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Core')
-rw-r--r--lib/Core/Executor.cpp18
-rw-r--r--lib/Core/ExecutorUtil.cpp2
-rw-r--r--lib/Core/ExternalDispatcher.cpp26
-rw-r--r--lib/Core/StatsTracker.cpp5
4 files changed, 47 insertions, 4 deletions
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;