<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Nov 11, 2015 at 1:01 PM, Alex Elsayed via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Wed, 11 Nov 2015 11:13:43 -0800, Daniel Berlin via llvm-dev wrote:<br>
<snip for gmane><br>
<span class="">> Heck, i could even reason about inline asm if i wanted to ;-).<br>
><br>
> My point is that this call is super special compared to all other<br>
> calls,<br>
> and literally everything in LLVM has to understand that.<br>
> The liklihood of subtle bugs being introduced in functionality (IE<br>
> analysis/etc doing the wrong thing because it is not special cased)<br>
> seems super high to me.<br>
<br>
</span>I do agree this is a concern.<br>
<span class=""><br>
>> I don't know how you could practically deploy a super-duper LTO mode<br>
>> that doesn't allow that as part of its model.<br>
>><br>
>><br>
> Sure.<br>
><br>
><br>
>> The following CFG simplification would be legal, as it also fits the<br>
>> normal model of an external call:<br>
>> if (cond) y =llvm.blackbox(x)<br>
>> else y = llvm.blackbox(x)<br>
>> --><br>
>> y = llvm.blackbox(x)<br>
>><br>
>> I don't see how this is special. It just provides an overloaded<br>
>> intrinsic whose definition we promise to never reason about. Other than<br>
>> that it follows the same familiar rules that function calls do.<br>
>><br>
>><br>
> You have now removed some conditional evaluation and jumps. those<br>
> would normally take benchmark time.<br>
> Why is that okay?<br>
<br>
</span>Because the original post in terms of wanting to inhibit specific<br>
optimizations was a flawed way of describing the problem.<br>
<br>
Reid's explanation of "an external function that LLVM is not allowed to<br>
reason about the body of" is a much better explanation, as a good<br>
benchmark will place llvm.blackbox() exactly where real code would call,<br>
say, getrandom() (on input) or printf() (on output).<br>
<br>
However, as the function call overhead of said external function isn't<br>
part of the _developer's_ code, and not something they can make faster in<br>
case of slow results, it's not relevant to the benchmarks - thus, using<br>
an _actual_ external function is suboptimal, even leaving aside that with<br>
LTO and such, llvm may STILL infer things about such functions, obviating<br>
the benchark.<br>
<br>
Perhaps the best explanation is that it's about *simulating the<br>
existence* of a "perfectly efficient" external world.<br></blockquote><div><br></div><div>Can you show a real benchmark that users have tried to write where the call overhead of actually using an external function call is measurable? A no-op function call is going to take maybe a dozen cycles max (inside a loop, so good branch prediction etc.). Anything where a dozen cycles is measurable by comparison basically can't be reasoned about at the C++ level (you are basically benchmarking at asm level at that point, so just write it in asm).</div><div><br></div><div>More generally, there's only been (I think) 1 concrete example given in this thread (the xor fold thing). Could you please give like 5 distinct real-world examples? That would help us get a feel for the real motivation here and why an external function call wouldn't work. (also, presumably this is a consistent problem that has been cropping up in practice if you are going to the length of wanting to add an IR intrinsic that, as Daniel points out, has implications throughout the compiler)</div><div><br></div><div>-- Sean Silva</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="HOEnZb"><div class="h5"><br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</div></div></blockquote></div><br></div></div>