[patch][pr10367] Add support for offsets in GlobalAlias

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue May 20 19:03:47 PDT 2014


On 20 May 2014 18:47, Reid Kleckner <rnk at google.com> wrote:
> So, it's a bit late, but why *exactly* is it better to use an offset than a
> constant GEP?
>
> I remember asking this question before, but I don't remember the answer.  I
> can't find it in my inbox either.

A GEP is far more general. In particular:

* We cannot easily constrain it to point to a GlobalObject. We can
have the verifier check that, but that is a far cry from the static
types we have now.
* The value is not just an integer. Given that ConstantExpr can nest,
one can write the most amusing "constants", including trapping ones.
* We can again impose restrictions on the verifier, but it then makes
it harder to write things like rauw that enforce those constrains as
they have to walk up to see if they are replacing something plugged
into a GlobalAlias.

For a long while GlobalAlias had very little relation to what object
files can actually represent, which is my main motivation for fixing
pr10367 before we get more widespread uses (windows RTTI, gcc style
destructor comdats, etc).

Cheers,
Rafael



More information about the llvm-commits mailing list