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
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
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits