<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Feb 24, 2016 at 11:18 PM Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">----- Original Message -----<br>
> From: "Chandler Carruth" <<a href="mailto:chandlerc@google.com" target="_blank">chandlerc@google.com</a>><br>
> To: "Sanjoy Das" <<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a>>, "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>><br>
> Cc: "llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>, "Philip Reames" <<a href="mailto:listmail@philipreames.com" target="_blank">listmail@philipreames.com</a>>, "Duncan P. N. Exon Smith"<br>
> <<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>><br>
> Sent: Thursday, February 25, 2016 12:40:53 AM<br>
> Subject: Re: [llvm-dev] Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")<br>
><br>
><br>
><br>
><br>
> On Wed, Feb 24, 2016 at 10:25 PM Sanjoy Das <<br>
> <a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</a> > wrote:<br>
><br>
><br>
><br>
> Hal Finkel wrote:<br>
><br>
> > But it is not all optimizations that are the problem. Rather, it<br>
> > seems like a select few (e.g. things involving collapsing allowed<br>
> > non-determinism in atomics), and losing those optimizations seems<br>
> > better than generally losing function-attribute deduction.<br>
><br>
> If we go by the langref, then optimizations that fold undef are also<br>
> problematic (though most C/C++ programs resulting in such IR would<br>
> have UB in practice).<br>
><br>
><br>
><br>
> I'm also concerned about undef. It isn't clear that we can reasonably<br>
> ensure that all things involving undef suitably stem from UB in the<br>
> face of speculation to preclude all "impossible" results coming from<br>
> interposition.<br>
><br>
><br>
> I think trying to enumerate the function-local optimizations which<br>
> are unsafe is *much* more challenging than identifying the<br>
> interprocedural optimizations which are unsafe, which is essentially<br>
> what disabling function attribute deduction is doing.<br>
><br>
<br>
It might be much more challenging, but let's try. This is not an issue we need to fix by the end of the month, and the potential optimization regressions are significant. Our deductions of readonly/readnone/nocapture/etc. are really important for enabling other optimizations. Given that all of our C++ constructors, inline functions, etc. end up in comdat sections, this is really important.<br></blockquote><div><br></div><div>Well, no one has really commented on my ideas to mitigate the issue.. I'm actually much less concerned in the face of those ideas.</div><div><br></div><div>But given that we can't even formulate a good statement of what transforms would necessarily have to be forbidden, I think we should get to a sound state first, and then work on more aggressive models to use.</div><div><br></div><div>I think that coming up with something that is really sound is going to be incredibly hard here because I think it will be tantamount to removing the concept of undef entirely and the entire optimizer's reliance on it. And most of the obvious ideas to replace it I think will have the same challenges as undef.</div><div><br></div><div>We're also, meanwhile, going to have to dramatically curtail our investigation of more exciting IPO opportunities because all of them bust be carefully examined to not trigger these issues more directly.</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> All of this makes me think we're just seeing the tip of the iceberg<br>
> of ways in which local optimizations can combine with attributes to<br>
> break this. =/ I really think the problem is as Richard describes<br>
> the interprocedural movement of information across a comdat-like<br>
> boundary where replacements may occur with differently transformed<br>
> code.<br>
<br>
Yes, but it is not *all* information that is relevant here.<br></blockquote><div><br></div><div>True. It is any information which is not necessarily the same in all (possibly transformed or untransformed) variants of the function.<br></div><div><br></div><div>My only confident summary of that is: "the information we can deduce prior to any transformations". It sounds like you think we can effectively preclude any such transformations on functions with ODR. I think that this will end up being extraordinarily limiting if we can do it at all. It certainly isn't the optimizer we have today, and would require changes all over...</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
-Hal<br>
<br>
--<br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
</blockquote></div></div>