<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 14 January 2016 at 15:05, Zhao, Weiming <span dir="ltr"><<a href="mailto:weimingz@codeaurora.org" target="_blank">weimingz@codeaurora.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
I agree what you said about different code generated with clang and
GCC generates. In this case, we should throw an error
(err_late_asm_label).<br>
<br>
But in this example, there is no use of the function. They are just
redundant declarations and there is no actual code generated.<br>
So I suggest we just give warnings for this case. Otherwise, it will
break existing code like some SPEC benchmarks.<br>
<br>
Please review my 2nd patch.</div></blockquote><div><br></div><div>I think your second patch checks whether it's used at the time of the redeclaration, which is too early. It may be used between there and the end of the program. I expect it not to warn but not error on the testcase I posted in my previous email?</div><div><br></div><div>To fix, you'd need to store a list of different-asm-label declarations in Sema, check it each time something is ODR-used (see the Sema::Mark<...>Referenced family of calls) to emit the error and remove it from the list. Also, when emitting a PCH or a Module, you need to serialize and deserialize this list.</div><div><br></div><div>Nick</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000"><span class="HOEnZb"><font color="#888888">Weiming</font></span><div><div class="h5"><br>
<br>
<div>On 1/14/2016 2:28 PM, Nick Lewycky
wrote:<br>
</div>
<blockquote type="cite">
<div dir="ltr">
<div class="gmail_extra">
<div class="gmail_quote">On 14 January 2016 at 10:38, Weiming
Zhao via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank"></a><a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">weimingz
added a comment.<br>
<br>
Hi Nick,<br>
<br>
Below is a reduced code:<br>
t.c:<br>
<br>
static long double acoshl (long double __x) __asm__ (""
"acosh") ; // this is from
<gcc4.9>/arm-linux-gnueabi/libc/usr/include/bits/mathcalls.h<br>
extern long double acoshl (long double) __asm__ (""
"__acoshl_finite") ; // this is from existing code<br>
<br>
GCC gives warning like:<br>
/tmp/t.c:2:1: warning: asm declaration ignored due to
conflict with previous rename [-Wpragmas]<br>
extern long double acoshl (long double) __asm__ (""
"__acoshl_finite") ;<br>
</blockquote>
<div><br>
</div>
<div>
<div>That's the same case as in this testcase:</div>
<div><br>
</div>
<div> void foo() __asm__("one");</div>
<div> void foo() __asm__("two");<br>
</div>
<div> void test() { foo(); }<br>
</div>
<div><br>
</div>
<div>GCC emits a call to 'one' while Clang emits a call to
'two'. This is a real bug. Please don't downgrade this
to a warning.</div>
<div><br>
</div>
<div>As an alternative, I would accept a patch which
changes how clang generates code so that it also
produces a call to 'one', with a warning. It looks like
what we need to do is drop subsequent asm label
declarations on functions that already have one.</div>
<div><br>
</div>
<div>Nick</div>
</div>
</div>
</div>
</div>
</blockquote>
<br>
</div></div></div>
</blockquote></div><br></div></div>