nickdesaulniers updated this revision to Diff 352844. nickdesaulniers marked 3 inline comments as done. nickdesaulniers added a comment.
- fix td files and test CHECKs Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D104475/new/ https://reviews.llvm.org/D104475 Files: clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/lib/CodeGen/CodeGenFunction.cpp clang/test/CodeGen/fprofile.c clang/test/Misc/pragma-attribute-supported-attributes-list.test Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test =================================================================== --- clang/test/Misc/pragma-attribute-supported-attributes-list.test +++ clang/test/Misc/pragma-attribute-supported-attributes-list.test @@ -99,6 +99,7 @@ // CHECK-NEXT: NoMerge (SubjectMatchRule_function) // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function) // CHECK-NEXT: NoMips16 (SubjectMatchRule_function) +// CHECK-NEXT: NoProfileFunction (SubjectMatchRule_function) // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global) // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, SubjectMatchRule_variable_is_global) // CHECK-NEXT: NoSpeculativeLoadHardening (SubjectMatchRule_function, SubjectMatchRule_objc_method) Index: clang/test/CodeGen/fprofile.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fprofile.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fprofile-instrument=csllvm -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fprofile-instrument=clang -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fprofile-arcs -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +int g(int); + +void __attribute__((no_profile)) no_instr() { +// CHECK: define {{.*}} void @no_instr() [[ATTR:#[0-9]+]] +} + +void instr(void) { +// CHECK: define {{.*}} void @instr() [[ATTR2:#[0-9]+]] +} +// CHECK: attributes [[ATTR]] = {{.*}} noprofile +// CHECK: attributes [[ATTR2]] = { +// CHECK-NOT: noprofile +// CHECK: } 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<NoProfileFunctionAttr>()) + 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/include/clang/Basic/AttrDocs.td =================================================================== --- clang/include/clang/Basic/AttrDocs.td +++ clang/include/clang/Basic/AttrDocs.td @@ -2559,6 +2559,17 @@ }]; } +def NoProfileDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the ``no_profile`` attribute on a function declaration to denote that the +compiler should not instrument the function with profile related +instrumentation, such as via the +``-fprofile-generate`` / ``-fprofile-instr-generate`` / +``-fcs-profile-generate`` / ``-fprofile-arcs`` flags. +}]; +} + def NoSanitizeDocs : Documentation { let Category = DocCatFunction; let Content = [{ Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -1970,6 +1970,13 @@ let SimpleHandler = 1; } +def NoProfileFunction : InheritableAttr { + let Spellings = [Clang<"no_profile">]; + let Subjects = SubjectList<[Function]>; + let Documentation = [NoProfileDocs]; + let SimpleHandler = 1; +} + def NotTailCalled : InheritableAttr { let Spellings = [Clang<"not_tail_called">]; let Subjects = SubjectList<[Function]>;
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test =================================================================== --- clang/test/Misc/pragma-attribute-supported-attributes-list.test +++ clang/test/Misc/pragma-attribute-supported-attributes-list.test @@ -99,6 +99,7 @@ // CHECK-NEXT: NoMerge (SubjectMatchRule_function) // CHECK-NEXT: NoMicroMips (SubjectMatchRule_function) // CHECK-NEXT: NoMips16 (SubjectMatchRule_function) +// CHECK-NEXT: NoProfileFunction (SubjectMatchRule_function) // CHECK-NEXT: NoSanitize (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_variable_is_global) // CHECK-NEXT: NoSanitizeSpecific (SubjectMatchRule_function, SubjectMatchRule_variable_is_global) // CHECK-NEXT: NoSpeculativeLoadHardening (SubjectMatchRule_function, SubjectMatchRule_objc_method) Index: clang/test/CodeGen/fprofile.c =================================================================== --- /dev/null +++ clang/test/CodeGen/fprofile.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -fprofile-instrument=llvm -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fprofile-instrument=csllvm -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fprofile-instrument=clang -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -fprofile-arcs -disable-llvm-passes \ +// RUN: -emit-llvm -o - %s | FileCheck %s +int g(int); + +void __attribute__((no_profile)) no_instr() { +// CHECK: define {{.*}} void @no_instr() [[ATTR:#[0-9]+]] +} + +void instr(void) { +// CHECK: define {{.*}} void @instr() [[ATTR2:#[0-9]+]] +} +// CHECK: attributes [[ATTR]] = {{.*}} noprofile +// CHECK: attributes [[ATTR2]] = { +// CHECK-NOT: noprofile +// CHECK: } 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<NoProfileFunctionAttr>()) + 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/include/clang/Basic/AttrDocs.td =================================================================== --- clang/include/clang/Basic/AttrDocs.td +++ clang/include/clang/Basic/AttrDocs.td @@ -2559,6 +2559,17 @@ }]; } +def NoProfileDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the ``no_profile`` attribute on a function declaration to denote that the +compiler should not instrument the function with profile related +instrumentation, such as via the +``-fprofile-generate`` / ``-fprofile-instr-generate`` / +``-fcs-profile-generate`` / ``-fprofile-arcs`` flags. +}]; +} + def NoSanitizeDocs : Documentation { let Category = DocCatFunction; let Content = [{ Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -1970,6 +1970,13 @@ let SimpleHandler = 1; } +def NoProfileFunction : InheritableAttr { + let Spellings = [Clang<"no_profile">]; + let Subjects = SubjectList<[Function]>; + let Documentation = [NoProfileDocs]; + let SimpleHandler = 1; +} + def NotTailCalled : InheritableAttr { let Spellings = [Clang<"not_tail_called">]; let Subjects = SubjectList<[Function]>;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits