nickdesaulniers updated this revision to Diff 351960. nickdesaulniers added a comment.
- rename new test from fprofile-generate.c to fprofile-instrument.c; -fprofile-generate is the driver opt, -fprofile-instrument is the frontend opt. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104253/new/ https://reviews.llvm.org/D104253 Files: clang/lib/CodeGen/CodeGenFunction.cpp clang/test/CodeGen/fprofile-instrument.c Index: clang/test/CodeGen/fprofile-instrument.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fprofile-instrument.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +int g(int); + +int __attribute__((__no_instrument_function__)) +__attribute__((no_instrument_function)) +no_instr(int a) { +// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]] + int sum = 0; + for (int i = 0; i < a; i++) + sum += g(i); + return sum; +} + +int instr(int a) { +// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]] + int sum = 0; + for (int i = 0; i < a; i++) + sum += g(i); + return sum; +} +// CHECK: attributes [[ATTR]] = {{.*}} noprofile +// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -893,6 +893,9 @@ if (D && D->hasAttr<CFICanonicalJumpTableAttr>()) Fn->addFnAttr("cfi-canonical-jump-table"); + if (D && D->hasAttr<NoInstrumentFunctionAttr>()) + Fn->addFnAttr(llvm::Attribute::NoProfile); + if (getLangOpts().OpenCL) { // Add metadata for a kernel function. if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
Index: clang/test/CodeGen/fprofile-instrument.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fprofile-instrument.c @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +int g(int); + +int __attribute__((__no_instrument_function__)) +__attribute__((no_instrument_function)) +no_instr(int a) { +// CHECK: define {{.*}} i32 @no_instr(i32 %a) [[ATTR:#[0-9]+]] + int sum = 0; + for (int i = 0; i < a; i++) + sum += g(i); + return sum; +} + +int instr(int a) { +// CHECK: define {{.*}} i32 @instr(i32 %a) [[ATTR2:#[0-9]+]] + int sum = 0; + for (int i = 0; i < a; i++) + sum += g(i); + return sum; +} +// CHECK: attributes [[ATTR]] = {{.*}} noprofile +// CHECK-NOT: attributes [[ATTR2]] = {{.*}} noprofile Index: clang/lib/CodeGen/CodeGenFunction.cpp =================================================================== --- clang/lib/CodeGen/CodeGenFunction.cpp +++ clang/lib/CodeGen/CodeGenFunction.cpp @@ -893,6 +893,9 @@ if (D && D->hasAttr<CFICanonicalJumpTableAttr>()) Fn->addFnAttr("cfi-canonical-jump-table"); + if (D && D->hasAttr<NoInstrumentFunctionAttr>()) + Fn->addFnAttr(llvm::Attribute::NoProfile); + if (getLangOpts().OpenCL) { // Add metadata for a kernel function. if (const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(D))
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits