diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 | ||||
-rw-r--r-- | clang/test/CodeGen/fentry.c | 11 |
2 files changed, 15 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index 38c679abf6b..2f814a7165a 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -1016,10 +1016,12 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, // 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()); } diff --git a/clang/test/CodeGen/fentry.c b/clang/test/CodeGen/fentry.c index b9133184e4d..43586c45633 100644 --- a/clang/test/CodeGen/fentry.c +++ b/clang/test/CodeGen/fentry.c @@ -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"{{.*}} } |