Skip to content

Commit f2981a3

Browse files
[SelectDagISEL] refactor HandlePHINodesInSuccessorBlocks NFC.
While working on this code to support outputs from callbr along indirect branches, I kept making these changes again and again. Precommit these. Reviewed By: craig.topper Differential Revision: https://reviews.llvm.org/D137445
1 parent 948fc66 commit f2981a3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10811,14 +10811,12 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
1081110811
void
1081210812
SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
1081310813
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
10814-
const Instruction *TI = LLVMBB->getTerminator();
1081510814

1081610815
SmallPtrSet<MachineBasicBlock *, 4> SuccsHandled;
1081710816

1081810817
// Check PHI nodes in successors that expect a value to be available from this
1081910818
// block.
10820-
for (unsigned succ = 0, e = TI->getNumSuccessors(); succ != e; ++succ) {
10821-
const BasicBlock *SuccBB = TI->getSuccessor(succ);
10819+
for (const BasicBlock *SuccBB : successors(LLVMBB->getTerminator())) {
1082210820
if (!isa<PHINode>(SuccBB->begin())) continue;
1082310821
MachineBasicBlock *SuccMBB = FuncInfo.MBBMap[SuccBB];
1082410822

@@ -10844,7 +10842,7 @@ SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
1084410842
unsigned Reg;
1084510843
const Value *PHIOp = PN.getIncomingValueForBlock(LLVMBB);
1084610844

10847-
if (const Constant *C = dyn_cast<Constant>(PHIOp)) {
10845+
if (const auto *C = dyn_cast<Constant>(PHIOp)) {
1084810846
unsigned &RegOut = ConstantsOut[C];
1084910847
if (RegOut == 0) {
1085010848
RegOut = FuncInfo.CreateRegs(C);
@@ -10875,10 +10873,9 @@ SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
1087510873
// the input for this MBB.
1087610874
SmallVector<EVT, 4> ValueVTs;
1087710875
ComputeValueVTs(TLI, DAG.getDataLayout(), PN.getType(), ValueVTs);
10878-
for (unsigned vti = 0, vte = ValueVTs.size(); vti != vte; ++vti) {
10879-
EVT VT = ValueVTs[vti];
10880-
unsigned NumRegisters = TLI.getNumRegisters(*DAG.getContext(), VT);
10881-
for (unsigned i = 0, e = NumRegisters; i != e; ++i)
10876+
for (EVT VT : ValueVTs) {
10877+
const unsigned NumRegisters = TLI.getNumRegisters(*DAG.getContext(), VT);
10878+
for (unsigned i = 0; i != NumRegisters; ++i)
1088210879
FuncInfo.PHINodesToUpdate.push_back(
1088310880
std::make_pair(&*MBBI++, Reg + i));
1088410881
Reg += NumRegisters;

0 commit comments

Comments
 (0)