[LLVMdev] Removal of ConstantExprs

Matthijs Kooijman matthijs at stdin.nl
Tue Jun 24 09:24:13 PDT 2008


Hi All,

I'm having a bit of trouble with ConstantExprs currently. In particular, a
global variable A is bitcasted and used in the initializer of another global
variable B (as a struct element).

B is unused, so it gets whacked and its initializer gets set to NULL. This
succesfully reduces the usecount of the bitcast to 0, but the bitcast itself
does not get removed then. This means that further on, other transformations
fail because A is still used by the bitcast. 

Now I know that there is GlobalValue::removeDeadConstantUsers which the
transformation could be calling, but shouldn't that be arranged automatically?
Also, in this case I'm using a bitcast of A, but what if this was a bitcast of
a gep of a A? In this case, removeDeadConstantUsers on A would not remove
anything, since the GEP is still used by the bitcast.

AFAICS this kind of thing should be triggered when the use is removed (ie,
when the initializer is set to 0). I was however unable to find the
implementation of Use::set(), which seems to be closely related. Does anyone
know where it is (grepping for "set" didn't prove so fruitful...)?

Gr.

Matthijs
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20080624/dd752a99/attachment.sig>


More information about the llvm-dev mailing list