Skip to content

Commit 04b6231

Browse files
detach from llvm#110653
1 parent 1d1021f commit 04b6231

File tree

2 files changed

+12
-283
lines changed

2 files changed

+12
-283
lines changed

llvm/lib/Target/SPIRV/SPIRVInstrInfo.cpp

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,9 @@ bool SPIRVInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
197197
} else if (MI->getOpcode() == SPIRV::OpBranchConditional) {
198198
Cond.push_back(MI->getOperand(0));
199199
TBB = MI->getOperand(1).getMBB();
200-
FBB = MI->getOperand(2).getMBB();
201-
for (unsigned I = 3, E = MI->getNumOperands(); I < E; ++I)
202-
Cond.push_back(MI->getOperand(I));
200+
if (MI->getNumOperands() == 3) {
201+
FBB = MI->getOperand(2).getMBB();
202+
}
203203
return false;
204204
} else {
205205
return true;
@@ -212,17 +212,9 @@ bool SPIRVInstrInfo::analyzeBranch(MachineBasicBlock &MBB,
212212
// If \p BytesRemoved is non-null, report the change in code size from the
213213
// removed instructions.
214214
unsigned SPIRVInstrInfo::removeBranch(MachineBasicBlock &MBB,
215-
int * /*BytesRemoved*/) const {
216-
MachineBasicBlock::iterator I = MBB.getLastNonDebugInstr();
217-
if (I == MBB.end())
218-
return 0;
219-
220-
unsigned Opcode = I->getOpcode();
221-
if (Opcode == SPIRV::OpBranch || Opcode == SPIRV::OpBranchConditional) {
222-
I->eraseFromParent();
223-
return 1;
224-
}
225-
return 0;
215+
int *BytesRemoved) const {
216+
report_fatal_error("Branch removal not supported, as MBB info not propagated"
217+
" to OpPhi instructions. Try using -O0 instead.");
226218
}
227219

228220
// Insert branch code into the end of the specified MachineBasicBlock. The
@@ -238,25 +230,12 @@ unsigned SPIRVInstrInfo::removeBranch(MachineBasicBlock &MBB,
238230
//
239231
// The CFG information in MBB.Predecessors and MBB.Successors must be valid
240232
// before calling this function.
241-
unsigned SPIRVInstrInfo::insertBranch(MachineBasicBlock &MBB,
242-
MachineBasicBlock *TBB,
243-
MachineBasicBlock *FBB,
244-
ArrayRef<MachineOperand> Cond,
245-
const DebugLoc &DL,
246-
int * /*BytesAdded*/) const {
247-
if (!TBB)
248-
return 0;
249-
if (Cond.empty()) {
250-
BuildMI(&MBB, DL, get(SPIRV::OpBranch)).addMBB(TBB);
251-
} else {
252-
auto MIB = BuildMI(&MBB, DL, get(SPIRV::OpBranchConditional))
253-
.add(Cond[0])
254-
.addMBB(TBB)
255-
.addMBB(FBB);
256-
for (unsigned i = 1; i < Cond.size(); ++i)
257-
MIB.add(Cond[i]);
258-
}
259-
return 1;
233+
unsigned SPIRVInstrInfo::insertBranch(
234+
MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB,
235+
ArrayRef<MachineOperand> Cond, const DebugLoc &DL, int *BytesAdded) const {
236+
report_fatal_error("Branch insertion not supported, as MBB info not "
237+
"propagated to OpPhi instructions. Try using "
238+
"-O0 instead.");
260239
}
261240

262241
void SPIRVInstrInfo::copyPhysReg(MachineBasicBlock &MBB,

llvm/test/CodeGen/SPIRV/branching/analyze-branch-opt.ll

Lines changed: 0 additions & 250 deletions
This file was deleted.

0 commit comments

Comments
 (0)