summaryrefslogtreecommitdiffstats
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
commit595085246918301df97a0176c63dcf406a06717b (patch)
tree9bcdbc38bd119bbcb62f6ee9c4b3d9462c2f2362
parentf208dcfa2b7c5debbb0b3094033d35962c73ed94 (diff)
downloadbcm5719-llvm-595085246918301df97a0176c63dcf406a06717b.tar.gz
bcm5719-llvm-595085246918301df97a0176c63dcf406a06717b.zip
Share ConstPoolPointer elements correctly
llvm-svn: 706
-rw-r--r--llvm/include/llvm/ConstPoolVals.h5
-rw-r--r--llvm/include/llvm/GlobalVariable.h9
2 files changed, 9 insertions, 5 deletions
diff --git a/llvm/include/llvm/ConstPoolVals.h b/llvm/include/llvm/ConstPoolVals.h
index 68dd0a3acfa..235ab12f263 100644
--- a/llvm/include/llvm/ConstPoolVals.h
+++ b/llvm/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/llvm/include/llvm/GlobalVariable.h b/llvm/include/llvm/GlobalVariable.h
index 4256ffee940..6d6de141466 100644
--- a/llvm/include/llvm/GlobalVariable.h
+++ b/llvm/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
OpenPOWER on IntegriCloud