<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Fri, Feb 26, 2016 at 7:26 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: "Hal Finkel" <<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>>, "Sanjoy Das" <<a href="mailto:sanjoy@playingwithpointers.com" target="_blank">sanjoy@playingwithpointers.com</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>>, "Xinliang David Li" <<a href="mailto:xinliangli@gmail.com" target="_blank">xinliangli@gmail.com</a>><br>
> Sent: Friday, February 26, 2016 9:01:48 PM<br>
> Subject: Re: [llvm-dev] Possible soundness issue with available_externally (split from "RFC: Add guard intrinsics")<br>
><br>
><br>
> I think this will have a much higher cost than my proposal to<br>
> constrain how we deduce function attributes (which still fixes<br>
> Sanjoy's latest example).<br>
><br>
> Specifically, I think this will force us to constrain far too many<br>
> transformations for the sake of code size in functions that we won't<br>
> inline. Even if we were never going to deduce function attributes<br>
> for anything in the function (because its big and reads and writes<br>
> everything), we'll still have to constrain our transformations just<br>
> because we *might* later deduce a function attribute that triggers<br>
> these kinds of bugs.<br>
><br>
> Essentially, you're proposing to limit intraprocedural optimization<br>
> to when we can successfully to interprocedural optimization<br>
> ("privatization"), where I'm suggesting we limit interprocedural<br>
> optimization to leave intraprocedural optimization unconstrained.<br>
> Given the ratio of our optimizations (almost all are intra, very few<br>
> are inter), I'm much more comfortable with the latter.<br>
<br>
This is a good point; we can certainly (easily) delay the privatization decision until we modify any IPA-level function information (at which point we can either reject the attribute change (when optimizing for code size), or keep it locally (when optimizing for speed). Ideally, you'd want to delay this even further (until you knew the attribute information was used), but I'm not sure that's practical.<br>
<br>
Actually, what if instead of actually privatizing, we moved the function into a different comdat section named after some hash of the function body? That way, if all versions are actually optimized identically, we'll still only end up with one copy in the final executable. If this is technically possible, it seems like the best kind of solution.<br></blockquote><div><br></div><div>This is how I want to do a revamped function merging anyways and it would fall out naturally of that.</div></div></div>