<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Jan 31, 2017 at 3:05 PM Paul Robinson via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">probinson added inline comments.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: test/DebugInfo/X86/dbg-abstract-vars-g-gmlt.ll:1<br class="gmail_msg">
+; RUN: llc < %s -filetype=obj | llvm-dwarfdump - -debug-dump=info | FileCheck %s<br class="gmail_msg">
+;<br class="gmail_msg">
----------------<br class="gmail_msg">
dblaikie wrote:<br class="gmail_msg">
> Here's the simplest example I have for this (also doesn't require optimizations either at compile time or after the link step (though they can be used to tidy up the IR a little):<br class="gmail_msg">
><br class="gmail_msg">
>   // first file<br class="gmail_msg">
>   void f1();<br class="gmail_msg">
>   inline __attribute__((always_inline)) void f2(int) {<br class="gmail_msg">
>     f1();<br class="gmail_msg">
>   }<br class="gmail_msg">
>   void f3() {<br class="gmail_msg">
>     f2();<br class="gmail_msg">
>   }<br class="gmail_msg">
><br class="gmail_msg">
>   // second file<br class="gmail_msg">
>   void f() {<br class="gmail_msg">
>   }<br class="gmail_msg">
><br class="gmail_msg">
I have not been able to get your example to crash on an unmodified compiler, can you provide more details?<br class="gmail_msg"></blockquote><div><br></div><div>Hmm. Seems to be working for me thusly (maybe I was missed some details first time around):<br><br></div><div>blaikie@blaikie-linux:~/dev/scratch$ cat AbstVar.cpp</div><div>#ifdef P1</div><div>void f1();</div><div>inline __attribute__((always_inline)) void f2(int) {</div><div>  f1();</div><div>}</div><div>void f3() {</div><div>  f2(0);</div><div>}</div><div>#else</div><div>void f() {</div><div>}</div><div>#endif</div><div>blaikie@blaikie-linux:~/dev/scratch$ clang-tot -emit-llvm -S -DP1 -g AbstVar.cpp -o AbstVar-1.ll && clang-tot -emit-llvm -S -gmlt AbstVar.cpp -o AbstVar-2.ll && llvm-link-tot AbstVar-{1,2}.ll -S -o AbstVar-link.ll && llc-tot AbstVar-link.ll -o /dev/null -filetype=obj 2>&1</div><div>llc-tot: llvm/src/lib/CodeGen/AsmPrinter/DwarfDebug.cpp:1223: virtual void llvm::DwarfDebug::endFunction(const llvm::MachineFunction *): Assertion `AbstractVariables.empty()' failed.</div><div>#0 0x0000000003fedf1c (llc-tot+0x3fedf1c)</div><div>#1 0x0000000003fee409 (llc-tot+0x3fee409)</div><div>#2 0x0000000003fec783 (llc-tot+0x3fec783)</div><div>#3 0x0000000003fee764 (llc-tot+0x3fee764)</div><div>#4 0x00007f3e1eb76330 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10330)</div><div>#5 0x00007f3e1dc83c37 gsignal /build/eglibc-oGUzwX/eglibc-2.19/signal/../nptl/sysdeps/unix/sysv/linux/raise.c:56:0</div><div>#6 0x00007f3e1dc87028 abort /build/eglibc-oGUzwX/eglibc-2.19/stdlib/abort.c:91:0</div><div>#7 0x00007f3e1dc7cbf6 __assert_fail_base /build/eglibc-oGUzwX/eglibc-2.19/assert/assert.c:92:0</div><div>#8 0x00007f3e1dc7cca2 (/lib/x86_64-linux-gnu/libc.so.6+0x2fca2)</div><div>#9 0x0000000003178220 (llc-tot+0x3178220)</div><div>#10 0x000000000314a7d6 (llc-tot+0x314a7d6)</div><div>#11 0x0000000002bd4fc1 (llc-tot+0x2bd4fc1)</div><div>#12 0x00000000033c9ee1 (llc-tot+0x33c9ee1)</div><div>#13 0x00000000037cae8f (llc-tot+0x37cae8f)</div><div>#14 0x00000000037cb1a5 (llc-tot+0x37cb1a5)</div><div>#15 0x00000000037cb93a (llc-tot+0x37cb93a)</div><div>#16 0x00000000037cb466 (llc-tot+0x37cb466)</div><div>#17 0x00000000037cbe51 (llc-tot+0x37cbe51)</div><div>#18 0x0000000001da725e (llc-tot+0x1da725e)</div><div>#19 0x0000000001da56eb (llc-tot+0x1da56eb)</div><div>#20 0x00007f3e1dc6ef45 __libc_start_main</div><div>#21 0x0000000001da5029 (llc-tot+0x1da5029)</div><div>Stack dump:</div><div>0.      Program arguments: llc-tot AbstVar-link.ll -o /dev/null -filetype=obj </div><div>1.      Running pass 'Function Pass Manager' on module 'AbstVar-link.ll'.</div><div>2.      Running pass 'X86 Assembly Printer' on function '@_Z1fv'</div><div>Aborted (core dumped)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
================<br class="gmail_msg">
Comment at: test/DebugInfo/X86/dbg-value-g-gmlt.ll:1<br class="gmail_msg">
+; RUN: llc -filetype=obj < %s | llvm-dwarfdump - -debug-dump=info | FileCheck %s<br class="gmail_msg">
+;<br class="gmail_msg">
----------------<br class="gmail_msg">
dblaikie wrote:<br class="gmail_msg">
> Interestingly, this still seems to trigger the assert:<br class="gmail_msg">
><br class="gmail_msg">
>   void f()<br class="gmail_msg">
>   void foo(int param) {<br class="gmail_msg">
>     if (param)<br class="gmail_msg">
>       f();<br class="gmail_msg">
>   }<br class="gmail_msg">
><br class="gmail_msg">
>   void foo(int);<br class="gmail_msg">
>   void bar() {<br class="gmail_msg">
>     foo(0);<br class="gmail_msg">
>   }<br class="gmail_msg">
><br class="gmail_msg">
> Which is vaguely worrying - since in this case the call to foo is not/cannot be optimized away, so I'm not sure what the assertion is telling us here. There should be instructions for the function & so we shouldn't be in that codepath.<br class="gmail_msg">
Why can't it be inlined away?  bar() calls foo(), foo() gets inlined into bar(), the constant 0 parameter is propagated to the 'if', the condition is guaranteed false therefore the 'if/then' goes away, poof all gone.  Except for the dbg.value describing the inlined copy of 'param'.<br class="gmail_msg"></blockquote><div><br></div><div>Oh, good point. Great - then that's a good reproduction :) </div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D29310" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D29310</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>