https://bugs.llvm.org/show_bug.cgi?id=36221
Bug ID: 36221
Summary: Support for the mno-stack-arg-probe flag
Product: libraries
Version: trunk
Hardware: PC
OS: All
Status: NEW
Severity: enhancement
Priority: P
Component: Backend: X86
Assignee: unassignedb...@nondot.org
Reporter: nruslan_de...@yahoo.com
CC: llvm-bugs@lists.llvm.org
Created attachment 19802
--> https://bugs.llvm.org/attachment.cgi?id=19802&action=edit
Patches for clang and LLVM
I created patches (attached) for LLVM and clang that add support for
mno-stack-arg-probe flag. This flag is supported by MinGW/GCC, and it
completely disables stack probes when compiling for PE/COFF (Windows)
executable targets. The patch includes changes for x86 as well as for ARM
(untested), AARCH64 (untested).
Although clang and LLVM already support a related stack-probe-size=<size> flag,
it does not seem to help when the stack usage is unknown at compile time, and
thus probes do not seem to be suppressed even if a very large value is
specified. For example, consider the following code:
extern void func2(void * buffer);
void func(unsigned long size)
{
char buffer[size];
func2(buffer);
}
/opt/llvm/bin/clang -Wall -O2 -target x86_64-pc-mingw32 -m64 -S
-mstack-probe-size=2147483647 test.c gives the following output (notice the
___chkstk_ms symbol):
func: # @func
.Lcfi0:
.seh_proc func
# BB#0:
pushq %rbp
.Lcfi1:
.seh_pushreg 5
movq %rsp, %rbp
.Lcfi2:
.seh_setframe 5, 0
.Lcfi3:func: # @func
.Lcfi0:
.seh_proc func
# BB#0:
pushq %rbp
.Lcfi1:
.seh_pushreg 5
movq %rsp, %rbp
.Lcfi2:
.seh_setframe 5, 0
.Lcfi3:func: # @func
.Lcfi0:
.seh_proc func
# BB#0:
pushq %rbp
.Lcfi1:
.seh_pushreg 5
movq %rsp, %rbp
.Lcfi2:
.seh_setframe 5, 0
.Lcfi3:
.seh_endprologue
movl %ecx, %ecx
addq $15, %rcx
movabsq $8589934576, %rax # imm = 0x1FFFFFFF0
andq %rcx, %rax
callq ___chkstk_ms
subq %rax, %rsp
movq %rsp, %rcx
subq $32, %rsp
callq func2
nop
movq %rbp, %rsp
popq %rbp
retq
With the patch attached, stack probes are no longer used.
/opt/llvm/bin/clang -Wall -O2 -target x86_64-pc-mingw32 -m64 -S
-mno-stack-arg-probe test.c
func: # @func
.Lcfi0:
.seh_proc func
# BB#0:
pushq %rbp
.Lcfi1:
.seh_pushreg 5
movq %rsp, %rbp
.Lcfi2:
.seh_setframe 5, 0
.Lcfi3:
.seh_endprologue
movl %ecx, %eax
addq $15, %rax
movabsq $8589934576, %rax # imm = 0x1FFFFFFF0
subq $-1, %rsp
movq %rsp, %rcx
subq $32, %rsp
callq func2
nop
movq %rbp, %rsp
popq %rbp
retq
--
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs