<div style="font-family:arial,helvetica,sans-serif;font-size:10pt">On 24 October 2012 08:52, Micah Villmow <span dir="ltr"><<a href="mailto:villmow@gmail.com" target="_blank">villmow@gmail.com</a>></span> wrote:<br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: mvillmow<br>
Date: Wed Oct 24 10:52:52 2012<br>
New Revision: 166578<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=166578&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=166578&view=rev</a><br>
Log:<br>
Add in support for getIntPtrType to get the pointer type based on the address space.<br>
This checkin also adds in some tests that utilize these paths and updates some of the<br>
clients.<br><br></blockquote><div><br></div><div>[...]</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
       // Only do this transformation if the int is intptrty in size, otherwise<br>
       // there is a truncation or extension that we aren't modeling.<br>
-      if (CE0->getOpcode() == Instruction::PtrToInt &&<br>
-          CE0->getType() == IntPtrTy) {<br>
-        Constant *C = CE0->getOperand(0);<br>
-        Constant *Null = Constant::getNullValue(C->getType());<br>
-        return ConstantFoldCompareInstOperands(Predicate, C, Null, TD, TLI);<br>
+      if (CE0->getOpcode() == Instruction::PtrToInt) {<br>
+        IntPtrTy = TD->getIntPtrType(CE0->getOperand(0)->getType());<br></blockquote><div><br></div><div>What about when TD is null? See PR14233 for a crash caused by this, but while that could be fixed by passing the TD down don't forget that people can have modules with no TD at all.</div>

<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+        if (CE0->getType() == IntPtrTy) {<br>
+          Constant *C = CE0->getOperand(0);<br>
+          Constant *Null = Constant::getNullValue(C->getType());<br>
+          return ConstantFoldCompareInstOperands(Predicate, C, Null, TD, TLI);<br>
+        }<br>
       }<br>
     }<br>
-<br></blockquote><div><br></div><div>Nick</div><div><br></div></div></div>