[all-commits] [llvm/llvm-project] 223b82: [Clang] noinline call site attribute
Dávid Bolvanský via All-commits
all-commits at lists.llvm.org
Mon Feb 28 12:21:39 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 223b8240223541d3feb0c96b7f9bac114cd72f46
https://github.com/llvm/llvm-project/commit/223b8240223541d3feb0c96b7f9bac114cd72f46
Author: Dávid Bolvanský <david.bolvansky at gmail.com>
Date: 2022-02-28 (Mon, 28 Feb 2022)
Changed paths:
M clang/include/clang/Basic/Attr.td
M clang/include/clang/Basic/AttrDocs.td
M clang/include/clang/Basic/DiagnosticSemaKinds.td
M clang/lib/CodeGen/CGCall.cpp
M clang/lib/CodeGen/CGStmt.cpp
M clang/lib/CodeGen/CodeGenFunction.h
M clang/lib/Sema/SemaStmtAttr.cpp
A clang/test/CodeGen/attr-noinline.cpp
M clang/test/Parser/stmt-attributes.c
M clang/test/Sema/attr-noinline.c
A clang/test/Sema/attr-noinline.cpp
Log Message:
-----------
[Clang] noinline call site attribute
Motivation:
```
int foo(int x, int y) { // any compiler will happily inline this function
return x / y;
}
int test(int x, int y) {
int r = 0;
[[clang::noinline]] r += foo(x, y); // for some reason we don't want any inlining 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. The implementation is "smaller" wrt approach which uses new intrinsics and thanks to https://reviews.llvm.org/D79121 (Add nomerge statement attribute to clang), we have got some basic infrastructure to deal with attrs on statements with call expressions.
GCC devs are more inclined to call attribute solution as well, as builtins are problematic for them - https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104187. But they have no patch proposal yet so.. We have free hands here.
If this approach makes sense, next future steps would be support for call site attributes for always_inline / flatten.
Reviewed By: aaron.ballman, kuhar
Differential Revision: https://reviews.llvm.org/D119061
More information about the All-commits
mailing list