<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 20, 2015 at 11:10 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">On Tue, Jan 20, 2015 at 10:58 AM, Adrian Prantl <span dir="ltr"><<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> Begin forwarded message:<br>
><br>
> Subject: Re: [llvm] r226588 - Add an assertion and prefer a crash over an infinite loop.<br>
> From: "Duncan P. N. Exon Smith" <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>><br>
> Date: January 20, 2015 at 10:53:38 AM PST<br>
> Cc: <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
> To: Adrian Prantl <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>><br>
<div><div>><br>
><br>
>> On 2015 Jan 20, at 10:03, Adrian Prantl <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>> wrote:<br>
>><br>
>> Author: adrian<br>
>> Date: Tue Jan 20 12:03:37 2015<br>
>> New Revision: 226588<br>
>><br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=226588&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=226588&view=rev</a><br>
>> Log:<br>
>> Add an assertion and prefer a crash over an infinite loop.<br>
>><br>
>> Modified:<br>
>>   llvm/trunk/lib/IR/DebugInfo.cpp<br>
>><br>
>> Modified: llvm/trunk/lib/IR/DebugInfo.cpp<br>
>> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=226588&r1=226587&r2=226588&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfo.cpp?rev=226588&r1=226587&r2=226588&view=diff</a><br>
>> ==============================================================================<br>
>> --- llvm/trunk/lib/IR/DebugInfo.cpp (original)<br>
>> +++ llvm/trunk/lib/IR/DebugInfo.cpp Tue Jan 20 12:03:37 2015<br>
>> @@ -527,12 +527,15 @@ bool DISubprogram::Verify() const {<br>
>>        while ((IA = DL.getInlinedAt()))<br>
>>          DL = DebugLoc::getFromDILocation(IA);<br>
>>        DL.getScopeAndInlinedAt(Scope, IA);<br>
>> +        assert(Scope && "debug location has no scope");<br>
>>        assert(!IA);<br>
>>        while (!DIDescriptor(Scope).isSubprogram()) {<br>
>>          DILexicalBlockFile D(Scope);<br>
>>          Scope = D.isLexicalBlockFile()<br>
>>                      ? D.getScope()<br>
>>                      : DebugLoc::getFromDILexicalBlock(Scope).getScope();<br>
>> +          if (!Scope)<br>
>> +            llvm_unreachable("lexical block file has no scope");<br>
><br>
> It's strange that this isn't simply an assertion:<br>
><br>
>    assert(Scope && "lexical block file has no scope");<br>
><br>
> But I guess that's so that it crashes even when NDEBUG?  (Is that<br>
> reliable?)<br>
<br>
</div></div>Yes, that’s the intention (and llvm_unreachable is meant to be used that way).<br></blockquote></div></div><div><br>I don't believe that's the intention of the LLVM style guide </div></div></div></div></blockquote><div><br>That said, can't find any mention of this in the style guide, sorry - so I'll reduce my claim to "I don't think I've seen this as a prevailing style/approach".<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>- generally we try to remove conditionals like this and replace the conditional with the assertion so the dead code isn't exercised in release builds.<br> </div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span>><br>
> If that's the reason, you should probably add a comment to that<br>
> effect since otherwise I'm likely to switch it to an assert next<br>
> time I look at it ;).<br>
><br>
> (Also, do you know when this situation arises?)<br>
<br>
</span>Happened to me when I compiled an old .ll file without the MDLocation upgrade.<br>
<span><font color="#888888"><br>
-- adrian<br>
</font></span><div><div><br>
><br>
>>        }<br>
>>        if (!DISubprogram(Scope).describes(F))<br>
>>          return false;<br>
>><br>
>><br>
>> _______________________________________________<br>
>> llvm-commits mailing list<br>
>> <a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
>> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
><br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></span></div><br></div></div>
</blockquote></div><br></div></div>