[llvm] 361c29d - [RDA] Avoid inserting duplicate reaching defs (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 7 08:50:48 PDT 2020
Author: Nikita Popov
Date: 2020-04-07T17:50:38+02:00
New Revision: 361c29d7ba55ee6fb762d36c08271375bb9f8c60
URL: https://github.com/llvm/llvm-project/commit/361c29d7ba55ee6fb762d36c08271375bb9f8c60
DIFF: https://github.com/llvm/llvm-project/commit/361c29d7ba55ee6fb762d36c08271375bb9f8c60.diff
LOG: [RDA] Avoid inserting duplicate reaching defs (NFCI)
An instruction may define the same reg unit multiple times,
avoid inserting the same reaching def multiple times in that case.
Also print the reg unit, rather than the super-register, in the
debug code.
Added:
Modified:
llvm/lib/CodeGen/ReachingDefAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index a143869c72c9..6ca8d5f07e30 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -65,8 +65,10 @@ void ReachingDefAnalysis::enterBasicBlock(
// Treat function live-ins as if they were defined just before the first
// instruction. Usually, function arguments are set up immediately
// before the call.
- LiveRegs[*Unit] = -1;
- MBBReachingDefs[MBBNumber][*Unit].push_back(LiveRegs[*Unit]);
+ if (LiveRegs[*Unit] != -1) {
+ LiveRegs[*Unit] = -1;
+ MBBReachingDefs[MBBNumber][*Unit].push_back(-1);
+ }
}
}
LLVM_DEBUG(dbgs() << printMBBReference(*MBB) << ": entry\n");
@@ -129,12 +131,14 @@ void ReachingDefAnalysis::processDefs(MachineInstr *MI) {
continue;
for (MCRegUnitIterator Unit(MO.getReg(), TRI); Unit.isValid(); ++Unit) {
// This instruction explicitly defines the current reg unit.
- LLVM_DEBUG(dbgs() << printReg(MO.getReg(), TRI) << ":\t" << CurInstr
+ LLVM_DEBUG(dbgs() << printReg(*Unit, TRI) << ":\t" << CurInstr
<< '\t' << *MI);
// How many instructions since this reg unit was last written?
- LiveRegs[*Unit] = CurInstr;
- MBBReachingDefs[MBBNumber][*Unit].push_back(CurInstr);
+ if (LiveRegs[*Unit] != CurInstr) {
+ LiveRegs[*Unit] = CurInstr;
+ MBBReachingDefs[MBBNumber][*Unit].push_back(CurInstr);
+ }
}
}
InstIds[MI] = CurInstr;
More information about the llvm-commits
mailing list