Skip to content

Commit

Permalink
Insert OpVariable instructions after OpPhi (#2449)
Browse files Browse the repository at this point in the history
Although `OpPhi` and `OpVariable` instructions should not be in the
same SPIR-V block in a valid module, take into account this case when
inserting new `OpVariable` operations.

Signed-off-by: Victor Perez <[email protected]>
  • Loading branch information
victor-eds authored Mar 20, 2024
1 parent ee0b560 commit af06f03
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ SPIRVInstruction *SPIRVBasicBlock::getVariableInsertionPoint() const {
auto IP =
std::find_if(InstVec.begin(), InstVec.end(), [](SPIRVInstruction *Inst) {
return !(isa<OpVariable>(Inst) || isa<OpLine>(Inst) ||
isa<OpNoLine>(Inst));
isa<OpNoLine>(Inst) ||
// Note: OpVariable and OpPhi instructions do not belong to the
// same block in a valid SPIR-V module.
isa<OpPhi>(Inst));
});
if (IP == InstVec.end())
return nullptr;
Expand Down

0 comments on commit af06f03

Please sign in to comment.