[PATCH] D129413: [InstrProf] Allow compiler generated functions in SCL

Ellis Hoag via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 11 10:32:39 PDT 2022


ellis created this revision.
Herald added a project: All.
ellis retitled this revision from "[instrprof] Allow compiler generated functions in SCL" to "[InstrProf] Allow compiler generated functions in SCL".
ellis edited the summary of this revision.
ellis added reviewers: kyulee, phosek.
ellis published this revision for review.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Allow compiler generated functions like `__clang_call_terminate` to be
blocked in the special case list (SCL) passed by the `-fprofile-list=` option.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129413

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/profile-filter-compiler-generated.cpp


Index: clang/test/CodeGen/profile-filter-compiler-generated.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGen/profile-filter-compiler-generated.cpp
@@ -0,0 +1,9 @@
+// RUN: echo "!fun:__clang_call_terminate" > %t.list
+// RUN: %clang -fprofile-generate -fprofile-list=%t.list -Wno-exceptions -emit-llvm -S %s -o - | FileCheck %s
+
+// CHECK-NOT: noprofile
+// CHECK-LABEL: define {{.*}} i32 @_Z3foov()
+int foo() noexcept { throw 0; }
+
+// CHECK: noprofile
+// CHECK-LABEL: define {{.*}} void @__clang_call_terminate(
Index: clang/lib/CodeGen/CodeGenModule.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3891,6 +3891,10 @@
     F->addFnAttrs(B);
   }
 
+  if (getCodeGenOpts().getProfileInstr() != CodeGenOptions::ProfileNone)
+    if (isProfileInstrExcluded(F, SourceLocation()))
+      F->addFnAttr(llvm::Attribute::NoProfile);
+
   if (!DontDefer) {
     // All MSVC dtors other than the base dtor are linkonce_odr and delegate to
     // each other bottoming out with the base dtor.  Therefore we emit non-base


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129413.443398.patch
Type: text/x-patch
Size: 1184 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220711/deb764f2/attachment.bin>


More information about the cfe-commits mailing list