Skip to content

Commit 0f9ffdb

Browse files
committed
Assert the image def and use are in same bb.
1 parent e7b00db commit 0f9ffdb

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2985,12 +2985,16 @@ void SPIRVInstructionSelector::selectImageWriteIntrinsic(
29852985
// that we will need to change the return type of the intrinsic.
29862986
// We will do that when we can, but for now trying to move forward with other
29872987
// issues.
2988+
Register ImageReg = I.getOperand(1).getReg();
2989+
assert(MRI->getVRegDef(ImageReg)->getParent() == I.getParent() &&
2990+
"The image must be loaded in the same basic block as its use.");
2991+
Register CoordinateReg = I.getOperand(2).getReg();
29882992
Register DataReg = I.getOperand(3).getReg();
29892993
assert(GR.getResultType(DataReg)->getOpcode() == SPIRV::OpTypeVector);
29902994
assert(GR.getScalarOrVectorComponentCount(GR.getResultType(DataReg)) == 4);
29912995
BuildMI(*I.getParent(), I, I.getDebugLoc(), TII.get(SPIRV::OpImageWrite))
2992-
.addUse(I.getOperand(1).getReg())
2993-
.addUse(I.getOperand(2).getReg())
2996+
.addUse(ImageReg)
2997+
.addUse(CoordinateReg)
29942998
.addUse(DataReg);
29952999
}
29963000

0 commit comments

Comments
 (0)