<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 11, 2015 at 7:12 PM, Charles Davis <span dir="ltr"><<a href="mailto:cdavis5x@gmail.com" target="_blank">cdavis5x@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">> On Oct 21, 2014, at 3:00 PM, Philip Reames <<a href="mailto:listmail@philipreames.com">listmail@philipreames.com</a>> wrote:<br>
><br>
> Author: reames<br>
> Date: Tue Oct 21 16:00:03 2014<br>
> New Revision: 220324<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=220324&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=220324&view=rev</a><br>
> Log:<br>
> Preserve 'nonnull' when changing type of the load.<br>
><br>
> When changing the type of a load in Chandler's recent InstCombine changes, we can preserve the new 'nonnull' metadata.<br>
><br>
> I considered adding an assert since 'nonnull' is only valid on pointer types, but casting a pointer to a non-pointer would involve more than a bitcast anyways.  If someone extends this transform to handle more than bitcasts, the verifier will report the malformed IR, so a separate assertion isn't needed.<br>
</span>Hi Philip and Chandler,<br>
<br>
Some recent changes to LLVM may have exposed a problem with this.<br>
<br>
Under certain conditions, if InstCombine attempts to canonicalize loads like this, we get a load of an integer with !nonnull metadata. I’ve attached a patch that contains a test that demonstrates this, and a fix that makes the test pass.<br></blockquote><div><br></div><div>Yuck.</div><div><br></div><div>I think it's probably important that we don't completely lose this information. Instead, we should transform !nonnull into !range metadata.</div><div><br></div><div>Also, you don't want to check for an integer type -- that's not the relevant thing. We need to remove !nonnull any time the target type is a non-pointer type. And we need to add !range when the target type is an integer type.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Shall I commit this right away? And should we also fix stores with !nonnull metadata?</blockquote></div><br>Maybe incorporate the above, and mail out a fresh patch? Sending it with Phabricator would help make it easy to review.</div></div>