[Clang] always_inline statement attribute
authorDávid Bolvanský <david.bolvansky@gmail.com>
Mon, 14 Mar 2022 20:44:59 +0000 (21:44 +0100)
committerDávid Bolvanský <david.bolvansky@gmail.com>
Mon, 14 Mar 2022 20:45:31 +0000 (21:45 +0100)
commit003c0b9307bc52605fc93c599dfe36849839ded5
treecc4feb18b91f00e3ba5de63c783d51a948d0da83
parent84af90336fed36f7dfdc468ded39236f32bbb82e
[Clang] always_inline statement  attribute

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.

Reviewed By: aaron.ballman

Differential Revision: https://reviews.llvm.org/D120717
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CodeGenFunction.h
clang/lib/Sema/SemaStmtAttr.cpp
clang/test/CodeGen/attr-alwaysinline.cpp [new file with mode: 0644]
clang/test/Parser/objc-implementation-attrs.m
clang/test/Sema/attr-alwaysinline.cpp [new file with mode: 0644]