This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG70248bfdea6c: [Clang] Implement function attribute nouwtable (authored by ychen).
Changed prior to commit: https://reviews.llvm.org/D132592?vs=456403&id=456433#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D132592/new/ https://reviews.llvm.org/D132592 Files: clang/docs/ReleaseNotes.rst clang/include/clang/Basic/Attr.td clang/include/clang/Basic/AttrDocs.td clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGen/attr-nouwtable.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 @@ -115,6 +115,7 @@ // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function) // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function) // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType) +// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType) // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function) // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_variable_is_parameter) Index: clang/test/CodeGen/attr-nouwtable.c =================================================================== --- /dev/null +++ clang/test/CodeGen/attr-nouwtable.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -funwind-tables=2 -S -emit-llvm %s -o - | FileCheck %s + +__attribute__((nouwtable)) +int test1(void) { return 0; } + +// CHECK: @test1{{.*}}[[ATTR1:#[0-9]+]] +// CHECK: attributes [[ATTR1]] = { +// CHECK-NOT: uwtable +// CHECK: } Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -1963,7 +1963,7 @@ llvm::Function *F) { llvm::AttrBuilder B(F->getContext()); - if (CodeGenOpts.UnwindTables) + if ((!D || !D->hasAttr<NoUwtableAttr>()) && CodeGenOpts.UnwindTables) B.addUWTableAttr(llvm::UWTableKind(CodeGenOpts.UnwindTables)); if (CodeGenOpts.StackClashProtector) Index: clang/include/clang/Basic/AttrDocs.td =================================================================== --- clang/include/clang/Basic/AttrDocs.td +++ clang/include/clang/Basic/AttrDocs.td @@ -4537,6 +4537,16 @@ }]; } +def NoUwtableDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Clang supports the ``nouwtable`` attribute which skips emitting +the unwind table entry for the specified function. This attribute is useful for +selectively emitting the unwind table entry on some functions when building with +``-funwind-tables`` compiler option. + }]; +} + def InternalLinkageDocs : 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 @@ -2092,6 +2092,13 @@ let Documentation = [NoThrowDocs]; } +def NoUwtable : InheritableAttr { + let Spellings = [Clang<"nouwtable">]; + let Subjects = SubjectList<[FunctionLike]>; + let Documentation = [NoUwtableDocs]; + let SimpleHandler = 1; +} + def NvWeak : IgnoredAttr { // No Declspec spelling of this attribute; the CUDA headers use // __attribute__((nv_weak)) unconditionally. Does not receive an [[]] Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -149,6 +149,9 @@ using the MinGW environment. This attribute is only available for Windows targets. +- Introduced a new function attribute ``__attribute__((nouwtable))`` to suppress + LLVM IR ``uwtable`` function attribute. + Windows Support ---------------
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 @@ -115,6 +115,7 @@ // CHECK-NEXT: NoStackProtector (SubjectMatchRule_function) // CHECK-NEXT: NoThreadSafetyAnalysis (SubjectMatchRule_function) // CHECK-NEXT: NoThrow (SubjectMatchRule_hasType_functionType) +// CHECK-NEXT: NoUwtable (SubjectMatchRule_hasType_functionType) // CHECK-NEXT: NotTailCalled (SubjectMatchRule_function) // CHECK-NEXT: OSConsumed (SubjectMatchRule_variable_is_parameter) // CHECK-NEXT: OSReturnsNotRetained (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_variable_is_parameter) Index: clang/test/CodeGen/attr-nouwtable.c =================================================================== --- /dev/null +++ clang/test/CodeGen/attr-nouwtable.c @@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -funwind-tables=2 -S -emit-llvm %s -o - | FileCheck %s + +__attribute__((nouwtable)) +int test1(void) { return 0; } + +// CHECK: @test1{{.*}}[[ATTR1:#[0-9]+]] +// CHECK: attributes [[ATTR1]] = { +// CHECK-NOT: uwtable +// CHECK: } Index: clang/lib/CodeGen/CodeGenModule.cpp =================================================================== --- clang/lib/CodeGen/CodeGenModule.cpp +++ clang/lib/CodeGen/CodeGenModule.cpp @@ -1963,7 +1963,7 @@ llvm::Function *F) { llvm::AttrBuilder B(F->getContext()); - if (CodeGenOpts.UnwindTables) + if ((!D || !D->hasAttr<NoUwtableAttr>()) && CodeGenOpts.UnwindTables) B.addUWTableAttr(llvm::UWTableKind(CodeGenOpts.UnwindTables)); if (CodeGenOpts.StackClashProtector) Index: clang/include/clang/Basic/AttrDocs.td =================================================================== --- clang/include/clang/Basic/AttrDocs.td +++ clang/include/clang/Basic/AttrDocs.td @@ -4537,6 +4537,16 @@ }]; } +def NoUwtableDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Clang supports the ``nouwtable`` attribute which skips emitting +the unwind table entry for the specified function. This attribute is useful for +selectively emitting the unwind table entry on some functions when building with +``-funwind-tables`` compiler option. + }]; +} + def InternalLinkageDocs : 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 @@ -2092,6 +2092,13 @@ let Documentation = [NoThrowDocs]; } +def NoUwtable : InheritableAttr { + let Spellings = [Clang<"nouwtable">]; + let Subjects = SubjectList<[FunctionLike]>; + let Documentation = [NoUwtableDocs]; + let SimpleHandler = 1; +} + def NvWeak : IgnoredAttr { // No Declspec spelling of this attribute; the CUDA headers use // __attribute__((nv_weak)) unconditionally. Does not receive an [[]] Index: clang/docs/ReleaseNotes.rst =================================================================== --- clang/docs/ReleaseNotes.rst +++ clang/docs/ReleaseNotes.rst @@ -149,6 +149,9 @@ using the MinGW environment. This attribute is only available for Windows targets. +- Introduced a new function attribute ``__attribute__((nouwtable))`` to suppress + LLVM IR ``uwtable`` function attribute. + Windows Support ---------------
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits