[llvm-commits] [llvm] r75025 - in /llvm/trunk: examples/BrainF/ include/llvm/ include/llvm/Support/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Linker/ lib/Transforms/IPO/ lib/Transforms/Instrumentation/ lib/Transforms/Scalar/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/

Owen Anderson resistor at mac.com
Wed Jul 8 12:04:44 PDT 2009


Author: resistor
Date: Wed Jul  8 14:03:57 2009
New Revision: 75025

URL: http://llvm.org/viewvc/llvm-project?rev=75025&view=rev
Log:
Switch GlobalVariable ctors to a sane API, where *either* a context or a module is required.

Modified:
    llvm/trunk/examples/BrainF/BrainF.cpp
    llvm/trunk/include/llvm/GlobalVariable.h
    llvm/trunk/include/llvm/Support/IRBuilder.h
    llvm/trunk/lib/Analysis/DebugInfo.cpp
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
    llvm/trunk/lib/Linker/LinkModules.cpp
    llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp
    llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp
    llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
    llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
    llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
    llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/Globals.cpp
    llvm/trunk/lib/VMCore/Module.cpp
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp
    llvm/trunk/tools/bugpoint/Miscompilation.cpp

Modified: llvm/trunk/examples/BrainF/BrainF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/BrainF/BrainF.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/examples/BrainF/BrainF.cpp (original)
+++ llvm/trunk/examples/BrainF/BrainF.cpp Wed Jul  8 14:03:57 2009
@@ -128,13 +128,12 @@
       get("Error: The head has left the tape.", true);
 
     GlobalVariable *aberrormsg = new GlobalVariable(
-      module->getContext(),
+      *module,
       msg_0->getType(),
       true,
       GlobalValue::InternalLinkage,
       msg_0,
-      "aberrormsg",
-      module);
+      "aberrormsg");
 
     //declare i32 @puts(i8 *)
     Function *puts_func = cast<Function>(module->

Modified: llvm/trunk/include/llvm/GlobalVariable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalVariable.h?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/include/llvm/GlobalVariable.h (original)
+++ llvm/trunk/include/llvm/GlobalVariable.h Wed Jul  8 14:03:57 2009
@@ -26,9 +26,9 @@
 
 namespace llvm {
 
-class LLVMContext;
 class Module;
 class Constant;
+class LLVMContext;
 template<typename ValueSubClass, typename ItemParentClass>
   class SymbolTableListTraits;
 
@@ -50,17 +50,16 @@
   }
   /// GlobalVariable ctor - If a parent module is specified, the global is
   /// automatically inserted into the end of the specified modules global list.
-  GlobalVariable(LLVMContext &Context, const Type *Ty,
-                 bool isConstant, LinkageTypes Linkage,
+  GlobalVariable(LLVMContext &Context, const Type *Ty, bool isConstant,
+                 LinkageTypes Linkage,
                  Constant *Initializer = 0, const std::string &Name = "",
-                 Module *Parent = 0, bool ThreadLocal = false,
-                 unsigned AddressSpace = 0);
+                 bool ThreadLocal = false, unsigned AddressSpace = 0);
   /// GlobalVariable ctor - This creates a global and inserts it before the
   /// specified other global.
-  GlobalVariable(LLVMContext &Context, const Type *Ty,
-                 bool isConstant, LinkageTypes Linkage,
-                 Constant *Initializer, const std::string &Name,
-                 GlobalVariable *InsertBefore, bool ThreadLocal = false,
+  GlobalVariable(Module &M, const Type *Ty, bool isConstant,
+                 LinkageTypes Linkage, Constant *Initializer,
+                 const std::string &Name,
+                 GlobalVariable *InsertBefore = 0, bool ThreadLocal = false,
                  unsigned AddressSpace = 0);
 
   ~GlobalVariable() {

Modified: llvm/trunk/include/llvm/Support/IRBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/IRBuilder.h?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/IRBuilder.h (original)
+++ llvm/trunk/include/llvm/Support/IRBuilder.h Wed Jul  8 14:03:57 2009
@@ -20,7 +20,6 @@
 #include "llvm/GlobalAlias.h"
 #include "llvm/GlobalVariable.h"
 #include "llvm/Function.h"
-#include "llvm/LLVMContext.h"
 #include "llvm/Support/ConstantFolder.h"
 
 namespace llvm {
@@ -43,16 +42,12 @@
   BasicBlock *BB;
   BasicBlock::iterator InsertPt;
   T Folder;
-  LLVMContext& Context;
 public:
-  IRBuilder(const T& F = T(), LLVMContext &C = getGlobalContext()) :
-    Folder(F), Context(C) { ClearInsertionPoint(); }
-  explicit IRBuilder(BasicBlock *TheBB, const T& F = T(),
-                     LLVMContext &C = getGlobalContext()) :
-    Folder(F), Context(C) { SetInsertPoint(TheBB); }
-  IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T(),
-            LLVMContext &C = getGlobalContext())
-    : Folder(F), Context(C) { SetInsertPoint(TheBB, IP); }
+  IRBuilder(const T& F = T()) : Folder(F) { ClearInsertionPoint(); }
+  explicit IRBuilder(BasicBlock *TheBB, const T& F = T())
+    : Folder(F) { SetInsertPoint(TheBB); }
+  IRBuilder(BasicBlock *TheBB, BasicBlock::iterator IP, const T& F = T())
+    : Folder(F) { SetInsertPoint(TheBB, IP); }
 
   /// getFolder - Get the constant folder being used.
   const T& getFolder() { return Folder; }
@@ -130,7 +125,7 @@
   ///
   ReturnInst *CreateAggregateRet(Value * const* retVals, unsigned N) {
     const Type *RetType = BB->getParent()->getReturnType();
-    Value *V = Context.getUndef(RetType);
+    Value *V = UndefValue::get(RetType);
     for (unsigned i = 0; i != N; ++i)
       V = CreateInsertValue(V, retVals[i], i, "mrv");
     return Insert(ReturnInst::Create(V));
@@ -354,7 +349,7 @@
     return Insert(GetElementPtrInst::Create(Ptr, Idx), Name);
   }
   Value *CreateConstGEP1_32(Value *Ptr, unsigned Idx0, const char *Name = "") {
-    Value *Idx = Context.getConstantInt(Type::Int32Ty, Idx0);
+    Value *Idx = ConstantInt::get(Type::Int32Ty, Idx0);
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
       return Folder.CreateGetElementPtr(PC, &Idx, 1);
@@ -364,8 +359,8 @@
   Value *CreateConstGEP2_32(Value *Ptr, unsigned Idx0, unsigned Idx1, 
                     const char *Name = "") {
     Value *Idxs[] = {
-      Context.getConstantInt(Type::Int32Ty, Idx0),
-      Context.getConstantInt(Type::Int32Ty, Idx1)
+      ConstantInt::get(Type::Int32Ty, Idx0),
+      ConstantInt::get(Type::Int32Ty, Idx1)
     };
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
@@ -374,7 +369,7 @@
     return Insert(GetElementPtrInst::Create(Ptr, Idxs, Idxs+2), Name);    
   }
   Value *CreateConstGEP1_64(Value *Ptr, uint64_t Idx0, const char *Name = "") {
-    Value *Idx = Context.getConstantInt(Type::Int64Ty, Idx0);
+    Value *Idx = ConstantInt::get(Type::Int64Ty, Idx0);
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
       return Folder.CreateGetElementPtr(PC, &Idx, 1);
@@ -384,8 +379,8 @@
   Value *CreateConstGEP2_64(Value *Ptr, uint64_t Idx0, uint64_t Idx1, 
                     const char *Name = "") {
     Value *Idxs[] = {
-      Context.getConstantInt(Type::Int64Ty, Idx0),
-      Context.getConstantInt(Type::Int64Ty, Idx1)
+      ConstantInt::get(Type::Int64Ty, Idx0),
+      ConstantInt::get(Type::Int64Ty, Idx1)
     };
 
     if (Constant *PC = dyn_cast<Constant>(Ptr))
@@ -397,21 +392,21 @@
     return CreateConstGEP2_32(Ptr, 0, Idx, Name);
   }
   Value *CreateGlobalString(const char *Str = "", const char *Name = "") {
-    Constant *StrConstant = Context.getConstantArray(Str, true);
-    GlobalVariable *gv = new GlobalVariable(Context,
+    Constant *StrConstant = ConstantArray::get(Str, true);
+    GlobalVariable *gv = new GlobalVariable(*BB->getParent()->getParent(),
                                             StrConstant->getType(),
                                             true,
                                             GlobalValue::InternalLinkage,
                                             StrConstant,
                                             "",
-                                            BB->getParent()->getParent(),
+                                            0,
                                             false);
     gv->setName(Name);
     return gv;
   }
   Value *CreateGlobalStringPtr(const char *Str = "", const char *Name = "") {
     Value *gv = CreateGlobalString(Str, Name);
-    Value *zero = Context.getConstantInt(Type::Int32Ty, 0);
+    Value *zero = ConstantInt::get(Type::Int32Ty, 0);
     Value *Args[] = { zero, zero };
     return CreateGEP(gv, Args, Args+2, Name);
   }
@@ -688,13 +683,13 @@
 
   /// CreateIsNull - Return an i1 value testing if \arg Arg is null.
   Value *CreateIsNull(Value *Arg, const char *Name = "") {
-    return CreateICmpEQ(Arg, Context.getNullValue(Arg->getType()),
+    return CreateICmpEQ(Arg, Constant::getNullValue(Arg->getType()),
                         Name);
   }
 
   /// CreateIsNotNull - Return an i1 value testing if \arg Arg is not null.
   Value *CreateIsNotNull(Value *Arg, const char *Name = "") {
-    return CreateICmpNE(Arg, Context.getNullValue(Arg->getType()),
+    return CreateICmpNE(Arg, Constant::getNullValue(Arg->getType()),
                         Name);
   }
 
@@ -709,7 +704,7 @@
     Value *RHS_int = CreatePtrToInt(RHS, Type::Int64Ty);
     Value *Difference = CreateSub(LHS_int, RHS_int);
     return CreateSDiv(Difference,
-                      Context.getConstantExprSizeOf(ArgType->getElementType()),
+                      ConstantExpr::getSizeOf(ArgType->getElementType()),
                       Name);
   }
 };

Modified: llvm/trunk/lib/Analysis/DebugInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/DebugInfo.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Jul  8 14:03:57 2009
@@ -490,9 +490,9 @@
   Constant *ConstStr = VMContext.getConstantArray(String);
     
   // Otherwise create and return a new string global.
-  GlobalVariable *StrGV = new GlobalVariable(VMContext,ConstStr->getType(), true,
+  GlobalVariable *StrGV = new GlobalVariable(M, ConstStr->getType(), true,
                                              GlobalVariable::InternalLinkage,
-                                             ConstStr, ".str", &M);
+                                             ConstStr, ".str");
   StrGV->setSection("llvm.metadata");
   return Slot = VMContext.getConstantExprBitCast(StrGV, DestTy);
 }
@@ -516,9 +516,9 @@
   DIDescriptor &Entry = SimpleConstantCache[Init];
   if (!Entry.isNull()) return DIArray(Entry.getGV());
   
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.array", &M);
+                                          Init, "llvm.dbg.array");
   GV->setSection("llvm.metadata");
   Entry = DIDescriptor(GV);
   return DIArray(GV);
@@ -542,9 +542,9 @@
   
   M.addTypeName("llvm.dbg.subrange.type", Init->getType());
 
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.subrange", &M);
+                                          Init, "llvm.dbg.subrange");
   GV->setSection("llvm.metadata");
   Entry = DIDescriptor(GV);
   return DISubrange(GV);
@@ -579,9 +579,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.compile_unit.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::LinkOnceAnyLinkage,
-                                          Init, "llvm.dbg.compile_unit", &M);
+                                          Init, "llvm.dbg.compile_unit");
   GV->setSection("llvm.metadata");
   return DICompileUnit(GV);
 }
@@ -598,9 +598,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.enumerator.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.enumerator", &M);
+                                          Init, "llvm.dbg.enumerator");
   GV->setSection("llvm.metadata");
   return DIEnumerator(GV);
 }
@@ -632,9 +632,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.basictype.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.basictype", &M);
+                                          Init, "llvm.dbg.basictype");
   GV->setSection("llvm.metadata");
   return DIBasicType(GV);
 }
@@ -668,9 +668,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.derivedtype.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.derivedtype", &M);
+                                          Init, "llvm.dbg.derivedtype");
   GV->setSection("llvm.metadata");
   return DIDerivedType(GV);
 }
@@ -708,9 +708,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.composite.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.composite", &M);
+                                          Init, "llvm.dbg.composite");
   GV->setSection("llvm.metadata");
   return DICompositeType(GV);
 }
@@ -746,9 +746,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.subprogram.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::LinkOnceAnyLinkage,
-                                          Init, "llvm.dbg.subprogram", &M);
+                                          Init, "llvm.dbg.subprogram");
   GV->setSection("llvm.metadata");
   return DISubprogram(GV);
 }
@@ -780,9 +780,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.global_variable.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::LinkOnceAnyLinkage,
-                                          Init, "llvm.dbg.global_variable", &M);
+                                          Init, "llvm.dbg.global_variable");
   GV->setSection("llvm.metadata");
   return DIGlobalVariable(GV);
 }
@@ -806,9 +806,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.variable.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.variable", &M);
+                                          Init, "llvm.dbg.variable");
   GV->setSection("llvm.metadata");
   return DIVariable(GV);
 }
@@ -826,9 +826,9 @@
                                              sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.block.type", Init->getType());
-  GlobalVariable *GV = new GlobalVariable(VMContext, Init->getType(), true,
+  GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
                                           GlobalValue::InternalLinkage,
-                                          Init, "llvm.dbg.block", &M);
+                                          Init, "llvm.dbg.block");
   GV->setSection("llvm.metadata");
   return DIBlock(GV);
 }

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Jul  8 14:03:57 2009
@@ -516,9 +516,8 @@
   }
 
   if (GV == 0) {
-    GV = new GlobalVariable(Context, Ty, false,
-                            GlobalValue::ExternalLinkage, 0, Name,
-                            M, false, AddrSpace);
+    GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0, 
+                            Name, 0, false, AddrSpace);
   } else {
     if (GV->getType()->getElementType() != Ty)
       return Error(TyLoc,
@@ -608,8 +607,8 @@
     
     FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
   } else {
-    FwdVal = new GlobalVariable(Context, PTy->getElementType(), false,
-                                GlobalValue::ExternalWeakLinkage, 0, Name, M);
+    FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
+                                GlobalValue::ExternalWeakLinkage, 0, Name);
   }
   
   ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
@@ -652,8 +651,8 @@
     }
     FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, "", M);
   } else {
-    FwdVal = new GlobalVariable(Context, PTy->getElementType(), false,
-                                GlobalValue::ExternalWeakLinkage, 0, "", M);
+    FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
+                                GlobalValue::ExternalWeakLinkage, 0, "");
   }
   
   ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Jul  8 14:03:57 2009
@@ -1254,7 +1254,7 @@
         isThreadLocal = Record[7];
 
       GlobalVariable *NewGV =
-        new GlobalVariable(Context, Ty, isConstant, Linkage, 0, "", TheModule, 
+        new GlobalVariable(*TheModule, Ty, isConstant, Linkage, 0, "", 0, 
                            isThreadLocal, AddressSpace);
       NewGV->setAlignment(Alignment);
       if (!Section.empty())

Modified: llvm/trunk/lib/CodeGen/ShadowStackGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/ShadowStackGC.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Wed Jul  8 14:03:57 2009
@@ -229,10 +229,9 @@
   //        to be a ModulePass (which means it cannot be in the 'llc' pipeline
   //        (which uses a FunctionPassManager (which segfaults (not asserts) if
   //        provided a ModulePass))).
-  Constant *GV = new GlobalVariable(*F.getContext(), FrameMap->getType(), true,
+  Constant *GV = new GlobalVariable(*F.getParent(), FrameMap->getType(), true,
                                     GlobalVariable::InternalLinkage,
-                                    FrameMap, "__gc_" + F.getName(),
-                                    F.getParent());
+                                    FrameMap, "__gc_" + F.getName());
 
   Constant *GEPIndices[2] = { ConstantInt::get(Type::Int32Ty, 0),
                               ConstantInt::get(Type::Int32Ty, 0) };
@@ -292,10 +291,10 @@
   if (!Head) {
     // If the root chain does not exist, insert a new one with linkonce
     // linkage!
-    Head = new GlobalVariable(M.getContext(), StackEntryPtrTy, false,
+    Head = new GlobalVariable(M, StackEntryPtrTy, false,
                               GlobalValue::LinkOnceAnyLinkage,
                               Constant::getNullValue(StackEntryPtrTy),
-                              "llvm_gc_root_chain", &M);
+                              "llvm_gc_root_chain");
   } else if (Head->hasExternalLinkage() && Head->isDeclaration()) {
     Head->setInitializer(Constant::getNullValue(StackEntryPtrTy));
     Head->setLinkage(GlobalValue::LinkOnceAnyLinkage);

Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Jul  8 14:03:57 2009
@@ -573,9 +573,9 @@
       // symbol over in the dest module... the initializer will be filled in
       // later by LinkGlobalInits.
       GlobalVariable *NewDGV =
-        new GlobalVariable(Context, SGV->getType()->getElementType(),
+        new GlobalVariable(*Dest, SGV->getType()->getElementType(),
                            SGV->isConstant(), SGV->getLinkage(), /*init*/0,
-                           SGV->getName(), Dest, false,
+                           SGV->getName(), 0, false,
                            SGV->getType()->getAddressSpace());
       // Propagate alignment, visibility and section info.
       CopyGVAttributes(NewDGV, SGV);
@@ -606,9 +606,9 @@
       // AppendingVars map.  The name is cleared out so that no linkage is
       // performed.
       GlobalVariable *NewDGV =
-        new GlobalVariable(Context, SGV->getType()->getElementType(),
+        new GlobalVariable(*Dest, SGV->getType()->getElementType(),
                            SGV->isConstant(), SGV->getLinkage(), /*init*/0,
-                           "", Dest, false,
+                           "", 0, false,
                            SGV->getType()->getAddressSpace());
 
       // Set alignment allowing CopyGVAttributes merge it with alignment of SGV.
@@ -634,9 +634,9 @@
       // we are replacing may be a function (if a prototype, weak, etc) or a
       // global variable.
       GlobalVariable *NewDGV =
-        new GlobalVariable(Context, SGV->getType()->getElementType(), 
+        new GlobalVariable(*Dest, SGV->getType()->getElementType(), 
                            SGV->isConstant(), NewLinkage, /*init*/0, 
-                           DGV->getName(), Dest, false,
+                           DGV->getName(), 0, false,
                            SGV->getType()->getAddressSpace());
 
       // Propagate alignment, section, and visibility info.
@@ -1157,8 +1157,8 @@
 
       // Create the new global variable...
       GlobalVariable *NG =
-        new GlobalVariable(Context, NewType, G1->isConstant(), G1->getLinkage(),
-                           /*init*/0, First->first, M, G1->isThreadLocal(),
+        new GlobalVariable(*M, NewType, G1->isConstant(), G1->getLinkage(),
+                           /*init*/0, First->first, 0, G1->isThreadLocal(),
                            G1->getType()->getAddressSpace());
 
       // Propagate alignment, visibility and section info.

Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Wed Jul  8 14:03:57 2009
@@ -108,9 +108,9 @@
         }
         ArrayType *AT = Context->getArrayType(SBP, AUGs.size());
         Constant *Init = Context->getConstantArray(AT, AUGs);
-        GlobalValue *gv = new GlobalVariable(M.getContext(), AT, false, 
+        GlobalValue *gv = new GlobalVariable(M, AT, false, 
                                              GlobalValue::AppendingLinkage, 
-                                             Init, "llvm.used", &M);
+                                             Init, "llvm.used");
         gv->setSection("llvm.metadata");
       }
 

Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Jul  8 14:03:57 2009
@@ -490,11 +490,10 @@
                                     Context->getConstantInt(Type::Int32Ty, i),
                                     Context);
       assert(In && "Couldn't get element of initializer?");
-      GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(i),
-                                               false,
+      GlobalVariable *NGV = new GlobalVariable(*Context,
+                                               STy->getElementType(i), false,
                                                GlobalVariable::InternalLinkage,
                                                In, GV->getName()+"."+utostr(i),
-                                               (Module *)NULL,
                                                GV->isThreadLocal(),
                                               GV->getType()->getAddressSpace());
       Globals.insert(GV, NGV);
@@ -527,13 +526,12 @@
                                     Context);
       assert(In && "Couldn't get element of initializer?");
 
-      GlobalVariable *NGV = new GlobalVariable(*Context, STy->getElementType(), 
-                                               false,
+      GlobalVariable *NGV = new GlobalVariable(*Context,
+                                               STy->getElementType(), false,
                                                GlobalVariable::InternalLinkage,
                                                In, GV->getName()+"."+utostr(i),
-                                               (Module *)NULL,
                                                GV->isThreadLocal(),
-                                               GV->getType()->getAddressSpace());
+                                              GV->getType()->getAddressSpace());
       Globals.insert(GV, NGV);
       NewGlobals.push_back(NGV);
       
@@ -842,18 +840,17 @@
 
   // Create the new global variable.  The contents of the malloc'd memory is
   // undefined, so initialize with an undef value.
+  // FIXME: This new global should have the alignment returned by malloc.  Code
+  // could depend on malloc returning large alignment (on the mac, 16 bytes) but
+  // this would only guarantee some lower alignment.
   Constant *Init = Context->getUndef(MI->getAllocatedType());
-  GlobalVariable *NewGV = new GlobalVariable(*Context, MI->getAllocatedType(),  
-                                             false,
+  GlobalVariable *NewGV = new GlobalVariable(*GV->getParent(), 
+                                             MI->getAllocatedType(), false,
                                              GlobalValue::InternalLinkage, Init,
                                              GV->getName()+".body",
-                                             (Module *)NULL,
+                                             GV,
                                              GV->isThreadLocal());
-  // FIXME: This new global should have the alignment returned by malloc.  Code
-  // could depend on malloc returning large alignment (on the mac, 16 bytes) but
-  // this would only guarantee some lower alignment.
-  GV->getParent()->getGlobalList().insert(GV, NewGV);
-
+  
   // Anything that used the malloc now uses the global directly.
   MI->replaceAllUsesWith(NewGV);
 
@@ -868,7 +865,7 @@
     new GlobalVariable(*Context, Type::Int1Ty, false,
                        GlobalValue::InternalLinkage,
                        Context->getConstantIntFalse(), GV->getName()+".init",
-                       (Module *)NULL, GV->isThreadLocal());
+                       GV->isThreadLocal());
   bool InitBoolUsed = false;
 
   // Loop over all uses of GV, processing them in turn.
@@ -1286,8 +1283,8 @@
     const Type *PFieldTy = Context->getPointerTypeUnqual(FieldTy);
     
     GlobalVariable *NGV =
-      new GlobalVariable(*Context, PFieldTy, false,
-                         GlobalValue::InternalLinkage,
+      new GlobalVariable(*GV->getParent(),
+                         PFieldTy, false, GlobalValue::InternalLinkage,
                          Context->getNullValue(PFieldTy),
                          GV->getName() + ".f" + utostr(FieldNo), GV,
                          GV->isThreadLocal());
@@ -1587,7 +1584,6 @@
   GlobalVariable *NewGV = new GlobalVariable(*Context, Type::Int1Ty, false,
          GlobalValue::InternalLinkage, Context->getConstantIntFalse(),
                                              GV->getName()+".b",
-                                             (Module *)NULL,
                                              GV->isThreadLocal());
   GV->getParent()->getGlobalList().insert(GV, NewGV);
 
@@ -1982,7 +1978,6 @@
   GlobalVariable *NGV = new GlobalVariable(*Context, CA->getType(), 
                                            GCL->isConstant(),
                                            GCL->getLinkage(), CA, "",
-                                           (Module *)NULL,
                                            GCL->isThreadLocal());
   GCL->getParent()->getGlobalList().insert(GCL, NGV);
   NGV->takeName(GCL);

Modified: llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/BlockProfiling.cpp Wed Jul  8 14:03:57 2009
@@ -65,8 +65,8 @@
 
   const Type *ATy = Context->getArrayType(Type::Int32Ty, NumFunctions);
   GlobalVariable *Counters =
-    new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage,
-                       Context->getNullValue(ATy), "FuncProfCounters", &M);
+    new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
+                       Context->getNullValue(ATy), "FuncProfCounters");
 
   // Instrument all of the functions...
   unsigned i = 0;
@@ -110,8 +110,8 @@
 
   const Type *ATy = Context->getArrayType(Type::Int32Ty, NumBlocks);
   GlobalVariable *Counters =
-    new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage,
-                       Context->getNullValue(ATy), "BlockProfCounters", &M);
+    new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
+                       Context->getNullValue(ATy), "BlockProfCounters");
 
   // Instrument all of the blocks...
   unsigned i = 0;

Modified: llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/EdgeProfiling.cpp Wed Jul  8 14:03:57 2009
@@ -66,8 +66,8 @@
 
   const Type *ATy = Context->getArrayType(Type::Int32Ty, NumEdges);
   GlobalVariable *Counters =
-    new GlobalVariable(M.getContext(), ATy, false, GlobalValue::InternalLinkage,
-                       Context->getNullValue(ATy), "EdgeProfCounters", &M);
+    new GlobalVariable(M, ATy, false, GlobalValue::InternalLinkage,
+                       Context->getNullValue(ATy), "EdgeProfCounters");
 
   // Instrument all of the edges...
   unsigned i = 0;

Modified: llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp (original)
+++ llvm/trunk/lib/Transforms/Instrumentation/RSProfiling.cpp Wed Jul  8 14:03:57 2009
@@ -198,9 +198,8 @@
                                          uint64_t resetval) : T(t) {
   ConstantInt* Init = M.getContext().getConstantInt(T, resetval); 
   ResetValue = Init;
-  Counter = new GlobalVariable(M.getContext(), T, false,
-                               GlobalValue::InternalLinkage,
-                               Init, "RandomSteeringCounter", &M);
+  Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage,
+                               Init, "RandomSteeringCounter");
 }
 
 GlobalRandomCounter::~GlobalRandomCounter() {}
@@ -238,9 +237,8 @@
   : AI(0), T(t) {
   ConstantInt* Init = M.getContext().getConstantInt(T, resetval);
   ResetValue  = Init;
-  Counter = new GlobalVariable(M.getContext(), T, false,
-                               GlobalValue::InternalLinkage,
-                               Init, "RandomSteeringCounter", &M);
+  Counter = new GlobalVariable(M, T, false, GlobalValue::InternalLinkage,
+                               Init, "RandomSteeringCounter");
 }
 
 GlobalRandomCounterOpt::~GlobalRandomCounterOpt() {}

Modified: llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SimplifyLibCalls.cpp Wed Jul  8 14:03:57 2009
@@ -1290,9 +1290,8 @@
       // pass to be run after this pass, to merge duplicate strings.
       FormatStr.erase(FormatStr.end()-1);
       Constant *C = Context->getConstantArray(FormatStr, true);
-      C = new GlobalVariable(*Context, C->getType(),
-                             true, GlobalVariable::InternalLinkage,
-                             C, "str", Callee->getParent());
+      C = new GlobalVariable(*Callee->getParent(), C->getType(), true,
+                             GlobalVariable::InternalLinkage, C, "str");
       EmitPutS(C, B);
       return CI->use_empty() ? (Value*)CI : 
                     Context->getConstantInt(CI->getType(), FormatStr.size()+1);

Modified: llvm/trunk/lib/Transforms/Utils/CloneModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/CloneModule.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CloneModule.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CloneModule.cpp Wed Jul  8 14:03:57 2009
@@ -56,11 +56,11 @@
   //
   for (Module::const_global_iterator I = M->global_begin(), E = M->global_end();
        I != E; ++I) {
-    GlobalVariable *GV = new GlobalVariable(M->getContext(),
+    GlobalVariable *GV = new GlobalVariable(*New, 
                                             I->getType()->getElementType(),
                                             false,
                                             GlobalValue::ExternalLinkage, 0,
-                                            I->getName(), New);
+                                            I->getName());
     GV->setAlignment(I->getAlignment());
     ValueMap[I] = GV;
   }

Modified: llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Wed Jul  8 14:03:57 2009
@@ -139,11 +139,10 @@
     // Now that we've done that, insert the jmpbuf list head global, unless it
     // already exists.
     if (!(JBListHead = M.getGlobalVariable("llvm.sjljeh.jblist", PtrJBList))) {
-      JBListHead = new GlobalVariable(M.getContext(),
-                                      PtrJBList, false,
+      JBListHead = new GlobalVariable(M, PtrJBList, false,
                                       GlobalValue::LinkOnceAnyLinkage,
                                       Context->getNullValue(PtrJBList),
-                                      "llvm.sjljeh.jblist", &M);
+                                      "llvm.sjljeh.jblist");
     }
 
 // VisualStudio defines setjmp as _setjmp via #include <csetjmp> / <setjmp.h>,
@@ -183,10 +182,9 @@
       Context->getConstantArray("ERROR: Exception thrown, but not caught!\n");
     AbortMessageLength = Msg->getNumOperands()-1;  // don't include \0
 
-    GlobalVariable *MsgGV = new GlobalVariable(M->getContext(),
-                                               Msg->getType(), true,
+    GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true,
                                                GlobalValue::InternalLinkage,
-                                               Msg, "abortmsg", M);
+                                               Msg, "abortmsg");
     std::vector<Constant*> GEPIdx(2, Context->getNullValue(Type::Int32Ty));
     AbortMessage = Context->getConstantExprGetElementPtr(MsgGV, &GEPIdx[0], 2);
   } else {
@@ -197,10 +195,9 @@
                         "Recompile program with -enable-correct-eh-support.\n");
     AbortMessageLength = Msg->getNumOperands()-1;  // don't include \0
 
-    GlobalVariable *MsgGV = new GlobalVariable(M->getContext(),
-                                               Msg->getType(), true,
+    GlobalVariable *MsgGV = new GlobalVariable(*M, Msg->getType(), true,
                                                GlobalValue::InternalLinkage,
-                                               Msg, "abortmsg", M);
+                                               Msg, "abortmsg");
     std::vector<Constant*> GEPIdx(2, Context->getNullValue(Type::Int32Ty));
     AbortMessage = ConstantExpr::getGetElementPtr(MsgGV, &GEPIdx[0], 2);
   }

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Wed Jul  8 14:03:57 2009
@@ -700,10 +700,8 @@
 /*--.. Operations on global variables ......................................--*/
 
 LLVMValueRef LLVMAddGlobal(LLVMModuleRef M, LLVMTypeRef Ty, const char *Name) {
-  LLVMContext &Context = unwrap(M)->getContext();
-  return wrap(new GlobalVariable(Context, unwrap(Ty), false,
-                                 GlobalValue::ExternalLinkage, 0, Name,
-                                 unwrap(M)));
+  return wrap(new GlobalVariable(*unwrap(M), unwrap(Ty), false,
+                                 GlobalValue::ExternalLinkage, 0, Name));
 }
 
 LLVMValueRef LLVMGetNamedGlobal(LLVMModuleRef M, const char *Name) {

Modified: llvm/trunk/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Globals.cpp (original)
+++ llvm/trunk/lib/VMCore/Globals.cpp Wed Jul  8 14:03:57 2009
@@ -97,8 +97,7 @@
 GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
                                bool constant, LinkageTypes Link,
                                Constant *InitVal, const std::string &Name,
-                               Module *ParentModule, bool ThreadLocal, 
-                               unsigned AddressSpace)
+                               bool ThreadLocal, unsigned AddressSpace)
   : GlobalValue(Context.getPointerType(Ty, AddressSpace), 
                 Value::GlobalVariableVal,
                 OperandTraits<GlobalVariable>::op_begin(this),
@@ -111,18 +110,14 @@
   }
 
   LeakDetector::addGarbageObject(this);
-
-  if (ParentModule)
-    ParentModule->getGlobalList().push_back(this);
 }
 
-GlobalVariable::GlobalVariable(LLVMContext &Context, const Type *Ty,
-                               bool constant, LinkageTypes Link,
-                               Constant *InitVal, const std::string &Name,
+GlobalVariable::GlobalVariable(Module &M, const Type *Ty, bool constant,
+                               LinkageTypes Link, Constant *InitVal,
+                               const std::string &Name,
                                GlobalVariable *Before, bool ThreadLocal,
                                unsigned AddressSpace)
-  : GlobalValue(Context.getPointerType(Ty, AddressSpace),
-                Value::GlobalVariableVal,
+  : GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
                 OperandTraits<GlobalVariable>::op_begin(this),
                 InitVal != 0, Link, Name),
     isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
@@ -136,6 +131,8 @@
   
   if (Before)
     Before->getParent()->getGlobalList().insert(Before, this);
+  else
+    M.getGlobalList().push_back(this);
 }
 
 void GlobalVariable::setParent(Module *parent) {

Modified: llvm/trunk/lib/VMCore/Module.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Module.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Module.cpp (original)
+++ llvm/trunk/lib/VMCore/Module.cpp Wed Jul  8 14:03:57 2009
@@ -28,20 +28,17 @@
 
 //===----------------------------------------------------------------------===//
 // Methods to implement the globals and functions lists.
-// NOTE: It is ok to allocate the globals used for these methods from the 
-// global context, because all we ever do is use them to compare for equality.
 //
 
 GlobalVariable *ilist_traits<GlobalVariable>::createSentinel() {
-  GlobalVariable *Ret = new GlobalVariable(getGlobalContext(),
-                                           Type::Int32Ty, false,
-                                           GlobalValue::ExternalLinkage);
+  GlobalVariable *Ret = new GlobalVariable(getGlobalContext(), Type::Int32Ty,
+                                           false, GlobalValue::ExternalLinkage);
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
   return Ret;
 }
 GlobalAlias *ilist_traits<GlobalAlias>::createSentinel() {
-  GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty, 
+  GlobalAlias *Ret = new GlobalAlias(Type::Int32Ty,
                                      GlobalValue::ExternalLinkage);
   // This should not be garbage monitored.
   LeakDetector::removeGarbageObject(Ret);
@@ -273,10 +270,9 @@
   if (GV == 0) {
     // Nope, add it
     GlobalVariable *New =
-      new GlobalVariable(getContext(), Ty, false, 
-                         GlobalVariable::ExternalLinkage, 0, Name);
-    GlobalList.push_back(New);
-    return New;                    // Return the new declaration.
+      new GlobalVariable(*this, Ty, false, GlobalVariable::ExternalLinkage,
+                         0, Name);
+     return New;                    // Return the new declaration.
   }
 
   // If the variable exists but has the wrong type, return a bitcast to the

Modified: llvm/trunk/tools/bugpoint/ExtractFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExtractFunction.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Wed Jul  8 14:03:57 2009
@@ -236,9 +236,9 @@
   GV->eraseFromParent();
   if (!M1Tors.empty()) {
     Constant *M1Init = GetTorInit(M1Tors);
-    new GlobalVariable(M1->getContext(), M1Init->getType(), false,
+    new GlobalVariable(*M1, M1Init->getType(), false,
                        GlobalValue::AppendingLinkage,
-                       M1Init, GlobalName, M1);
+                       M1Init, GlobalName);
   }
 
   GV = M2->getNamedGlobal(GlobalName);
@@ -248,9 +248,9 @@
   GV->eraseFromParent();
   if (!M2Tors.empty()) {
     Constant *M2Init = GetTorInit(M2Tors);
-    new GlobalVariable(M2->getContext(), M2Init->getType(), false, 
+    new GlobalVariable(*M2, M2Init->getType(), false,
                        GlobalValue::AppendingLinkage,
-                       M2Init, GlobalName, M2);
+                       M2Init, GlobalName);
   }
 }
 

Modified: llvm/trunk/tools/bugpoint/Miscompilation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/Miscompilation.cpp?rev=75025&r1=75024&r2=75025&view=diff

==============================================================================
--- llvm/trunk/tools/bugpoint/Miscompilation.cpp (original)
+++ llvm/trunk/tools/bugpoint/Miscompilation.cpp Wed Jul  8 14:03:57 2009
@@ -703,10 +703,9 @@
         // 1. Add a string constant with its name to the global file
         Constant *InitArray = ConstantArray::get(F->getName());
         GlobalVariable *funcName =
-          new GlobalVariable(Safe->getContext(),
-                             InitArray->getType(), true /*isConstant*/,
+          new GlobalVariable(*Safe, InitArray->getType(), true /*isConstant*/,
                              GlobalValue::InternalLinkage, InitArray,
-                             F->getName() + "_name", Safe);
+                             F->getName() + "_name");
 
         // 2. Use `GetElementPtr *funcName, 0, 0' to convert the string to an
         // sbyte* so it matches the signature of the resolver function.
@@ -723,9 +722,9 @@
           // Create a new global to hold the cached function pointer.
           Constant *NullPtr = ConstantPointerNull::get(F->getType());
           GlobalVariable *Cache =
-            new GlobalVariable(F->getParent()->getContext(),
-                               F->getType(), false,GlobalValue::InternalLinkage,
-                               NullPtr,F->getName()+".fpcache", F->getParent());
+            new GlobalVariable(*F->getParent(), F->getType(), 
+                               false, GlobalValue::InternalLinkage,
+                               NullPtr,F->getName()+".fpcache");
 
           // Construct a new stub function that will re-route calls to F
           const FunctionType *FuncTy = F->getFunctionType();





More information about the llvm-commits mailing list