about summary refs log tree commit diff homepage
path: root/lib/Module
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-08-17 00:54:57 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-08-17 00:54:57 +0000
commit36c9fe87bb38d20850ca50d60facd019af54aa30 (patch)
tree6c26f044da7a248b497fd9e362f1344b87189844 /lib/Module
parent1d539296be5701036e8c48dac75add46eaf03a3f (diff)
downloadklee-36c9fe87bb38d20850ca50d60facd019af54aa30.tar.gz
Update for LLVM API change.
git-svn-id: https://llvm.org/svn/llvm-project/klee/trunk@79217 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Module')
-rw-r--r--lib/Module/Checks.cpp7
-rw-r--r--lib/Module/IntrinsicCleaner.cpp6
-rw-r--r--lib/Module/KModule.cpp40
-rw-r--r--lib/Module/LowerSwitch.cpp4
-rw-r--r--lib/Module/RaiseAsm.cpp4
5 files changed, 32 insertions, 29 deletions
diff --git a/lib/Module/Checks.cpp b/lib/Module/Checks.cpp
index ca4eeb44..ee7029c7 100644
--- a/lib/Module/Checks.cpp
+++ b/lib/Module/Checks.cpp
@@ -44,7 +44,7 @@ bool DivCheckPass::runOnModule(Module &M) {
             
             CastInst *denominator =
               CastInst::CreateIntegerCast(i->getOperand(1),
-                                          (Type*)Type::Int64Ty,
+                                          Type::getInt64Ty(getGlobalContext()),
                                           false,  /* sign doesn't matter */
                                           "int_cast_to_i64",
                                           i);
@@ -52,8 +52,9 @@ bool DivCheckPass::runOnModule(Module &M) {
             // Lazily bind the function to avoid always importing it.
             if (!divZeroCheckFunction) {
               Constant *fc = M.getOrInsertFunction("klee_div_zero_check", 
-                                                   Type::VoidTy, 
-                                                   Type::Int64Ty, NULL);
+                                                   Type::getVoidTy(getGlobalContext()), 
+                                                   Type::getInt64Ty(getGlobalContext()), 
+                                                   NULL);
               divZeroCheckFunction = cast<Function>(fc);
             }
 
diff --git a/lib/Module/IntrinsicCleaner.cpp b/lib/Module/IntrinsicCleaner.cpp
index 4f490e8e..a73d8ca6 100644
--- a/lib/Module/IntrinsicCleaner.cpp
+++ b/lib/Module/IntrinsicCleaner.cpp
@@ -61,18 +61,18 @@ bool IntrinsicCleanerPass::runOnBasicBlock(BasicBlock &b) {
         Value *src = ii->getOperand(2);
 
         if (WordSize == 4) {
-          Type *i8pp = PointerType::getUnqual(PointerType::getUnqual(Type::Int8Ty));
+          Type *i8pp = PointerType::getUnqual(PointerType::getUnqual(Type::getInt8Ty(getGlobalContext())));
           Value *castedDst = CastInst::CreatePointerCast(dst, i8pp, "vacopy.cast.dst", ii);
           Value *castedSrc = CastInst::CreatePointerCast(src, i8pp, "vacopy.cast.src", ii);
           Value *load = new LoadInst(castedSrc, "vacopy.read", ii);
           new StoreInst(load, castedDst, false, ii);
         } else {
           assert(WordSize == 8 && "Invalid word size!");
-          Type *i64p = PointerType::getUnqual(Type::Int64Ty);
+          Type *i64p = PointerType::getUnqual(Type::getInt64Ty(getGlobalContext()));
           Value *pDst = CastInst::CreatePointerCast(dst, i64p, "vacopy.cast.dst", ii);
           Value *pSrc = CastInst::CreatePointerCast(src, i64p, "vacopy.cast.src", ii);
           Value *val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
-          Value *off = ConstantInt::get(Type::Int64Ty, 1);
+          Value *off = ConstantInt::get(Type::getInt64Ty(getGlobalContext()), 1);
           pDst = GetElementPtrInst::Create(pDst, off, std::string(), ii);
           pSrc = GetElementPtrInst::Create(pSrc, off, std::string(), ii);
           val = new LoadInst(pSrc, std::string(), ii); new StoreInst(val, pDst, ii);
diff --git a/lib/Module/KModule.cpp b/lib/Module/KModule.cpp
index 78ecf4d1..37e869c8 100644
--- a/lib/Module/KModule.cpp
+++ b/lib/Module/KModule.cpp
@@ -112,12 +112,12 @@ static Function *getStubFunctionForCtorList(Module *m,
   
   std::vector<const Type*> nullary;
 
-  Function *fn = Function::Create(FunctionType::get(Type::VoidTy, 
+  Function *fn = Function::Create(FunctionType::get(Type::getVoidTy(getGlobalContext()), 
 						    nullary, false),
 				  GlobalVariable::InternalLinkage, 
 				  name,
                               m);
-  BasicBlock *bb = BasicBlock::Create("entry", fn);
+  BasicBlock *bb = BasicBlock::Create(getGlobalContext(), "entry", fn);
   
   // From lli:
   // Should be an array of '{ int, void ()* }' structs.  The first value is
@@ -142,7 +142,7 @@ static Function *getStubFunctionForCtorList(Module *m,
     }
   }
   
-  ReturnInst::Create(bb);
+  ReturnInst::Create(getGlobalContext(), bb);
 
   return fn;
 }
@@ -197,7 +197,8 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
     Function *mergeFn = module->getFunction("klee_merge");
     if (!mergeFn) {
       const llvm::FunctionType *Ty = 
-        FunctionType::get(Type::VoidTy, std::vector<const Type*>(), false);
+        FunctionType::get(Type::getVoidTy(getGlobalContext()), 
+                          std::vector<const Type*>(), false);
       mergeFn = Function::Create(Ty, GlobalVariable::ExternalLinkage,
 				 "klee_merge",
 				 module);
@@ -215,12 +216,12 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
                    name.c_str());
       }
 
-      BasicBlock *exit = BasicBlock::Create("exit", f);
+      BasicBlock *exit = BasicBlock::Create(getGlobalContext(), "exit", f);
       PHINode *result = 0;
-      if (f->getReturnType() != Type::VoidTy)
+      if (f->getReturnType() != Type::getVoidTy(getGlobalContext()))
         result = PHINode::Create(f->getReturnType(), "retval", exit);
       CallInst::Create(mergeFn, "", exit);
-      ReturnInst::Create(result, exit);
+      ReturnInst::Create(getGlobalContext(), result, exit);
 
       llvm::errs() << "KLEE: adding klee_merge at exit of: " << name << "\n";
       for (llvm::Function::iterator bbit = f->begin(), bbie = f->end(); 
@@ -263,18 +264,19 @@ void KModule::prepare(const Interpreter::ModuleOptions &opts,
   // by name. We only add them if such a function doesn't exist to
   // avoid creating stale uses.
 
-  forceImport(module, "memcpy", PointerType::getUnqual(Type::Int8Ty),
-              PointerType::getUnqual(Type::Int8Ty),
-              PointerType::getUnqual(Type::Int8Ty),
-              targetData->getIntPtrType(), (Type*) 0);
-  forceImport(module, "memmove", PointerType::getUnqual(Type::Int8Ty),
-              PointerType::getUnqual(Type::Int8Ty),
-              PointerType::getUnqual(Type::Int8Ty),
-              targetData->getIntPtrType(), (Type*) 0);
-  forceImport(module, "memset", PointerType::getUnqual(Type::Int8Ty),
-              PointerType::getUnqual(Type::Int8Ty),
-              Type::Int32Ty,
-              targetData->getIntPtrType(), (Type*) 0);
+  const llvm::Type *i8Ty = Type::getInt8Ty(getGlobalContext());
+  forceImport(module, "memcpy", PointerType::getUnqual(i8Ty),
+              PointerType::getUnqual(i8Ty),
+              PointerType::getUnqual(i8Ty),
+              targetData->getIntPtrType(getGlobalContext()), (Type*) 0);
+  forceImport(module, "memmove", PointerType::getUnqual(i8Ty),
+              PointerType::getUnqual(i8Ty),
+              PointerType::getUnqual(i8Ty),
+              targetData->getIntPtrType(getGlobalContext()), (Type*) 0);
+  forceImport(module, "memset", PointerType::getUnqual(i8Ty),
+              PointerType::getUnqual(i8Ty),
+              Type::getInt32Ty(getGlobalContext()),
+              targetData->getIntPtrType(getGlobalContext()), (Type*) 0);
 
   // FIXME: Missing force import for various math functions.
 
diff --git a/lib/Module/LowerSwitch.cpp b/lib/Module/LowerSwitch.cpp
index a2033eae..381ebd29 100644
--- a/lib/Module/LowerSwitch.cpp
+++ b/lib/Module/LowerSwitch.cpp
@@ -60,7 +60,7 @@ void LowerSwitchPass::switchConvert(CaseItr begin, CaseItr end,
   
   // iterate through all the cases, creating a new BasicBlock for each
   for (CaseItr it = begin; it < end; ++it) {
-    BasicBlock *newBlock = BasicBlock::Create("NodeBlock");
+    BasicBlock *newBlock = BasicBlock::Create(getGlobalContext(), "NodeBlock");
     Function::iterator FI = origBlock;
     F->getBasicBlockList().insert(++FI, newBlock);
     
@@ -96,7 +96,7 @@ void LowerSwitchPass::processSwitchInst(SwitchInst *SI) {
 
   // Create a new, empty default block so that the new hierarchy of
   // if-then statements go to this and the PHI nodes are happy.
-  BasicBlock* newDefault = BasicBlock::Create("newDefault");
+  BasicBlock* newDefault = BasicBlock::Create(getGlobalContext(), "newDefault");
 
   F->getBasicBlockList().insert(defaultBlock, newDefault);
   BranchInst::Create(defaultBlock, newDefault);
diff --git a/lib/Module/RaiseAsm.cpp b/lib/Module/RaiseAsm.cpp
index 67fbf8ae..b62338a6 100644
--- a/lib/Module/RaiseAsm.cpp
+++ b/lib/Module/RaiseAsm.cpp
@@ -35,10 +35,10 @@ bool RaiseAsmPass::runOnInstruction(Module &M, Instruction *I) {
       // bswaps
       if (ci->getNumOperands() == 2 && 
           T == ci->getOperand(1)->getType() &&
-          ((T == llvm::Type::Int16Ty && 
+          ((T == llvm::Type::getInt16Ty(getGlobalContext()) && 
             as == "rorw $$8, ${0:w}" &&
             cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}") ||
-           (T == llvm::Type::Int32Ty &&
+           (T == llvm::Type::getInt32Ty(getGlobalContext()) &&
             as == "rorw $$8, ${0:w};rorl $$16, $0;rorw $$8, ${0:w}" &&
             cs == "=r,0,~{dirflag},~{fpsr},~{flags},~{cc}"))) {
         llvm::Value *Arg0 = ci->getOperand(1);