Motivation:
int test(int x, int y) { int r = 0; [[clang::always_inline]] r += foo(x, y); // force compiler to inline this function here return r; }
In 2018, @kuhar proposed "Introduce per-callsite inline intrinsics" in https://reviews.llvm.org/D51200 to solve this motivation case (and many others).
This patch solves this problem with call site attribute. "noinline" statement attribute already landed in D119061. Also, some LLVM Inliner fixes landed so call site attribute is stronger than function attribute.
We should document more clearly (perhaps just with an example) what "contains calls" means. e.g.,
Do we attempt to inline everything? Just the simple calls with no expressions? Just the call to foo()?
It's probably also worth reminding people that a declaration statement, which is a statement, is not a statement that can have an attribute associated with it (the attribute applies to the declaration, not the statement in that case). So this won't work, and it's not a bug:
(If this case matters to you, you could have the attribute also apply to VarDecl or some subset of that.)