<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Oct 18, 2014 at 11:48 PM, Hal Finkel <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">----- Original Message -----<br>
> From: "Chandler Carruth" <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>><br>
> To: <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> Sent: Saturday, October 18, 2014 6:00:12 AM<br>
> Subject: [llvm] r220141 - Preserve AA metadata when combining (cast (load     (...))) -> (load (cast<br>
><br>
> Author: chandlerc<br>
> Date: Sat Oct 18 06:00:12 2014<br>
> New Revision: 220141<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220141&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=220141&view=rev</a><br>
> Log:<br>
> Preserve AA metadata when combining (cast (load (...))) -> (load<br>
> (cast<br>
> (...))).<br>
<br>
</span>This is obviously good, but there is also other metadata that can be preserved here (like llvm.mem.parallel_loop_access, invariant.load, etc.), and we should do so. I think that it might be better to "drop and copy" instead of doing it this way. We have a Instruction::dropUnknownMetadata(ArrayRef<unsigned> KnownIDs) function now which should make this easy.</blockquote></div></div><br><div>Yea.</div><div><br></div><div>The more I think about it, the less I can dream up any metadata that will ever *not* be valid to propagate here. But of course, we need to be conservatively correct. I don't think dropUnknownMetadata is the right approach here, not the least because we don't have any way to copy it. Instead, I think a copy with an explicit switch is the right approach. Then, if I change the enum of MD kinds to be a named enum I can get a warning if anyone ever updates the set of metadata with kinds in that enum and fails to add it to this switch.</div><div><br></div><div>I'm switching the code to use a switch and preserve all of the currently tagged kinds of metadata. Does going further and using a named enum seem reasonable to you as well? If so, I'll make and document that change.</div></div>