[LLVMdev] ConstantPointerRef Changes [important info]
sabre at nondot.org
Sun Jul 18 03:26:49 PDT 2004
On Sat, 17 Jul 2004, Reid Spencer wrote:
> The long awaited conclusion of bug 122 (VMCore cleanups) is very near. I
> have just committed all the changes to rid LLVM of the ConstantPointerRef
> abomination. This class no longer exists. Just use GlobalValue,
> GlobalVariable or Function directly.
Actually, PR122 is now closed, which is a HUGE deal. If you're
interested, I suggest taking a look at some of the stuff in the bug trail
to see what Reid went through: http://llvm.cs.uiuc.edu/PR122 :)
> The changes pass 100% of Feature and Regression tests.
> Two minor discrepancies against the Programs tests were detected but these
> were attributed to either the test program (changes committed) or the test
All tests pass on X86. By tommorow we should get nightly tester data for
other platforms, but I don't anticipate major trouble.
What Reid didn't do is explain what this change DOES. :) Here's what it
did and what you need to know if you are maintaining code outside of CVS:
1. The GlobalValue class now derives from the Constant class. This means
the two classes that derive from GlobalValue (Function & GlobalVariable)
are now constants.
2. Because of #1, isa/dyn_cast/etc functions on a global value will return
true for isa<Constant>. This can break your code, so you should be
aware of it.
3. Because of #1, the ConstantPointerRef class is now obsolete and is
gone. ConstantPointerRef used to be a bridge between the GlobalValue
class and the Constant classes (which allowed you to treat a GV as a
constant). Because global values ARE constants, you can just use the
GV directly now. If you use the ConstantPointerRef class in your code,
this will break your code, just use the GlobalValue where you used CPR.
For clarity, I will point out what it means for global values to be
constants. :) In particular, the "value" of a global value is really the
address of the mentioned object. For example, if you have a program like
%G = global int 4
load int* %G
The operand to the load *is* the GlobalVariable for %G.
Because the address of a global is a link-time constant, it makes sense
for the GlobalValue class to derive from Constant.
Anyways, if you have any questions or if your code is broken somehow,
please let us know and we'll try to help. Also, HUGE thanks to Reid for
taking charge and getting this bug fixed. This is a major cleanup for
LLVM and allows the system make more sense.
More information about the llvm-dev