r326639 - Do not generate calls to fentry with __attribute__((no_instrument_function))
Manoj Gupta via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 2 15:52:44 PST 2018
Author: manojgupta
Date: Fri Mar 2 15:52:44 2018
New Revision: 326639
URL: http://llvm.org/viewvc/llvm-project?rev=326639&view=rev
Log:
Do not generate calls to fentry with __attribute__((no_instrument_function))
Summary:
Currently only calls to mcount were suppressed with
no_instrument_function attribute.
Linux kernel requires that calls to fentry should also not be
generated.
This is an extended fix for PR PR33515.
Reviewers: hfinkel, rengolin, srhines, rnk, rsmith, rjmccall, hans
Reviewed By: rjmccall
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D43995
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/test/CodeGen/fentry.c
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=326639&r1=326638&r2=326639&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Fri Mar 2 15:52:44 2018
@@ -1016,10 +1016,12 @@ void CodeGenFunction::StartFunction(Glob
// The attribute "counting-function" is set to mcount function name which is
// architecture dependent.
if (CGM.getCodeGenOpts().InstrumentForProfiling) {
- if (CGM.getCodeGenOpts().CallFEntry)
- Fn->addFnAttr("fentry-call", "true");
- else {
- if (!CurFuncDecl || !CurFuncDecl->hasAttr<NoInstrumentFunctionAttr>()) {
+ // Calls to fentry/mcount should not be generated if function has
+ // the no_instrument_function attribute.
+ if (!CurFuncDecl || !CurFuncDecl->hasAttr<NoInstrumentFunctionAttr>()) {
+ if (CGM.getCodeGenOpts().CallFEntry)
+ Fn->addFnAttr("fentry-call", "true");
+ else {
Fn->addFnAttr("instrument-function-entry-inlined",
getTarget().getMCountName());
}
Modified: cfe/trunk/test/CodeGen/fentry.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/fentry.c?rev=326639&r1=326638&r2=326639&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/fentry.c (original)
+++ cfe/trunk/test/CodeGen/fentry.c Fri Mar 2 15:52:44 2018
@@ -7,5 +7,12 @@ int foo(void) {
return 0;
}
-//CHECK: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"="true"{{.*}} }
-//NOPG-NOT: attributes #{{[0-9]+}} = { {{.*}}"fentry-call"{{.*}} }
+int __attribute__((no_instrument_function)) no_instrument(void) {
+ return foo();
+}
+
+//CHECK: attributes #0 = { {{.*}}"fentry-call"="true"{{.*}} }
+//CHECK: attributes #1 = { {{.*}} }
+//CHECK-NOT: attributes #1 = { {{.*}}"fentry-call"="true"{{.*}} }
+//NOPG-NOT: attributes #0 = { {{.*}}"fentry-call"{{.*}} }
+//NOPG-NOT: attributes #1 = { {{.*}}"fentry-call"{{.*}} }
More information about the cfe-commits
mailing list