[llvm] [SPIR-V] Ensure that a correct pointer type is deduced from the Value argument of OpAtomic* instructions (PR #127492)
Vyacheslav Levytskyy via llvm-commits
llvm-commits at lists.llvm.org
Mon Feb 17 06:28:06 PST 2025
================
@@ -934,9 +937,23 @@ bool SPIRVEmitIntrinsics::deduceOperandElementTypeCalledFunction(
case SPIRV::OpAtomicUMax:
case SPIRV::OpAtomicSMin:
case SPIRV::OpAtomicSMax: {
- KnownElemTy = getAtomicElemTy(GR, CI, Op);
+ KnownElemTy = isPointerTy(CI->getType()) ? getAtomicElemTy(GR, CI, Op)
+ : CI->getType();
if (!KnownElemTy)
return true;
+ Uncomplete = isTodoType(Op);
+ Ops.push_back(std::make_pair(Op, 0));
+ } break;
+ case SPIRV::OpAtomicStore: {
+ if (CI->arg_size() < 4)
+ return true;
+ Value *ValOp = CI->getArgOperand(3);
+ KnownElemTy = isPointerTy(ValOp->getType())
+ ? getAtomicElemTy(GR, CI, Op)
+ : ValOp->getType();
+ if (!KnownElemTy)
+ return true;
+ Uncomplete = isTodoType(Op);
----------------
VyacheslavLevytskyy wrote:
It's the same patter as we see in deduceOperandElementType() - this variable means that a related pointer has the default type (i8) assigned rather than a deduced one, and we may change the type if we get a better type. It's in use actually, please see
```
if (!Uncomplete)
eraseTodoType(Op);
```
below the call to deduceOperandElementTypeCalledFunction().
https://github.com/llvm/llvm-project/pull/127492
More information about the llvm-commits
mailing list