[PATCH] Implement the no_split_stack attribute.
Peter Collingbourne
peter at pcc.me.uk
Fri May 16 23:23:06 PDT 2014
This is a GNU attribute that allows split stacks to be turned off on a
per-function basis.
http://reviews.llvm.org/D3817
Files:
include/clang/Basic/Attr.td
lib/CodeGen/CGCall.cpp
lib/Sema/SemaDeclAttr.cpp
test/CodeGen/split-stacks.c
Index: include/clang/Basic/Attr.td
===================================================================
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -823,6 +823,12 @@
let Documentation = [Undocumented];
}
+def NoSplitStack : InheritableAttr {
+ let Spellings = [GNU<"no_split_stack">];
+ let Subjects = SubjectList<[Function]>;
+ let Documentation = [Undocumented];
+}
+
def NonNull : InheritableAttr {
let Spellings = [GCC<"nonnull">];
let Subjects = SubjectList<[ObjCMethod, HasFunctionProto, ParmVar], WarnDiag,
Index: lib/CodeGen/CGCall.cpp
===================================================================
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1117,7 +1117,8 @@
FuncAttrs.addAttribute(llvm::Attribute::NoRedZone);
if (CodeGenOpts.NoImplicitFloat)
FuncAttrs.addAttribute(llvm::Attribute::NoImplicitFloat);
- if (CodeGenOpts.EnableSegmentedStacks)
+ if (CodeGenOpts.EnableSegmentedStacks &&
+ !(TargetDecl && TargetDecl->hasAttr<NoSplitStackAttr>()))
FuncAttrs.addAttribute("split-stack");
if (AttrOnCallSite) {
Index: lib/Sema/SemaDeclAttr.cpp
===================================================================
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -4173,6 +4173,9 @@
case AttributeList::AT_NoCommon:
handleSimpleAttribute<NoCommonAttr>(S, D, Attr);
break;
+ case AttributeList::AT_NoSplitStack:
+ handleSimpleAttribute<NoSplitStackAttr>(S, D, Attr);
+ break;
case AttributeList::AT_NonNull:
if (ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(D))
handleNonNullAttrParameter(S, PVD, Attr);
Index: test/CodeGen/split-stacks.c
===================================================================
--- test/CodeGen/split-stacks.c
+++ test/CodeGen/split-stacks.c
@@ -5,13 +5,21 @@
return 0;
}
+__attribute__((no_split_stack))
+int nosplit() {
+ return 0;
+}
+
int main() {
return foo();
}
-// CHECK-SEGSTK: define i32 @foo() #0 {
-// CHECK-SEGSTK: define i32 @main() #0 {
-// CHECK-SEGSTK: #0 = { {{.*}} "split-stack" {{.*}} }
+// CHECK-SEGSTK: define i32 @foo() [[SS:#[0-9]+]] {
+// CHECK-SEGSTK: define i32 @nosplit() [[NSS:#[0-9]+]] {
+// CHECK-SEGSTK: define i32 @main() [[SS]] {
+// CHECK-SEGSTK-NOT: [[NSS]] = { {{.*}} "split-stack" {{.*}} }
+// CHECK-SEGSTK: [[SS]] = { {{.*}} "split-stack" {{.*}} }
+// CHECK-SEGSTK-NOT: [[NSS]] = { {{.*}} "split-stack" {{.*}} }
// CHECK-NOSEGSTK: define i32 @foo() #0 {
// CHECK-NOSEGSTK: define i32 @main() #0 {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3817.9507.patch
Type: text/x-patch
Size: 2515 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140517/428a7072/attachment.bin>
More information about the cfe-commits
mailing list