Skip to content

Commit 435d636

Browse files
committed
Address code review feedback.
1 parent 4f91ce4 commit 435d636

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4029,7 +4029,7 @@ bool SPIRVInstructionSelector::selectModf(Register ResVReg,
40294029
GR.assignSPIRVTypeToVReg(PtrType, PtrTyReg, MIRBuilder.getMF());
40304030
MachineBasicBlock &EntryBB = I.getMF()->front();
40314031
MachineBasicBlock::iterator VarPos =
4032-
getPosForOpVariableWithinBlock(EntryBB);
4032+
getFirstValidInstructionInsertPoint(EntryBB);
40334033
auto AllocaMIB =
40344034
BuildMI(EntryBB, VarPos, I.getDebugLoc(), TII.get(SPIRV::OpVariable))
40354035
.addDef(PtrTyReg)

llvm/lib/Target/SPIRV/SPIRVUtils.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -996,7 +996,7 @@ unsigned getArrayComponentCount(const MachineRegisterInfo *MRI,
996996
}
997997

998998
MachineBasicBlock::iterator
999-
getPosForOpVariableWithinBlock(MachineBasicBlock &BB) {
999+
getFirstValidInstructionInsertPoint(MachineBasicBlock &BB) {
10001000
// Find the position to insert the OpVariable instruction.
10011001
// We will insert it after the last OpFunctionParameter, if any, or
10021002
// after OpFunction otherwise.
@@ -1014,7 +1014,8 @@ getPosForOpVariableWithinBlock(MachineBasicBlock &BB) {
10141014
}
10151015
// VarPos is now pointing at after the last OpFunctionParameter, if any,
10161016
// or after OpFunction, if no parameters.
1017-
return VarPos;
1017+
return VarPos != BB.end() && VarPos->getOpcode() == SPIRV::OpLabel ? ++VarPos
1018+
: VarPos;
10181019
}
10191020

10201021
} // namespace llvm

llvm/lib/Target/SPIRV/SPIRVUtils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ int64_t foldImm(const MachineOperand &MO, const MachineRegisterInfo *MRI);
507507
unsigned getArrayComponentCount(const MachineRegisterInfo *MRI,
508508
const MachineInstr *ResType);
509509
MachineBasicBlock::iterator
510-
getPosForOpVariableWithinBlock(MachineBasicBlock &BB);
510+
getFirstValidInstructionInsertPoint(MachineBasicBlock &BB);
511511

512512
} // namespace llvm
513513
#endif // LLVM_LIB_TARGET_SPIRV_SPIRVUTILS_H

0 commit comments

Comments
 (0)