[llvm] [InferAddressSpaces] Handle unconverted ptrmask (PR #140802)
Robert Imschweiler via llvm-commits
llvm-commits at lists.llvm.org
Wed May 21 01:45:53 PDT 2025
================
@@ -1338,7 +1338,20 @@ bool InferAddressSpacesImpl::rewriteWithNewAddressSpaces(
unsigned OperandNo = PoisonUse->getOperandNo();
assert(isa<PoisonValue>(NewV->getOperand(OperandNo)));
- NewV->setOperand(OperandNo, ValueWithNewAddrSpace.lookup(PoisonUse->get()));
+ WeakTrackingVH NewOp = ValueWithNewAddrSpace.lookup(PoisonUse->get());
+ if (NewOp) {
+ NewV->setOperand(OperandNo, NewOp);
+ } else {
+ // Something went wrong while converting the instruction defining the new
+ // operand value. -> Replace the poison value with the previous operand
+ // value combined with an addrspace case.
----------------
ro-i wrote:
Yes, and I was thinking about this, too. But the function has already been adopted by one of the other backends, which also makes use of null as a potential return value (https://github.com/llvm/llvm-project/blob/64dcf7893554b44b2a79d23ea0b21d6f3fc2e38f/llvm/lib/Target/NVPTX/NVPTXTargetTransformInfo.cpp#L575). That's why I thought that it might be preferable to just handle null. Additionally, it may not be easy to detect all invalid cases beforehand since the addrspaces need to be known (and they currently aren't in `InferAddressSpacesImpl::collectRewritableIntrinsicOperands`).
https://github.com/llvm/llvm-project/pull/140802
More information about the llvm-commits
mailing list