[llvm-commits] CVS: llvm/lib/VMCore/Type.cpp
Chris Lattner
sabre at nondot.org
Fri Feb 9 14:24:29 PST 2007
Changes in directory llvm/lib/VMCore:
Type.cpp updated: 1.168 -> 1.169
---
Log message:
Fix clients like this:
delete ParseBytecodeFile(InputFilename, 0, &ErrorMessage);
llvm_shutdown();
delete ParseBytecodeFile(InputFilename, 0, &ErrorMessage);
The primitive type objects failed to ressurect themselves after shutdown, leading
to crashes in clients that used them after llvm_shutdown().
This solution isn't wonderful, because we clearly have static ctors. However,
the code it replaces was just as bad, so it's not a regression.
---
Diffs of the changes: (+15 -28)
Type.cpp | 43 +++++++++++++++----------------------------
1 files changed, 15 insertions(+), 28 deletions(-)
Index: llvm/lib/VMCore/Type.cpp
diff -u llvm/lib/VMCore/Type.cpp:1.168 llvm/lib/VMCore/Type.cpp:1.169
--- llvm/lib/VMCore/Type.cpp:1.168 Mon Feb 5 14:47:20 2007
+++ llvm/lib/VMCore/Type.cpp Fri Feb 9 16:24:04 2007
@@ -347,34 +347,21 @@
// Primitive 'Type' data
//===----------------------------------------------------------------------===//
-#define DeclarePrimType(TY, Str) \
- namespace { \
- struct VISIBILITY_HIDDEN TY##Type : public Type { \
- TY##Type() : Type(Str, Type::TY##TyID) {} \
- }; \
- } \
- static ManagedStatic<TY##Type> The##TY##Ty; \
- const Type *Type::TY##Ty = &*The##TY##Ty
-
-#define DeclareIntegerType(TY, BitWidth) \
- namespace { \
- struct VISIBILITY_HIDDEN TY##Type : public IntegerType { \
- TY##Type() : IntegerType(BitWidth) {} \
- }; \
- } \
- static ManagedStatic<TY##Type> The##TY##Ty; \
- const IntegerType *Type::TY##Ty = &*The##TY##Ty
-
-DeclarePrimType(Void, "void");
-DeclarePrimType(Float, "float");
-DeclarePrimType(Double, "double");
-DeclarePrimType(Label, "label");
-DeclareIntegerType(Int1, 1);
-DeclareIntegerType(Int8, 8);
-DeclareIntegerType(Int16, 16);
-DeclareIntegerType(Int32, 32);
-DeclareIntegerType(Int64, 64);
-#undef DeclarePrimType
+const Type *Type::VoidTy = new Type("void", Type::VoidTyID);
+const Type *Type::FloatTy = new Type("float", Type::FloatTyID);
+const Type *Type::DoubleTy = new Type("double", Type::DoubleTyID);
+const Type *Type::LabelTy = new Type("label", Type::LabelTyID);
+
+namespace {
+ struct BuiltinIntegerType : public IntegerType {
+ BuiltinIntegerType(unsigned W) : IntegerType(W) {}
+ };
+}
+const IntegerType *Type::Int1Ty = new BuiltinIntegerType(1);
+const IntegerType *Type::Int8Ty = new BuiltinIntegerType(8);
+const IntegerType *Type::Int16Ty = new BuiltinIntegerType(16);
+const IntegerType *Type::Int32Ty = new BuiltinIntegerType(32);
+const IntegerType *Type::Int64Ty = new BuiltinIntegerType(64);
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list