<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Please be more specific about the problem, because your simplified example doesn't actually show an issue. If I write this function:</div><div>int foo() {</div><div> int retval;</div><div> asm("# ..." : "=r"(retval));</div><div> return retval;</div><div>}</div><div>it already does get treated as definitely writing retval, and optimizes away the initialization (whether you explicitly initialize retval, or use -ftrivial-auto-var-init).<br></div><div>Example: <a href="https://godbolt.org/z/YYBCXL">https://godbolt.org/z/YYBCXL</a></div><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr"><br></div><div dir="ltr" class="gmail_attr">On Thu, Mar 21, 2019 at 8:35 AM Alexander Potapenko via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org">cfe-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi JF et al.,<br>
<br>
In the Linux kernel we often encounter the following pattern:<br>
<br>
type op(...) {<br>
type retval;<br>
inline asm(... retval ...);<br>
return retval;<br>
}<br>
<br>
, which is used to implement low-level platform-dependent memory operations.<br>
<br>
Some of these operations turn out to be very hot, so we probably don't<br>
want to initialize |retval| given that it's always initialized in the<br>
assembly.<br>
<br>
However it's practically impossible to tell that a variable is being<br>
written to by the inline assembly, or figure out the size of that<br>
write.<br>
Perhaps we could speculatively treat every scalar output of an inline<br>
assembly routine as an initialized value (which is true for the Linux<br>
kernel, but I'm not sure about other users of inline assembly, e.g.<br>
video codecs).<br>
<br>
WDYT?<br>
<br>
<br>
-- <br>
Alexander Potapenko<br>
Software Engineer<br>
<br>
Google Germany GmbH<br>
Erika-Mann-Straße, 33<br>
80636 München<br>
<br>
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado<br>
Registergericht und -nummer: Hamburg, HRB 86891<br>
Sitz der Gesellschaft: Hamburg<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div></div></div></div></div></div></div></div></div>