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" }