Page MenuHomePhabricator

[inliner] Apply nomerge attribute to all call sites inside inlined function.
AbandonedPublic

Authored by zequanwu on Dec 3 2020, 5:29 PM.

Details

Summary

[[clang::nomerge]] statement attribute stops optimizer from merging multiple calls into one. When inlining happends, the attribute got lost, which is not desired.

Diff Detail

Event Timeline

zequanwu created this revision.Dec 3 2020, 5:29 PM
zequanwu requested review of this revision.Dec 3 2020, 5:29 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 3 2020, 5:29 PM
rnk resigned from this revision.Dec 7 2020, 12:24 PM
rnk added a reviewer: asbirlea.
rnk added a reviewer: aeubanks.

Let's get input from someone who has made recent inliner changes. Arthur or Alina, does this change make sense to you?

mtrofin accepted this revision.Dec 7 2020, 1:56 PM

lgtm

This revision is now accepted and ready to land.Dec 7 2020, 1:56 PM

According to: https://clang.llvm.org/docs/AttributeReference.html#nomerge, the existance of the attribute should prevent call site merging, so the change makes sense.
However, in the test example then, if there was branching and two @f calls inside @bar, it would be correct to merge the @f call sites (no attribute preventing that inside) when processing @bar. But after inlining, that's no longer allowed if the attribute is distributed to all callsites inside the function.
This is a contradiction that needs clarification from folks more familiar with the Inliner.

According to: https://clang.llvm.org/docs/AttributeReference.html#nomerge, the existance of the attribute should prevent call site merging, so the change makes sense.
However, in the test example then, if there was branching and two @f calls inside @bar, it would be correct to merge the @f call sites (no attribute preventing that inside) when processing @bar. But after inlining, that's no longer allowed if the attribute is distributed to all callsites inside the function.
This is a contradiction that needs clarification from folks more familiar with the Inliner.

Good point. I didn't consider this before.

I think I should adding a new no-merge as a function attribute which prevent all the function call from merging. Why not making nomerge as both statement attribute and function attribute? Currently, it's not allowed to do so in Attr.td.

zequanwu abandoned this revision.Dec 11 2020, 12:49 PM