diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-04-05 21:09:49 +0200 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-04-07 17:50:38 +0200 |
commit | 361c29d7ba55ee6fb762d36c08271375bb9f8c60 (patch) | |
tree | 79dbbec098719992e764b60dd4ea3487fff2b78d /llvm/lib/CodeGen/ReachingDefAnalysis.cpp | |
parent | b9245f14b799855a7b81010793ec5368e65d0f0f (diff) | |
download | llvm-361c29d7ba55ee6fb762d36c08271375bb9f8c60.zip llvm-361c29d7ba55ee6fb762d36c08271375bb9f8c60.tar.gz llvm-361c29d7ba55ee6fb762d36c08271375bb9f8c60.tar.bz2 |
[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.
Diffstat (limited to 'llvm/lib/CodeGen/ReachingDefAnalysis.cpp')
-rw-r--r-- | llvm/lib/CodeGen/ReachingDefAnalysis.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp index a143869..6ca8d5f 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; |