[clang] [lld] [llvm] [WIP][IR][Constants] Change the semantic of `ConstantPointerNull` to represent an actual `nullptr` instead of a zero-value pointer (PR #166667)
Shilei Tian via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 21 20:42:50 PST 2025
================
@@ -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;
----------------
shiltian wrote:
Yes.
https://github.com/llvm/llvm-project/pull/166667
More information about the llvm-commits
mailing list