[PATCH] D49362: [ThinLTO] Compute constant references

Eugene Leviant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 17 13:23:36 PDT 2018


evgeny777 added a comment.

> That's true. Actually, thinking more about the above example - presumably your global analysis on these new const bits would have to look at the references on global variables, and treat that as a non-const ref and basically mark the referenced GUID as non-const, to represent the address as escaping, right?

For now I implemented constant propagation in ModuleSummaryIndex which works in three steps:

1. Set `Constant = true` in all `GlobalVarKind` GVS and to `false` in all others
2. Iterate through all live function summaries and propagate `Constant = false` over each non-constant reference
3. Iterate through all live `GlobalVarKind` summaries with `Constant = false` propagate it over all references to other global variables using a work queue.

Also I added few small tweaks to internalize global w/o external usage when `Constant` is `true` and produce a local copy during import phase. 
I didn't have chance to test it on something real though (just small toy example).


https://reviews.llvm.org/D49362





More information about the llvm-commits mailing list