[Clang][Codegen] Add GNU function attribute 'no_profile' and lower it to noprofile
authorNick Desaulniers <ndesaulniers@google.com>
Fri, 18 Jun 2021 20:33:44 +0000 (13:33 -0700)
committerNick Desaulniers <ndesaulniers@google.com>
Fri, 18 Jun 2021 20:42:32 +0000 (13:42 -0700)
commit193e41c987127aad86d0380df83e67a85266f1f1
treefc220057bce78a4978c42220932ebd01fc9256cc
parentf7999e73caeff482a324ab0f9ac2fbeb99f8e3ec
[Clang][Codegen] Add GNU function attribute 'no_profile' and lower it to noprofile

noprofile IR attribute already exists to prevent profiling with PGO;
emit that when a function uses the newly added no_profile function
attribute.

The Linux kernel would like to avoid compiler generated code in
functions annotated with such attribute. We already respect this for
libcalls to fentry() and mcount().

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80223
Link: https://lore.kernel.org/lkml/CAKwvOdmPTi93n2L0_yQkrzLdmpxzrOR7zggSzonyaw2PGshApw@mail.gmail.com/
Reviewed By: MaskRay, void, phosek, aaron.ballman

Differential Revision: https://reviews.llvm.org/D104475
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/lib/CodeGen/CodeGenFunction.cpp
clang/test/CodeGen/no_profile.c [new file with mode: 0644]
clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/Sema/no_profile-attribute.c [new file with mode: 0644]