Skip to content

Commit 9235f0c

Browse files
victor-edssys-ce-bb
authored andcommitted
Insert OpVariable instructions after OpPhi (#2449)
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 <victor.perez@codeplay.com> Original commit: KhronosGroup/SPIRV-LLVM-Translator@af06f03bb85c1f4
1 parent f0cec1f commit 9235f0c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVBasicBlock.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ SPIRVInstruction *SPIRVBasicBlock::getVariableInsertionPoint() const {
9191
auto IP =
9292
std::find_if(InstVec.begin(), InstVec.end(), [](SPIRVInstruction *Inst) {
9393
return !(isa<OpVariable>(Inst) || isa<OpLine>(Inst) ||
94-
isa<OpNoLine>(Inst));
94+
isa<OpNoLine>(Inst) ||
95+
// Note: OpVariable and OpPhi instructions do not belong to the
96+
// same block in a valid SPIR-V module.
97+
isa<OpPhi>(Inst));
9598
});
9699
if (IP == InstVec.end())
97100
return nullptr;

0 commit comments

Comments
 (0)