[llvm-commits] CVS: llvm/include/llvm/Constants.h

Chris Lattner sabre at nondot.org
Mon Feb 19 22:11:58 PST 2007



Changes in directory llvm/include/llvm:

Constants.h updated: 1.129 -> 1.130
---
Log message:

Make ConstantInt::getTrue/getFalse be llvm_shutdown safe.


---
Diffs of the changes:  (+8 -6)

 Constants.h |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)


Index: llvm/include/llvm/Constants.h
diff -u llvm/include/llvm/Constants.h:1.129 llvm/include/llvm/Constants.h:1.130
--- llvm/include/llvm/Constants.h:1.129	Mon Feb 19 23:55:46 2007
+++ llvm/include/llvm/Constants.h	Tue Feb 20 00:11:36 2007
@@ -40,6 +40,7 @@
 /// represents both boolean and integral constants.
 /// @brief Class for constant integers.
 class ConstantInt : public Constant {
+  static ConstantInt *TheTrueVal, *TheFalseVal;
 protected:
   uint64_t Val;
 protected:
@@ -73,14 +74,12 @@
 
   /// getTrue/getFalse - Return the singleton true/false values.
   static inline ConstantInt *getTrue() {
-    static ConstantInt *T = 0;
-    if (T) return T;
-    return T = new ConstantInt(Type::Int1Ty, 1);
+    if (TheTrueVal) return TheTrueVal;
+    return CreateTrueFalseVals(true);
   }
   static inline ConstantInt *getFalse() {
-    static ConstantInt *F = 0;
-    if (F) return F;
-    return F = new ConstantInt(Type::Int1Ty, 0);
+    if (TheFalseVal) return TheFalseVal;
+    return CreateTrueFalseVals(false);
   }
 
   /// Return a ConstantInt with the specified value for the specified type. The
@@ -165,6 +164,9 @@
   static bool classof(const Value *V) {
     return V->getValueType() == ConstantIntVal;
   }
+  static void ResetTrueFalse() { TheTrueVal = TheFalseVal = 0; }
+private:
+  static ConstantInt *CreateTrueFalseVals(bool WhichOne);
 };
 
 






More information about the llvm-commits mailing list