[llvm-commits] [llvm] r78258 - in /llvm/trunk: include/llvm/ lib/Analysis/ lib/AsmParser/ lib/Bitcode/Reader/ lib/CodeGen/ lib/Debugger/ lib/Transforms/IPO/ lib/Transforms/Utils/ lib/VMCore/ tools/bugpoint/ utils/TableGen/

Owen Anderson resistor at mac.com
Wed Aug 5 16:16:18 PDT 2009


Author: resistor
Date: Wed Aug  5 18:16:16 2009
New Revision: 78258

URL: http://llvm.org/viewvc/llvm-project?rev=78258&view=rev
Log:
Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs.

Modified:
    llvm/trunk/include/llvm/Constants.h
    llvm/trunk/include/llvm/DerivedTypes.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/Debugger/ProgramInfo.cpp
    llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
    llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
    llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp
    llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp
    llvm/trunk/lib/VMCore/ConstantFold.cpp
    llvm/trunk/lib/VMCore/Constants.cpp
    llvm/trunk/lib/VMCore/Core.cpp
    llvm/trunk/lib/VMCore/LLVMContextImpl.h
    llvm/trunk/lib/VMCore/Type.cpp
    llvm/trunk/tools/bugpoint/ExtractFunction.cpp
    llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp

Modified: llvm/trunk/include/llvm/Constants.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Constants.h?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Constants.h (original)
+++ llvm/trunk/include/llvm/Constants.h Wed Aug  5 18:16:16 2009
@@ -407,8 +407,10 @@
 public:
   // ConstantStruct accessors
   static Constant* get(const StructType* T, const std::vector<Constant*>& V);
-  static Constant* get(const std::vector<Constant*>& V, bool Packed = false);
-  static Constant* get(Constant* const *Vals, unsigned NumVals,
+  static Constant* get(LLVMContext &Context, 
+                       const std::vector<Constant*>& V, bool Packed = false);
+  static Constant* get(LLVMContext &Context,
+                       Constant* const *Vals, unsigned NumVals,
                        bool Packed = false);
   
   /// Transparently provide more efficient getOperand methods.

Modified: llvm/trunk/include/llvm/DerivedTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/DerivedTypes.h?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/include/llvm/DerivedTypes.h (original)
+++ llvm/trunk/include/llvm/DerivedTypes.h Wed Aug  5 18:16:16 2009
@@ -31,6 +31,7 @@
 class VectorValType;
 class IntegerValType;
 class APInt;
+struct LLVMContext;
 
 class DerivedType : public Type {
   friend class Type;
@@ -240,20 +241,22 @@
   /// StructType::get - This static method is the primary way to create a
   /// StructType.
   ///
-  static StructType *get(const std::vector<const Type*> &Params,
+  static StructType *get(LLVMContext &Context, 
+                         const std::vector<const Type*> &Params,
                          bool isPacked=false);
 
   /// StructType::get - Create an empty structure type.
   ///
-  static StructType *get(bool isPacked=false) {
-    return get(std::vector<const Type*>(), isPacked);
+  static StructType *get(LLVMContext &Context, bool isPacked=false) {
+    return get(Context, std::vector<const Type*>(), isPacked);
   }
 
   /// StructType::get - This static method is a convenience method for
   /// creating structure types by specifying the elements as arguments.
   /// Note that this method always returns a non-packed struct.  To get
   /// an empty struct, pass NULL, NULL.
-  static StructType *get(const Type *type, ...) END_WITH_NULL;
+  static StructType *get(LLVMContext &Context, 
+                         const Type *type, ...) END_WITH_NULL;
 
   /// isValidElementType - Return true if the specified type is valid as a
   /// element type.

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

==============================================================================
--- llvm/trunk/lib/Analysis/DebugInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/DebugInfo.cpp Wed Aug  5 18:16:16 2009
@@ -470,7 +470,7 @@
   : M(m), VMContext(M.getContext()), StopPointFn(0), FuncStartFn(0), 
     RegionStartFn(0), RegionEndFn(0),
     DeclareFn(0) {
-  EmptyStructPtr = PointerType::getUnqual(StructType::get());
+  EmptyStructPtr = PointerType::getUnqual(StructType::get(VMContext));
 }
 
 /// getCastToEmpty - Return this descriptor as a Constant* with type '{}*'.
@@ -546,7 +546,8 @@
     ConstantInt::get(Type::Int64Ty, Hi)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
 
   // If we already have this range, just return the uniqued version.
   DIDescriptor &Entry = SimpleConstantCache[Init];
@@ -587,7 +588,8 @@
     ConstantInt::get(Type::Int32Ty, RunTimeVer)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.compile_unit.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -605,7 +607,8 @@
     ConstantInt::get(Type::Int64Ty, Val)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.enumerator.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -638,7 +641,8 @@
     ConstantInt::get(Type::Int32Ty, Encoding)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.basictype.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -673,7 +677,8 @@
     getCastToEmpty(DerivedFrom)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.derivedtype.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -712,7 +717,8 @@
     ConstantInt::get(Type::Int32Ty, RuntimeLang)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.composite.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -749,7 +755,8 @@
     ConstantInt::get(Type::Int1Ty, isDefinition)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.subprogram.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -782,7 +789,8 @@
     ConstantExpr::getBitCast(Val, EmptyStructPtr)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.global_variable.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -807,7 +815,8 @@
     getCastToEmpty(Type)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.variable.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,
@@ -826,7 +835,8 @@
     getCastToEmpty(Context)
   };
   
-  Constant *Init = ConstantStruct::get(Elts, sizeof(Elts)/sizeof(Elts[0]));
+  Constant *Init = ConstantStruct::get(VMContext, Elts,
+                                       sizeof(Elts)/sizeof(Elts[0]));
   
   M.addTypeName("llvm.dbg.block.type", Init->getType());
   GlobalVariable *GV = new GlobalVariable(M, Init->getType(), true,

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

==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Wed Aug  5 18:16:16 2009
@@ -1381,7 +1381,7 @@
   Lex.Lex(); // Consume the '{'
   
   if (EatIfPresent(lltok::rbrace)) {
-    Result = StructType::get(Packed);
+    Result = StructType::get(Context, Packed);
     return false;
   }
 
@@ -1413,7 +1413,7 @@
   std::vector<const Type*> ParamsListTy;
   for (unsigned i = 0, e = ParamsList.size(); i != e; ++i)
     ParamsListTy.push_back(ParamsList[i].get());
-  Result = HandleUpRefs(StructType::get(ParamsListTy, Packed));
+  Result = HandleUpRefs(StructType::get(Context, ParamsListTy, Packed));
   return false;
 }
 
@@ -1772,7 +1772,8 @@
         ParseToken(lltok::rbrace, "expected end of struct constant"))
       return true;
     
-    ID.ConstantVal = ConstantStruct::get(Elts.data(), Elts.size(), false);
+    ID.ConstantVal = ConstantStruct::get(Context, Elts.data(),
+                                         Elts.size(), false);
     ID.Kind = ValID::t_Constant;
     return false;
   }
@@ -1792,7 +1793,7 @@
     
     if (isPackedStruct) {
       ID.ConstantVal =
-        ConstantStruct::get(Elts.data(), Elts.size(), true);
+        ConstantStruct::get(Context, Elts.data(), Elts.size(), true);
       ID.Kind = ValID::t_Constant;
       return false;
     }

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

==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Wed Aug  5 18:16:16 2009
@@ -292,7 +292,7 @@
         NewC = ConstantArray::get(UserCA->getType(), &NewOps[0],
                                         NewOps.size());
       } else if (ConstantStruct *UserCS = dyn_cast<ConstantStruct>(UserC)) {
-        NewC = ConstantStruct::get(&NewOps[0], NewOps.size(),
+        NewC = ConstantStruct::get(Context, &NewOps[0], NewOps.size(),
                                          UserCS->getType()->isPacked());
       } else if (isa<ConstantVector>(UserC)) {
         NewC = ConstantVector::get(&NewOps[0], NewOps.size());
@@ -580,7 +580,7 @@
       std::vector<const Type*> EltTys;
       for (unsigned i = 1, e = Record.size(); i != e; ++i)
         EltTys.push_back(getTypeByID(Record[i], true));
-      ResultTy = StructType::get(EltTys, Record[0]);
+      ResultTy = StructType::get(Context, EltTys, Record[0]);
       break;
     }
     case bitc::TYPE_CODE_ARRAY:     // ARRAY: [numelts, eltty]

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

==============================================================================
--- llvm/trunk/lib/CodeGen/ShadowStackGC.cpp (original)
+++ llvm/trunk/lib/CodeGen/ShadowStackGC.cpp Wed Aug  5 18:16:16 2009
@@ -206,12 +206,12 @@
   };
 
   Constant *DescriptorElts[] = {
-    ConstantStruct::get(BaseElts, 2),
+    ConstantStruct::get(F.getContext(), BaseElts, 2),
     ConstantArray::get(ArrayType::get(VoidPtr, NumMeta),
                        Metadata.begin(), NumMeta)
   };
 
-  Constant *FrameMap = ConstantStruct::get(DescriptorElts, 2);
+  Constant *FrameMap = ConstantStruct::get(F.getContext(), DescriptorElts, 2);
 
   std::string TypeName("gc_map.");
   TypeName += utostr(NumMeta);
@@ -245,7 +245,7 @@
   EltTys.push_back(StackEntryTy);
   for (size_t I = 0; I != Roots.size(); I++)
     EltTys.push_back(Roots[I].second->getAllocatedType());
-  Type *Ty = StructType::get(EltTys);
+  Type *Ty = StructType::get(F.getContext(), EltTys);
 
   std::string TypeName("gc_stackentry.");
   TypeName += F.getName();
@@ -265,7 +265,7 @@
   std::vector<const Type*> EltTys;
   EltTys.push_back(Type::Int32Ty); // 32 bits is ok up to a 32GB stack frame. :)
   EltTys.push_back(Type::Int32Ty); // Specifies length of variable length array.
-  StructType *FrameMapTy = StructType::get(EltTys);
+  StructType *FrameMapTy = StructType::get(M.getContext(), EltTys);
   M.addTypeName("gc_map", FrameMapTy);
   PointerType *FrameMapPtrTy = PointerType::getUnqual(FrameMapTy);
 
@@ -279,7 +279,7 @@
   EltTys.clear();
   EltTys.push_back(PointerType::getUnqual(RecursiveTy));
   EltTys.push_back(FrameMapPtrTy);
-  PATypeHolder LinkTyH = StructType::get(EltTys);
+  PATypeHolder LinkTyH = StructType::get(M.getContext(), EltTys);
 
   RecursiveTy->refineAbstractTypeTo(LinkTyH.get());
   StackEntryTy = cast<StructType>(LinkTyH.get());

Modified: llvm/trunk/lib/Debugger/ProgramInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Debugger/ProgramInfo.cpp?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/lib/Debugger/ProgramInfo.cpp (original)
+++ llvm/trunk/lib/Debugger/ProgramInfo.cpp Wed Aug  5 18:16:16 2009
@@ -271,7 +271,8 @@
   // should be on the use list of the llvm.dbg.translation_units global.
   //
   GlobalVariable *Units =
-    M->getGlobalVariable("llvm.dbg.translation_units", StructType::get());
+    M->getGlobalVariable("llvm.dbg.translation_units", 
+                         StructType::get(M->getContext()));
   if (Units == 0)
     throw "Program contains no debugging information!";
 
@@ -353,7 +354,7 @@
   // should be on the use list of the llvm.dbg.translation_units global.
   //
   GlobalVariable *Units =
-    M->getGlobalVariable("llvm.dbg.globals", StructType::get());
+    M->getGlobalVariable("llvm.dbg.globals", StructType::get(M->getContext()));
   if (Units == 0)
     throw "Program contains no debugging information!";
 

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Wed Aug  5 18:16:16 2009
@@ -638,7 +638,7 @@
       // something and {} into void.
       // Make the new struct packed if we used to return a packed struct
       // already.
-      NRetTy = StructType::get(RetTypes, STy->isPacked());
+      NRetTy = StructType::get(STy->getContext(), RetTypes, STy->isPacked());
     else if (RetTypes.size() == 1)
       // One return type? Just a simple value then, but only if we didn't use to
       // return a struct with that simple value before.

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

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Wed Aug  5 18:16:16 2009
@@ -1961,7 +1961,7 @@
       CSVals[1] = Constant::getNullValue(PFTy);
       CSVals[0] = ConstantInt::get(Type::Int32Ty, 2147483647);
     }
-    CAList.push_back(ConstantStruct::get(CSVals));
+    CAList.push_back(ConstantStruct::get(Context, CSVals));
   }
   
   // Create the array initializer.
@@ -2069,7 +2069,7 @@
     Elts[Idx] = EvaluateStoreInto(Elts[Idx], Val, Addr, OpNo+1, Context);
     
     // Return the modified struct.
-    return ConstantStruct::get(&Elts[0], Elts.size(), STy->isPacked());
+    return ConstantStruct::get(Context, &Elts[0], Elts.size(), STy->isPacked());
   } else {
     ConstantInt *CI = cast<ConstantInt>(Addr->getOperand(OpNo));
     const ArrayType *ATy = cast<ArrayType>(Init->getType());

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

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/CodeExtractor.cpp Wed Aug  5 18:16:16 2009
@@ -275,7 +275,7 @@
 
   if (AggregateArgs && (inputs.size() + outputs.size() > 0)) {
     PointerType *StructPtr =
-           PointerType::getUnqual(StructType::get(paramTy));
+           PointerType::getUnqual(StructType::get(M->getContext(), paramTy));
     paramTy.clear();
     paramTy.push_back(StructPtr);
   }
@@ -382,7 +382,7 @@
       ArgTypes.push_back((*v)->getType());
 
     // Allocate a struct at the beginning of this function
-    Type *StructArgTy = StructType::get(ArgTypes);
+    Type *StructArgTy = StructType::get(newFunction->getContext(), ArgTypes);
     Struct =
       new AllocaInst(StructArgTy, 0, "structArg",
                      codeReplacer->getParent()->begin()->begin());

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

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/LowerInvoke.cpp Wed Aug  5 18:16:16 2009
@@ -128,7 +128,7 @@
       Elements.push_back(JmpBufTy);
       OpaqueType *OT = OpaqueType::get();
       Elements.push_back(PointerType::getUnqual(OT));
-      PATypeHolder JBLType(StructType::get(Elements));
+      PATypeHolder JBLType(StructType::get(M.getContext(), Elements));
       OT->refineAbstractTypeTo(JBLType.get());  // Complete the cycle.
       JBLinkTy = JBLType.get();
       M.addTypeName("llvm.sjljeh.jmpbufty", JBLinkTy);

Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Wed Aug  5 18:16:16 2009
@@ -519,7 +519,7 @@
       Ops[i] = const_cast<Constant*>(Op);
     }
     if (isa<StructType>(AggTy))
-      return ConstantStruct::get(Ops);
+      return ConstantStruct::get(Context, Ops);
     else
       return ConstantArray::get(cast<ArrayType>(AggTy), Ops);
   }
@@ -548,7 +548,7 @@
       Ops[i] = const_cast<Constant*>(Op);
     }
     if (isa<StructType>(AggTy))
-      return ConstantStruct::get(Ops);
+      return ConstantStruct::get(Context, Ops);
     else
       return ConstantArray::get(cast<ArrayType>(AggTy), Ops);
   }
@@ -565,7 +565,7 @@
     }
     Constant *C;
     if (isa<StructType>(Agg->getType()))
-      C = ConstantStruct::get(Ops);
+      C = ConstantStruct::get(Context, Ops);
     else
       C = ConstantArray::get(cast<ArrayType>(Agg->getType()), Ops);
     return C;

Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Wed Aug  5 18:16:16 2009
@@ -532,18 +532,20 @@
   return ConstantAggregateZero::get(T);
 }
 
-Constant* ConstantStruct::get(const std::vector<Constant*>& V, bool packed) {
+Constant* ConstantStruct::get(LLVMContext &Context,
+                              const std::vector<Constant*>& V, bool packed) {
   std::vector<const Type*> StructEls;
   StructEls.reserve(V.size());
   for (unsigned i = 0, e = V.size(); i != e; ++i)
     StructEls.push_back(V[i]->getType());
-  return get(StructType::get(StructEls, packed), V);
+  return get(StructType::get(Context, StructEls, packed), V);
 }
 
-Constant* ConstantStruct::get(Constant* const *Vals, unsigned NumVals,
+Constant* ConstantStruct::get(LLVMContext &Context,
+                              Constant* const *Vals, unsigned NumVals,
                               bool Packed) {
   // FIXME: make this the primary ctor method.
-  return get(std::vector<Constant*>(Vals, Vals+NumVals), Packed);
+  return get(Context, std::vector<Constant*>(Vals, Vals+NumVals), Packed);
 }
 
 ConstantVector::ConstantVector(const VectorType *T,
@@ -1355,7 +1357,8 @@
 
 Constant* ConstantExpr::getAlignOf(const Type* Ty) {
   // alignof is implemented as: (i64) gep ({i8,Ty}*)null, 0, 1
-  const Type *AligningTy = StructType::get(Type::Int8Ty, Ty, NULL);
+  const Type *AligningTy = StructType::get(Ty->getContext(),
+                                           Type::Int8Ty, Ty, NULL);
   Constant *NullPtr = Constant::getNullValue(AligningTy->getPointerTo());
   Constant *Zero = ConstantInt::get(Type::Int32Ty, 0);
   Constant *One = ConstantInt::get(Type::Int32Ty, 1);

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

==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Wed Aug  5 18:16:16 2009
@@ -217,7 +217,7 @@
                    *E = ElementTypes + ElementCount; I != E; ++I)
     Tys.push_back(unwrap(*I));
   
-  return wrap(StructType::get(Tys, Packed != 0));
+  return wrap(StructType::get(getGlobalContext(), Tys, Packed != 0));
 }
 
 unsigned LLVMCountStructElementTypes(LLVMTypeRef StructTy) {
@@ -411,7 +411,8 @@
 
 LLVMValueRef LLVMConstStruct(LLVMValueRef *ConstantVals, unsigned Count,
                              int Packed) {
-  return wrap(ConstantStruct::get(unwrap<Constant>(ConstantVals, Count),
+  return wrap(ConstantStruct::get(getGlobalContext(),
+                                  unwrap<Constant>(ConstantVals, Count),
                                   Count, Packed != 0));
 }
 

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Wed Aug  5 18:16:16 2009
@@ -132,6 +132,7 @@
   TypeMap<VectorValType, VectorType> VectorTypes;
   TypeMap<PointerValType, PointerType> PointerTypes;
   TypeMap<FunctionValType, FunctionType> FunctionTypes;
+  TypeMap<StructValType, StructType> StructTypes;
   
   LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { }
 };

Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Wed Aug  5 18:16:16 2009
@@ -849,22 +849,23 @@
 // Struct Type Factory...
 //
 
-static ManagedStatic<TypeMap<StructValType, StructType> > StructTypes;
-
-StructType *StructType::get(const std::vector<const Type*> &ETypes, 
+StructType *StructType::get(LLVMContext &Context,
+                            const std::vector<const Type*> &ETypes, 
                             bool isPacked) {
   StructValType STV(ETypes, isPacked);
   StructType *ST = 0;
   
+  LLVMContextImpl *pImpl = Context.pImpl;
+  
   sys::SmartScopedLock<true> L(*TypeMapLock);
-  ST = StructTypes->get(STV);
+  ST = pImpl->StructTypes.get(STV);
     
   if (!ST) {
     // Value not found.  Derive a new type!
     ST = (StructType*) operator new(sizeof(StructType) +
                                     sizeof(PATypeHandle) * ETypes.size());
     new (ST) StructType(ETypes, isPacked);
-    StructTypes->add(STV, ST);
+    pImpl->StructTypes.add(STV, ST);
   }
 #ifdef DEBUG_MERGE_TYPES
   DOUT << "Derived new type: " << *ST << "\n";
@@ -872,7 +873,7 @@
   return ST;
 }
 
-StructType *StructType::get(const Type *type, ...) {
+StructType *StructType::get(LLVMContext &Context, const Type *type, ...) {
   va_list ap;
   std::vector<const llvm::Type*> StructFields;
   va_start(ap, type);
@@ -880,7 +881,7 @@
     StructFields.push_back(type);
     type = va_arg(ap, llvm::Type*);
   }
-  return llvm::StructType::get(StructFields);
+  return llvm::StructType::get(Context, StructFields);
 }
 
 bool StructType::isValidElementType(const Type *ElemTy) {
@@ -1146,11 +1147,13 @@
 //
 void StructType::refineAbstractType(const DerivedType *OldType,
                                     const Type *NewType) {
-  StructTypes->RefineAbstractType(this, OldType, NewType);
+  LLVMContextImpl *pImpl = OldType->getContext().pImpl;
+  pImpl->StructTypes.RefineAbstractType(this, OldType, NewType);
 }
 
 void StructType::typeBecameConcrete(const DerivedType *AbsTy) {
-  StructTypes->TypeBecameConcrete(this, AbsTy);
+  LLVMContextImpl *pImpl = AbsTy->getContext().pImpl;
+  pImpl->StructTypes.TypeBecameConcrete(this, AbsTy);
 }
 
 // refineAbstractType - Called when a contained type is found to be more

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

==============================================================================
--- llvm/trunk/tools/bugpoint/ExtractFunction.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExtractFunction.cpp Wed Aug  5 18:16:16 2009
@@ -186,7 +186,8 @@
     std::vector<Constant*> Elts;
     Elts.push_back(ConstantInt::get(Type::Int32Ty, TorList[i].second));
     Elts.push_back(TorList[i].first);
-    ArrayElts.push_back(ConstantStruct::get(Elts));
+    ArrayElts.push_back(ConstantStruct::get(
+                                        TorList[i].first->getContext(), Elts));
   }
   return ConstantArray::get(ArrayType::get(ArrayElts[0]->getType(), 
                                            ArrayElts.size()),

Modified: llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp?rev=78258&r1=78257&r2=78258&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/IntrinsicEmitter.cpp Wed Aug  5 18:16:16 2009
@@ -146,7 +146,7 @@
     OS << "IntegerType::get(" << BitWidth << ")";
   } else if (VT == MVT::Other) {
     // MVT::OtherVT is used to mean the empty struct type here.
-    OS << "StructType::get()";
+    OS << "StructType::get(Context)";
   } else if (VT == MVT::f32) {
     OS << "Type::FloatTy";
   } else if (VT == MVT::f64) {
@@ -177,7 +177,7 @@
     return;
   }
 
-  OS << "StructType::get(";
+  OS << "StructType::get(Context, ";
 
   for (std::vector<Record*>::const_iterator
          I = ArgTypes.begin(), E = ArgTypes.end(); I != E; ++I) {





More information about the llvm-commits mailing list