Share ConstPoolPointer elements correctly
authorChris Lattner <sabre@nondot.org>
Wed, 3 Oct 2001 15:38:36 +0000 (15:38 +0000)
committerChris Lattner <sabre@nondot.org>
Wed, 3 Oct 2001 15:38:36 +0000 (15:38 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@706 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/ConstPoolVals.h
include/llvm/GlobalVariable.h

index 68dd0a3acfa1978767c8e145d5afe54214991e6a..235ab12f26361b0f0db3d50e7545fa94fd329aac 100644 (file)
@@ -217,10 +217,7 @@ protected:
   ConstPoolPointer(const PointerType *T);
   ~ConstPoolPointer() {}
 public:
-  static ConstPoolPointer *getNullPointer(const PointerType *T) {
-    // FIXME: These should all be shared!
-    return new ConstPoolPointer(T);
-  }
+  static ConstPoolPointer *getNull(const PointerType *T);
 
   virtual string getStrValue() const;
 };
index 4256ffee940ad07f0ef085e75fd7376ce433e44d..6d6de1414665767e49af7ff1ca4f7ac2a039ba64 100644 (file)
@@ -46,7 +46,14 @@ public:
   inline ConstPoolVal *getInitializer() {
     return (ConstPoolVal*)Operands[0].get();
   }
-  inline void setInitializer(ConstPoolVal *CPV) { Operands[0] = (Value*)CPV; }
+  inline void setInitializer(ConstPoolVal *CPV) {
+    if (CPV == 0) {
+      if (hasInitializer()) Operands.pop_back();
+    } else {
+      if (!hasInitializer()) Operands.push_back(Use(0, this));
+      Operands[0] = (Value*)CPV;
+    }
+  }
 
 
   // If the value is a global constant, its value is immutable throughout the