[PATCH] D88813: [CodeGen] Postprocess PHI nodes for callbr
Bill Wendling via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 5 02:37:13 PDT 2020
void created this revision.
void added reviewers: nickdesaulniers, jyknight, craig.topper, efriedma.
Herald added subscribers: llvm-commits, pengfei, hiraditya.
Herald added a project: LLVM.
void requested review of this revision.
When processing PHI nodes after a callbr, we need to make sure that the
PHI nodes on the default branch are resolved after the callbr (inserted
after INLINEASM_BR). The PHI node values on the indirect branches are
processed before the INLINEASM_BR.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D88813
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -783,7 +783,8 @@
void processIntegerCallValue(const Instruction &I,
SDValue Value, bool IsSigned);
- void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB);
+ void HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB,
+ bool FirstIter);
void emitInlineAsmError(const CallBase &Call, const Twine &Message);
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1101,6 +1101,7 @@
CopyToExportRegsIfNeeded(&I);
CurInst = nullptr;
+ ConstantsOut.clear();
}
void SelectionDAGBuilder::visitPHI(const PHINode &) {
@@ -9994,8 +9995,8 @@
/// directly add them, because expansion might result in multiple MBB's for one
/// BB. As such, the start of the BB might correspond to a different MBB than
/// the end.
-void
-SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(const BasicBlock *LLVMBB) {
+void SelectionDAGBuilder::HandlePHINodesInSuccessorBlocks(
+ const BasicBlock *LLVMBB, bool FirstIter) {
const Instruction *TI = LLVMBB->getTerminator();
SmallPtrSet<MachineBasicBlock *, 4> SuccsHandled;
@@ -10005,6 +10006,21 @@
for (unsigned succ = 0, e = TI->getNumSuccessors(); succ != e; ++succ) {
const BasicBlock *SuccBB = TI->getSuccessor(succ);
if (!isa<PHINode>(SuccBB->begin())) continue;
+
+ if (CI) {
+ if (FirstIter) {
+ // Don't push PHI node values back before an INLINEASM_BR instruction on
+ // the default branch.
+ if (SuccBB == CI->getDefaultDest())
+ continue;
+ } else {
+ // Don't push PHI node values back after an INLINEASM_BR instruction on
+ // the indirect branch.
+ if (SuccBB != CI->getDefaultDest())
+ continue;
+ }
+ }
+
MachineBasicBlock *SuccMBB = FuncInfo.MBBMap[SuccBB];
// If this terminator has multiple identical successors (common for
@@ -10065,8 +10081,6 @@
}
}
}
-
- ConstantsOut.clear();
}
/// Add a successor MBB to ParentMBB< creating a new MachineBB for BB if SuccMBB
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88813.296126.patch
Type: text/x-patch
Size: 2492 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201005/3f852e95/attachment.bin>
More information about the llvm-commits
mailing list