================
@@ -126,6 +126,40 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, 
Constant *V,
   if (isa<PoisonValue>(V))
     return PoisonValue::get(DestTy);
 
+  if (opc == Instruction::IntToPtr) {
+    // We can't fold inttoptr(0) to ConstantPointerNull without checking the
+    // target data layout. However, since data layout is not available here, we
+    // can't do this.
+    if (V->isZeroValue())
+      return nullptr;
----------------
arichardson wrote:

```suggestion
    // Note: We can't fold inttoptr(0) to ConstantPointerNull without checking
    // the target data layout since null pointers could also be all-ones.
```
I don't think we need the early return here? Although I guess it's a cheap 
check and so might actually be better to have it.

https://github.com/llvm/llvm-project/pull/166667
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to