[PATCH] D51637: [AsmPrinter] GlobalAlias with non-zero size and public linkage ends up with wrong size, PR38794

Daphne Pfister via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 7 10:50:02 PDT 2018


daphnediane added a comment.

In https://reviews.llvm.org/D51637#1227528, @john.brawn wrote:

> The reason for the default of not emitting a size (which ends up having the effect of the alias having the same size as the aliasee) is for compatibility with gcc where if you have
>
>   int var1[10] = {1};
>   extern int var2 __attribute__((alias("var1")));
>
>
> you end up with var2 being a symbol with the same size as var1, even though it's a smaller type.
>
> So I think checking for the size being smaller is incorrect, or rather it would mean we would be inconsistent with gcc which we generally want to avoid unless there's a good reason, but the change to emit the size when the alias has an offset (i.e. the change in how we decide BaseObject) looks OK. It does make me wonder though if perhaps it would be better to explicitly distinguish at the IR level between alias as "this name is another name for that other thing", which we want for the alias variable attribute and so don't want to emit a size; and "this name refers to a subpart of that other thing", which we want for aliases generated by GlobalMerge and so do want to emit a size.


Note I'm using LLVM IR for a different language not C/C++ and need to be able to generate partial symbols of different sizes. The programming language I'm porting has a concept of combined segments where some parts of the segments are public and that the layout between them is well defined within a single module but only visible by symbol name to external modules.


Repository:
  rL LLVM

https://reviews.llvm.org/D51637





More information about the llvm-commits mailing list