[PATCH] D68154: [Dominators][CodeGen] Fix MachineDominatorTree preservation in PHIElimination
Jakub Kuderski via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 12:09:44 PDT 2019
kuhar created this revision.
kuhar added reviewers: arsenm, hliao, alex-t, rampitec, vpykhtin.
Herald added subscribers: javed.absar, hiraditya, wdng, MatzeB.
Herald added a reviewer: grosser.
Herald added a project: LLVM.
PHIElimination modifies CFG and marks MachineDominatorTree as preserved. Therefore, it the CFG changes it should also update the MDT, when available. This patch teaches PHIElimination to recalculate MDT when necessary.
This fixes the `tailmerging_in_mbp.ll` test failure discovered after switching to generic DomTree verification algorithm in MachineDominators in D67976 <https://reviews.llvm.org/D67976>.
Repository:
rL LLVM
https://reviews.llvm.org/D68154
Files:
llvm/lib/CodeGen/MachineScheduler.cpp
llvm/lib/CodeGen/PHIElimination.cpp
llvm/test/CodeGen/AArch64/tailmerging_in_mbp.ll
Index: llvm/test/CodeGen/AArch64/tailmerging_in_mbp.ll
===================================================================
--- llvm/test/CodeGen/AArch64/tailmerging_in_mbp.ll
+++ llvm/test/CodeGen/AArch64/tailmerging_in_mbp.ll
@@ -1,5 +1,4 @@
; RUN: llc <%s -mtriple=aarch64-eabi -verify-machine-dom-info | FileCheck %s
-; XFAIL: *
; CHECK-LABEL: test:
; CHECK-LABEL: %cond.false12.i
Index: llvm/lib/CodeGen/PHIElimination.cpp
===================================================================
--- llvm/lib/CodeGen/PHIElimination.cpp
+++ llvm/lib/CodeGen/PHIElimination.cpp
@@ -148,6 +148,7 @@
MRI = &MF.getRegInfo();
LV = getAnalysisIfAvailable<LiveVariables>();
LIS = getAnalysisIfAvailable<LiveIntervals>();
+ auto *MDT = getAnalysisIfAvailable<MachineDominatorTree>();
bool Changed = false;
@@ -185,6 +186,9 @@
MF.DeleteMachineInstr(I.first);
}
+ if (Changed && MDT)
+ MDT->getBase().recalculate(MF);
+
LoweredPHIs.clear();
ImpDefs.clear();
VRegPHIUseCount.clear();
Index: llvm/lib/CodeGen/MachineScheduler.cpp
===================================================================
--- llvm/lib/CodeGen/MachineScheduler.cpp
+++ llvm/lib/CodeGen/MachineScheduler.cpp
@@ -198,6 +198,7 @@
INITIALIZE_PASS_BEGIN(MachineScheduler, DEBUG_TYPE,
"Machine Instruction Scheduler", false, false)
INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass)
+INITIALIZE_PASS_DEPENDENCY(MachineDominatorTree)
INITIALIZE_PASS_DEPENDENCY(MachineLoopInfo)
INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
@@ -210,7 +211,7 @@
void MachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
- AU.addRequiredID(MachineDominatorsID);
+ AU.addRequired<MachineDominatorTree>();
AU.addRequired<MachineLoopInfo>();
AU.addRequired<AAResultsWrapperPass>();
AU.addRequired<TargetPassConfig>();
@@ -234,7 +235,7 @@
void PostMachineScheduler::getAnalysisUsage(AnalysisUsage &AU) const {
AU.setPreservesCFG();
- AU.addRequiredID(MachineDominatorsID);
+ AU.addRequired<MachineDominatorTree>();
AU.addRequired<MachineLoopInfo>();
AU.addRequired<TargetPassConfig>();
MachineFunctionPass::getAnalysisUsage(AU);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68154.222223.patch
Type: text/x-patch
Size: 2232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190927/70c9e893/attachment.bin>
More information about the llvm-commits
mailing list