[PATCH] Add a "no-split-stack" function attribute.
Luqman Aden
me+llvm at luqman.ca
Fri Oct 11 18:17:35 PDT 2013
This disable emission of segmented-stack prologues on a per-function basis, even if segmented stacks are turned on globally.
http://llvm-reviews.chandlerc.com/D1905
Files:
lib/CodeGen/PrologEpilogInserter.cpp
test/CodeGen/X86/segmented-stacks.ll
Index: lib/CodeGen/PrologEpilogInserter.cpp
===================================================================
--- lib/CodeGen/PrologEpilogInserter.cpp
+++ lib/CodeGen/PrologEpilogInserter.cpp
@@ -707,7 +707,8 @@
// we've been asked for it. This, when linked with a runtime with support
// for segmented stacks (libgcc is one), will result in allocating stack
// space in small chunks instead of one large contiguous block.
- if (Fn.getTarget().Options.EnableSegmentedStacks)
+ if (Fn.getTarget().Options.EnableSegmentedStacks &&
+ !Fn.getFunction()->hasFnAttribute("no-split-stack"))
TFI.adjustForSegmentedStacks(Fn);
// Emit additional code that is required to explicitly handle the stack in
Index: test/CodeGen/X86/segmented-stacks.ll
===================================================================
--- test/CodeGen/X86/segmented-stacks.ll
+++ test/CodeGen/X86/segmented-stacks.ll
@@ -383,3 +383,29 @@
; X32-Darwin-NEXT: ret
}
+
+define void @test_no_split_stack() #0 {
+ %mem = alloca i32, i32 10
+ call void @dummy_use (i32* %mem, i32 10)
+ ret void
+
+; Don't emit __morestack if no-split-stack
+
+; X32-Linux-LABEL: test_no_split_stack:
+; X32-Linux-NOT: __morestack
+
+; X64-Linux-LABEL: test_no_split_stack:
+; X64-Linux-NOT: __morestack
+
+; X32-Darwin-LABEL: test_no_split_stack:
+; X32-Darwin-NOT: __morestack
+
+; X64-Darwin-LABEL: test_no_split_stack:
+; X64-Darwin-NOT: __morestack
+
+; X64-FreeBSD-LABEL: test_no_split_stack:
+; X64-FreeBSD-NOT: __morestack
+
+}
+
+attributes #0 = { "no-split-stack" }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D1905.1.patch
Type: text/x-patch
Size: 1586 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20131011/dee0185f/attachment.bin>
More information about the llvm-commits
mailing list