Skip to content

Commit 75a2934

Browse files
committed
[SPIR-V] Don't replace spirv.Type with spv_track_constant
Fixes #134417
1 parent 412f7fa commit 75a2934

File tree

2 files changed

+20
-11
lines changed

2 files changed

+20
-11
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,21 +2062,13 @@ void SPIRVEmitIntrinsics::processInstrAfterVisit(Instruction *I,
20622062
}
20632063
Type *OpTy = Op->getType();
20642064
Value *OpTyVal = Op;
2065-
if (OpTy->isTargetExtTy())
2066-
OpTyVal = getNormalizedPoisonValue(OpTy);
20672065
Type *OpElemTy = GR->findDeducedElementType(Op);
20682066
Value *NewOp = Op;
2069-
if (OpTy->isTargetExtTy()) {
2067+
TargetExtType *TargetTy = dyn_cast<TargetExtType>(OpTy);
2068+
if (TargetTy && TargetTy->getName() != "spirv.Type") {
2069+
OpTyVal = getNormalizedPoisonValue(OpTy);
20702070
NewOp = buildIntrWithMD(Intrinsic::spv_track_constant,
20712071
{OpTy, OpTyVal->getType()}, Op, OpTyVal, {}, B);
2072-
if (isPointerTy(OpTy)) {
2073-
if (OpElemTy) {
2074-
GR->buildAssignPtr(B, OpElemTy, NewOp);
2075-
} else {
2076-
insertTodoType(NewOp);
2077-
GR->buildAssignPtr(B, OpTy, NewOp);
2078-
}
2079-
}
20802072
}
20812073
if (!IsConstComposite && isPointerTy(OpTy) && OpElemTy != nullptr &&
20822074
OpElemTy != IntegerType::getInt8Ty(I->getContext())) {
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv-unknown-unknown %s -o - | FileCheck %s
2+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - -filetype=obj | spirv-val %}
3+
; RUN: %if spirv-tools %{ llc -O0 -mtriple=spirv-unknown-unknown %s -o - | spirv-as - -o - | spirv-val %}
4+
5+
%literal_32 = type target("spirv.Literal", 32)
6+
%literal_true = type target("spirv.Literal", 1)
7+
8+
; CHECK-DAG: OpUnknown(21, 4) [[int_t:%[0-9]+]] 32 1
9+
%int_t = type target("spirv.Type", %literal_32, %literal_true, 21, 4, 32)
10+
11+
; CHECK-DAG: {{%[0-9]+}} = OpTypeFunction [[int_t]]
12+
define %int_t @foo() {
13+
entry:
14+
; CHECK-DAG: [[undef:%[0-9]+]] = OpUndef [[int_t]]
15+
; CHECK-DAG: OpReturnValue [[undef]]
16+
ret %int_t undef
17+
}

0 commit comments

Comments
 (0)