[llvm-commits] [cfe-commits] [PATCH][RFC] PR10367: don't allow GlobalAlias's aliasee to be an arbitrary Constant

Jay Foad jay.foad at gmail.com
Thu Aug 4 04:34:29 PDT 2011


On 1 August 2011 10:34, Duncan Sands <baldrick at free.fr> wrote:
>> It sounds like you are arguing against PR10367:
>>
>>   "Instead, the initializer of a
>> GlobalAlias should be required to be a GlobalValue, but the type of the
>> source
>> and dest of the alias should not be required to be the same, they should
>> just
>> be completely decoupled."
>>
>> ... not against my implementation of it.
>
> that's correct.  It seemed like a good idea at first, but once you see that
> RAUW means you need to retain bitcasts and GEPs as alias operands, 99% of
> the
> interest of the idea goes away in my opinion.
>
> That said, your patch simplifies the way global aliases are manipulated by
> users, right?  Do you think you can keep the ease-of-use improvements while
> discarding the IR modification parts?

OK, how about this then? It changes setAliasee/getAliasee to
take/return a GlobalValue instead of a Constant, but setAliasee
creates a bitcast if necessary to ensure that the type of the
GlobalAlias always matches the type of its operand. Thus, setAliasee
is the "helper function for front ends" that you asked for up-thread.

The changes elsewhere are mostly replacing:

getAliasedGlobal() with getAliasee()

and, in code that really wants to deal with the raw operands (like
reading/writing bitcode/ll files, cloning modules etc):

getAliasee() with getOperand(0)
setAliasee(x) with setOperand(0, x)

(In ModuleLinker::linkAliasBodies() I'm using getAliasee/setAliasee to
strip off and recreate bitcasts as needed, in the hope that, in some
cases, we won't need to create a new bitcast at all. But I'm not at
all sure about this.)

Tested with "make check-all" and a clang self-hosted "make all
check-all". OK to commit? I don't think any changes are needed in
dragonegg or llvm-gcc-4.2.

Thanks,
Jay.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-globalalias-2.diff
Type: text/x-patch
Size: 17323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20110804/1af0ba38/attachment.bin>


More information about the llvm-commits mailing list