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

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 7 10:31:39 PDT 2018


john.brawn added a comment.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D51637





More information about the llvm-commits mailing list