[[clang::nomerge]] statement attribute stops optimizer from merging multiple calls into one. When inlining happends, the attribute got lost, which is not desired.
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.