[patch][PR10367] Fix the design of GlobalAlias

Rafael EspĂ­ndola rafael.espindola at gmail.com
Mon May 12 21:52:51 PDT 2014


These patches change the design of GlobalAlias so that it doesn't take
a ConstantExpr anymore.

First, sorry for such large patches, but I am out of ideas on how to
split them further. The patches are:

* llvm-1.patch: Split GlobalValue into GlobalValue and GlobalObject.
That allows us statically accept a Function or a GlobalVariable, but
not an alias. This is already a cleanup by itself IMHO, but the main
reason is that it gives a lot more confidence that the next patch is
doing the right thing.

* clang-1.patch is just an update for the api change.

These two patches are already fairly mature. The next two still need
polishing and some bug fixes, but it should already be possible to
provide feedback on some high level issues. In particular:

To avoid changing all alias related tests in these patches, I kept the
common syntax

@foo = alias i32* @bar

to mean the same as now. The more general case when the types don't
match is written

@foo = alias i16, i32* @bar.

Note that GlobalAlias now behaves a bit more like GlobalVariable. We
know that its type is always a pointer, so we omit the '*'.

For the bitcode, a nice surprise is that we were writing both
identical types already, so the format change is minimal. Auto upgrade
is handled by looking through the casts and no new fields are needed
for now. New bitcode will simply have different types for Alias and
Aliassee.

One last interesting point in the patch is that replaceAllUsesWith
becomes smart enough to avoid putting a ConstantExpr in the aliassee.
This seems better than checking and updating every caller.

What is still not implemented (and will be done in a followup patch)
is to add an offset field, so that we can represent an alias that is
inside another symbol.

Cheers,
Rafael
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-1.patch
Type: application/octet-stream
Size: 1460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140513/c84b2fdc/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: clang-2.patch
Type: application/octet-stream
Size: 16206 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140513/c84b2fdc/attachment-0001.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-1.patch
Type: application/octet-stream
Size: 18168 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140513/c84b2fdc/attachment-0002.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-2.patch
Type: application/octet-stream
Size: 47320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140513/c84b2fdc/attachment-0003.obj>


More information about the llvm-commits mailing list