From 193e41c987127aad86d0380df83e67a85266f1f1 Mon Sep 17 00:00:00 2001 From: Nick Desaulniers Date: Fri, 18 Jun 2021 13:33:44 -0700 Subject: [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/lib/CodeGen/CodeGenFunction.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp') diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 518305e..97288d0 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -893,6 +893,9 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (D && D->hasAttr()) Fn->addFnAttr("cfi-canonical-jump-table"); + if (D && D->hasAttr()) + Fn->addFnAttr(llvm::Attribute::NoProfile); + if (getLangOpts().OpenCL) { // Add metadata for a kernel function. if (const FunctionDecl *FD = dyn_cast_or_null(D)) -- cgit v1.1