aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-10-03 15:38:36 +0000
committerChris Lattner <sabre@nondot.org>2001-10-03 15:38:36 +0000
commit7323c69a31912b352e7eab26bbd98a422b262f95 (patch)
tree80139db2f4f7a8edeb6977bdbe058912eacf60ed
parenta861f966fd64a5745b1fe4ad19db97f4a9887b59 (diff)
Share ConstPoolPointer elements correctly
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@706 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/ConstPoolVals.h5
-rw-r--r--include/llvm/GlobalVariable.h9
2 files changed, 9 insertions, 5 deletions
diff --git a/include/llvm/ConstPoolVals.h b/include/llvm/ConstPoolVals.h
index 68dd0a3acf..235ab12f26 100644
--- a/include/llvm/ConstPoolVals.h
+++ b/include/llvm/ConstPoolVals.h
@@ -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;
};
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index 4256ffee94..6d6de14146 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -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