about summary refs log tree commit diff homepage
diff options
context:
space:
mode:
authorMicah Villmow <villmow@gmail.com>2012-10-08 16:50:13 +0000
committerMicah Villmow <villmow@gmail.com>2012-10-08 16:50:13 +0000
commit2c8039b3a2abf467c5eefa9fc8d1408766ab877d (patch)
tree3b04cb477da0d7de59eddc348a1a937e1c52fd04
parentcb7a4c6c52563589ef7c832bd4c87390b3a3a919 (diff)
downloadklee-2c8039b3a2abf467c5eefa9fc8d1408766ab877d.tar.gz
Make the changes in r165394 be conditional on post LLVM 3.1 changes.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@165405 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/klee/Internal/Module/KModule.h8
-rw-r--r--lib/Core/Executor.cpp14
-rw-r--r--lib/Core/Executor.h4
-rw-r--r--lib/Core/ExecutorUtil.cpp6
-rw-r--r--lib/Module/Checks.cpp6
-rw-r--r--lib/Module/IntrinsicCleaner.cpp10
-rw-r--r--lib/Module/KModule.cpp10
-rw-r--r--lib/Module/Optimize.cpp11
-rw-r--r--lib/Module/Passes.h18
9 files changed, 80 insertions, 7 deletions
diff --git a/include/klee/Internal/Module/KModule.h b/include/klee/Internal/Module/KModule.h
index 322e6898..538d8e6e 100644
--- a/include/klee/Internal/Module/KModule.h
+++ b/include/klee/Internal/Module/KModule.h
@@ -22,7 +22,11 @@ namespace llvm {
   class Function;
   class Instruction;
   class Module;
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+  class TargetData;
+#else
   class DataLayout;
+#endif
 }
 
 namespace klee {
@@ -80,7 +84,11 @@ namespace klee {
   class KModule {
   public:
     llvm::Module *module;
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+    llvm::TargetData *targetData;
+#else
     llvm::DataLayout *targetData;
+#endif
     
     // Some useful functions to know the address of
     llvm::Function *dbgStopPointFn, *kleeMergeFn;
diff --git a/lib/Core/Executor.cpp b/lib/Core/Executor.cpp
index cd66c0c3..8478ea67 100644
--- a/lib/Core/Executor.cpp
+++ b/lib/Core/Executor.cpp
@@ -64,7 +64,11 @@
 #else
 #include "llvm/Support/Process.h"
 #endif
-#include "llvm/Target/DataLayout.h"
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+#include "llvm/Target/TargetData.h"
+#else
+#include "llvm/DataLayout.h"
+#endif
 
 #include <cassert>
 #include <algorithm>
@@ -346,7 +350,11 @@ const Module *Executor::setModule(llvm::Module *module,
   kmodule = new KModule(module);
 
   // Initialize the context.
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+  TargetData *TD = kmodule->targetData;
+#else
   DataLayout *TD = kmodule->targetData;
+#endif
   Context::initialize(TD->isLittleEndian(),
                       (Expr::Width) TD->getPointerSizeInBits());
 
@@ -384,7 +392,11 @@ Executor::~Executor() {
 void Executor::initializeGlobalObject(ExecutionState &state, ObjectState *os,
                                       const Constant *c, 
                                       unsigned offset) {
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+  TargetData *targetData = kmodule->targetData;
+#else
   DataLayout *targetData = kmodule->targetData;
+#endif
   if (const ConstantVector *cp = dyn_cast<ConstantVector>(c)) {
     unsigned elementSize =
       targetData->getTypeStoreSize(cp->getType()->getElementType());
diff --git a/lib/Core/Executor.h b/lib/Core/Executor.h
index d47a3364..7e6b79cd 100644
--- a/lib/Core/Executor.h
+++ b/lib/Core/Executor.h
@@ -37,7 +37,11 @@ namespace llvm {
   class Function;
   class GlobalValue;
   class Instruction;
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+  class TargetData;
+#else
   class DataLayout;
+#endif
   class Twine;
   class Value;
 }
diff --git a/lib/Core/ExecutorUtil.cpp b/lib/Core/ExecutorUtil.cpp
index c42b0810..0d85afee 100644
--- a/lib/Core/ExecutorUtil.cpp
+++ b/lib/Core/ExecutorUtil.cpp
@@ -28,7 +28,11 @@
 #include "llvm/ModuleProvider.h"
 #endif
 #include "llvm/Support/CallSite.h"
-#include "llvm/Target/DataLayout.h"
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+#include "llvm/Target/TargetData.h"
+#else
+#include "llvm/DataLayout.h"
+#endif
 #include <iostream>
 #include <cassert>
 
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index 125e807a..18ef398a 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -26,7 +26,11 @@
 #include "llvm/Type.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Target/DataLayout.h"
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+#include "llvm/Target/TargetData.h"
+#else
+#include "llvm/DataLayout.h"
+#endif
 
 using namespace llvm;
 using namespace klee;
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 41dc5724..fd0db91d 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -26,7 +26,11 @@
 #include "llvm/Support/IRBuilder.h"
 #include "llvm/Transforms/Scalar.h"
 #include "llvm/Transforms/Utils/BasicBlockUtils.h"
-#include "llvm/Target/DataLayout.h"
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+#include "llvm/Target/TargetData.h"
+#else
+#include "llvm/DataLayout.h"
+#endif
 
 using namespace llvm;
 
@@ -45,7 +49,11 @@ bool IntrinsicCleanerPass::runOnModule(Module &M) {
 bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) { 
   bool dirty = false;
   
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+  unsigned WordSize = TargetData.getPointerSizeInBits() / 8;
+#else
   unsigned WordSize = DataLayout.getPointerSizeInBits() / 8;
+#endif
   for (BasicBlock::iterator i = b.begin(), ie = b.end(); i != ie;) {     
     IntrinsicInst *ii = dyn_cast<IntrinsicInst>(&*i);
     // increment now since LowerIntrinsic deletion makes iterator invalid.
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index eeaa10cf..ea86433e 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -40,7 +40,11 @@
 #else
 #include "llvm/Support/Path.h"
 #endif
-#include "llvm/Target/DataLayout.h"
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+#include "llvm/Target/TargetData.h"
+#else
+#include "llvm/DataLayout.h"
+#endif
 #include "llvm/Transforms/Scalar.h"
 
 #include <sstream>
@@ -90,7 +94,11 @@ namespace {
 
 KModule::KModule(Module *_module) 
   : module(_module),
+#if LLVM_VERSION_CODE <= LLVM_VERSION(3, 1)
+    targetData(new TargetData(module)),
+#else
     targetData(new DataLayout(module)),
+#endif
     dbgStopPointFn(0),
     kleeMergeFn(0),
     infos(0),
diff --git a/lib/Module/Optimize.cpp b/lib/Module/Optimize.cpp
index fc37c1a9..20922e9e 100644
--- a/lib/Module/Optimize.cpp
+++ b/lib/Module/Optimize.cpp
@@ -27,7 +27,11 @@
 #else
 #include "llvm/Support/DynamicLibrary.h"
 #endif
-#include "llvm/Target/DataLayout.h"
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
+#include "llvm/Target/TargetData.h"
+#else
+#include "llvm/DataLayout.h"
+#endif
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Transforms/IPO.h"
 #include "llvm/Transforms/Scalar.h"
@@ -178,8 +182,13 @@ void Optimize(Module* M) {
   if (VerifyEach)
     Passes.add(createVerifierPass());
 
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
+  // Add an appropriate TargetData instance for this module...
+  addPass(Passes, new TargetData(M));
+#else
   // Add an appropriate DataLayout instance for this module...
   addPass(Passes, new DataLayout(M));
+#endif
 
   // DWD - Run the opt standard pass list as well.
   AddStandardCompilePasses(Passes);
diff --git a/lib/Module/Passes.h b/lib/Module/Passes.h
index 721a61ea..84ab2b13 100644
--- a/lib/Module/Passes.h
+++ b/lib/Module/Passes.h
@@ -22,7 +22,11 @@ namespace llvm {
   class Function;
   class Instruction;
   class Module;
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
+  class TargetData;
+#else
   class DataLayout;
+#endif
   class TargetLowering;
   class Type;
 }
@@ -64,20 +68,32 @@ public:
   // variables (via intrinsic lowering).
 class IntrinsicCleanerPass : public llvm::ModulePass {
   static char ID;
-  const llvm::DataLayout &DataLayout;
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
+  const llvm::TargetData &DataLayout;
+#else
+  const llvm::DataLayout &DL;
+#endif
   llvm::IntrinsicLowering *IL;
   bool LowerIntrinsics;
 
   bool runOnBasicBlock(llvm::BasicBlock &b);
 public:
+#if LLVM_VERSION_CODE < LLVM_VERSION(3, 1)
+  IntrinsicCleanerPass(const llvm::TargetData &TD,
+#else
   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)
       DataLayout(TD),
+#else
+      DL(TD),
+#endif
       IL(new llvm::IntrinsicLowering(TD)),
       LowerIntrinsics(LI) {}
   ~IntrinsicCleanerPass() { delete IL; }