[PATCH] D137445: [SelectDagISEL] refactor HandlePHINodesInSuccessorBlocks NFC.
Nick Desaulniers via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 4 10:02:58 PDT 2022
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: craig.topper.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nickdesaulniers requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
While working on this code to support outputs from callbr along indirect
branches, I kept making these changes again and again. Precommit these.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D137445
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -10811,14 +10811,12 @@
void
SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
- const Instruction *TI = LLVMBB->getTerminator();
SmallPtrSet<MachineBasicBlock *, 4> SuccsHandled;
// Check PHI nodes in successors that expect a value to be available from this
// block.
- for (unsigned succ = 0, e = TI->getNumSuccessors(); succ != e; ++succ) {
- const BasicBlock *SuccBB = TI->getSuccessor(succ);
+ for (const BasicBlock *SuccBB : successors(LLVMBB->getTerminator())) {
if (!isa<PHINode>(SuccBB->begin())) continue;
MachineBasicBlock *SuccMBB = FuncInfo.MBBMap[SuccBB];
@@ -10844,7 +10842,7 @@
unsigned Reg;
const Value *PHIOp = PN.getIncomingValueForBlock(LLVMBB);
- if (const Constant *C = dyn_cast<Constant>(PHIOp)) {
+ if (const auto *C = dyn_cast<Constant>(PHIOp)) {
unsigned &RegOut = ConstantsOut[C];
if (RegOut == 0) {
RegOut = FuncInfo.CreateRegs(C);
@@ -10875,10 +10873,9 @@
// the input for this MBB.
SmallVector<EVT, 4> ValueVTs;
ComputeValueVTs(TLI, DAG.getDataLayout(), PN.getType(), ValueVTs);
- for (unsigned vti = 0, vte = ValueVTs.size(); vti != vte; ++vti) {
- EVT VT = ValueVTs[vti];
- unsigned NumRegisters = TLI.getNumRegisters(*DAG.getContext(), VT);
- for (unsigned i = 0, e = NumRegisters; i != e; ++i)
+ for (EVT &VT : ValueVTs) {
+ const unsigned NumRegisters = TLI.getNumRegisters(*DAG.getContext(), VT);
+ for (unsigned i = 0; i != NumRegisters; ++i)
FuncInfo.PHINodesToUpdate.push_back(
std::make_pair(&*MBBI++, Reg + i));
Reg += NumRegisters;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137445.473277.patch
Type: text/x-patch
Size: 2001 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221104/91db6ff5/attachment.bin>
More information about the llvm-commits
mailing list