[clang] [llvm] [ValueTracking] Return true for AddrSpaceCast in canCreateUndefOrPoison (PR #144686)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 20 00:45:40 PDT 2025
================
@@ -10211,8 +10210,18 @@ bool AANoUndef::isImpliedByIR(Attributor &A, const IRPosition &IRP,
return true;
Value &Val = IRP.getAssociatedValue();
+ auto IsTargetGuaranteedNotPoison = [&](Value &V) {
+ if (auto *ASC = dyn_cast<AddrSpaceCastInst>(&V)) {
+ const auto *TTI = A.getInfoCache().getTargetTransformInfoForFunction(
+ *ASC->getFunction());
+ return ASC && TTI->isValidAddrSpaceCast(ASC->getSrcAddressSpace(),
+ ASC->getDestAddressSpace());
+ }
+ return false;
+ };
if (IRP.getPositionKind() != IRPosition::IRP_RETURNED &&
- isGuaranteedNotToBeUndefOrPoison(&Val)) {
+ (isGuaranteedNotToBeUndefOrPoison(&Val) ||
+ IsTargetGuaranteedNotPoison(Val))) {
----------------
nikic wrote:
This is incorrect, it will not handle poison introduced higher up the chain if it ends in an addrspacecast. It's also sub-optimal, because it will not handle known-valid addrspacecasts higher up the chain. This needs to be handled fully inside canCreateUndefOrPoison.
https://github.com/llvm/llvm-project/pull/144686
More information about the llvm-commits
mailing list