<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 - [clang-cl] Decide what to do about /Gs (set stack probe size)"
href="https://bugs.llvm.org/show_bug.cgi?id=39074">39074</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>[clang-cl] Decide what to do about /Gs (set stack probe size)
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</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>Driver
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>hans@chromium.org
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, nicolasweber@gmx.de
</td>
</tr>
<tr>
<th>Blocks</th>
<td>13707
</td>
</tr></table>
<p>
<div>
<pre>The MSDN docs about /Gs are a bit confusing.
They say "/Gs0 activates stack probes for every function call that requires
storage for local variables. This can have a negative impact on performance."
and "If the /Gs option is specified without a size argument, it is the same as
specifying /Gs0".
Yet they say /O1 and /O2 imply /Gs. Why would they do that if it has negative
impact on performance?
Also, I'm having trouble reproducing this locally. With MSVC from VS 2017:
a.cc:
int f(int x) { volatile int a[128] = {0}; return a[0];
cl /c /O1 a.cc && dumpbin /disasm a.obj
no stack probe
cl /c /O1 /Gs a.cc && dumpbin /disasm a.obj
no stack probe
cl /c /O1 /Gs0 a.cc && dumpbin /disasm a.obj
yes stack probe!
Okay, so maybe the doc is incorrect and /Gs doesn't mean /Gs0, but maybe it
means turn off stack probes? That would make sense with /O1 and /O2...
Adjusting a.cc to use more stack:
int f(int x) { volatile int a[4097] = {0}; return a[0]; }
cl /c /O1 a.cc && dumpbin /disasm a.obj
yes stack probe
cl /c /O1 /Gs a.cc && dumpbin /disasm a.obj
yes stack probe
cl /c /O1 /Gs100000 a.cc && dumpbin /disasm a.obj
no stack probe
cl /c /O1 /Gs100000 /Gs a.cc && dumpbin /disasm a.obj
yes stack probe
Well, since we still got a stack probe with /Gs, it doesn't seem to turn it
off.
I guess /Gs really just means use the default stack probe size (4096), and so
has no effect in practice.
If that's the case, we should make clang-cl behave accordingly; currently it
implements what the MSDN docs say.</pre>
</div>
</p>
<div id="referenced">
<hr style="border: 1px dashed #969696">
<b>Referenced Bugs:</b>
<ul>
<li>
[<a class="bz_bug_link
bz_status_NEW "
title="NEW - [meta] VCPP compatibility issues"
href="https://bugs.llvm.org/show_bug.cgi?id=13707">Bug 13707</a>] [meta] VCPP compatibility issues
</li>
</ul>
</div>
<br>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>