InjectTLIMappings fails to preserve the analysis result of GlobalsAA. Not preserving the analysis might affect benchmark performance. This change fixes this issue.
Details
Diff Detail
Event Timeline
LGTM thanks as discussed in D82063. Please let me know if you need someone to commit the change on your behalf.
I noticed that this change had a somewhat peculiar optimization impact: text size diffs There's some fairly large changes, but only for the ReleaseLTO -g case. Is there any obvious reason why that configuration would be affected, while others weren't?
Yes I think that's expected. As an additional data pointer, we have been seeing 4-8% runtime regressions without this patch in several SPEC benchmarks.
Without preserving it in InjectTLIMappings (which is requested by LoopVectorize), GlobalsAA is not available in LV. Without it, it will either result in code not being vectorized or vectorized with runtime checks (which means we have to keep both a copy of the vectorized and non-vectorized loop around). And GlobalsAA should be much more likely to deduce no alias with LTO, given the more complete pictures of globals.
Arguably, it might be even better to not schedule InjectTLIMappings via the pass manager, because of the subtle invalidation of other analysis requested by the same pass. But that's a potential follow-up I think.