[PATCH] D54507: [ThinLTO] Handle chains of aliases

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 11 13:32:03 PST 2018


pcc added a comment.

In D54507#1327487 <https://reviews.llvm.org/D54507#1327487>, @tejohnson wrote:

> In D54507#1327394 <https://reviews.llvm.org/D54507#1327394>, @pcc wrote:
>
> > Isn't this just a bug in promotion? It should probably internalize any non-prevailing aliases like lib/Linker does.
>
>
> Can you clarify? The summary doesn't contain any references to the intermediate aliasee so it looks completely unreferenced.


And indeed it isn't. The important thing to keep alive is the base object, which is what the code already does.

My first idea was that we would change the code in `convertToDeclaration` here:
http://llvm-cs.pcc.me.uk/lib/Transforms/IPO/FunctionImport.cpp#923
so that we would RAUW all alias references to point to the external and all non-alias references to point to the aliasee. But unfortunately it doesn't seem easy to implement "replace some uses with" on constants.

Probably the simplest fix is to make sure that each aliasee is canonicalized to point to the base object before calling `convertToDeclaration`. This seems pretty straightforward using `ConstantExpr::getWithOperands`. This also takes us one step closer to the canonical alias form we discussed last year: we would just need to apply the same canonicalization *before* writing the bitcode file.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54507/new/

https://reviews.llvm.org/D54507





More information about the llvm-commits mailing list