<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Support for the mno-stack-arg-probe flag"
href="https://bugs.llvm.org/show_bug.cgi?id=36221">36221</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Support for the mno-stack-arg-probe flag
</td>
</tr>
<tr>
<th>Product</th>
<td>libraries
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>Backend: X86
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>nruslan_devel@yahoo.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=19802" name="attach_19802" title="Patches for clang and LLVM">attachment 19802</a> <a href="attachment.cgi?id=19802&action=edit" title="Patches for clang and LLVM">[details]</a></span>
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</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>