[llvm] [SPIR-V] Consistent handling of TargetExtTypes in emit-intrinsics (PR #135682)

Vyacheslav Levytskyy via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 02:53:10 PDT 2025


================
@@ -1947,10 +1947,14 @@ void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I,
           GR->buildAssignPtr(B, ElemTy ? ElemTy : deduceElementType(Op, true),
                              Op);
         } else {
+          Value *OpTyVal = Op;
+          if (OpTy->isTargetExtTy()) {
+            OpTyVal = getNormalizedPoisonValue(OpTy);
----------------
VyacheslavLevytskyy wrote:

Let's please document this explicitly in comments.

A wider context is that in https://github.com/llvm/llvm-project/pull/130605 we have started elimination of spv_track_constant intrinsics, and this is a work in progress. I understand this change and its need to resolve the issue, however, it introduces a hidden relations between this point in the code and SPIRVEmitIntrinsics::processInstrAfterVisit() where `Intrinsic::spv_track_constant` is inserted. This create a pitfall for anyone who will try to untangle type inference logic from emit-intrinsic logic.

I think it's ok to introduce this change, but please add a longer comment here and in SPIRVEmitIntrinsics::processInstrAfterVisit(), referencing another occurrence of the spv_track_constant/spv_assign_type pair implicitly linked by `isTargetExtTy()`, so that we do not forget to address this after the prospective rework of type inference vs. emit-intrinsic starts.

https://github.com/llvm/llvm-project/pull/135682


More information about the llvm-commits mailing list