================
@@ -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:
Ah is this because of the `V->isNullValue()` below? In that case let's keep 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