[llvm] 85dd852 - [RDA] Don't visit the BB of the instruction in getReachingUniqueMIDef

Sam Tebbs via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 04:41:02 PDT 2020


Author: Sam Tebbs
Date: 2020-08-26T12:40:39+01:00
New Revision: 85dd852a0d46684883fe3b4b19e780ba5d915b06

URL: https://github.com/llvm/llvm-project/commit/85dd852a0d46684883fe3b4b19e780ba5d915b06
DIFF: https://github.com/llvm/llvm-project/commit/85dd852a0d46684883fe3b4b19e780ba5d915b06.diff

LOG: [RDA] Don't visit the BB of the instruction in getReachingUniqueMIDef

If the basic block of the instruction passed to getUniqueReachingMIDef
is a transitive predecessor of itself and has a definition of the
register, the function will return that definition even if it is after
the instruction given to the function. This patch stops the function
from scanning the instruction's basic block to prevent this.

Differential Revision: https://reviews.llvm.org/D86607

Added: 
    

Modified: 
    llvm/lib/CodeGen/ReachingDefAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index 4e18c7deb3eb..cb53ea47e79f 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -423,7 +423,9 @@ MachineInstr *ReachingDefAnalysis::getUniqueReachingMIDef(MachineInstr *MI,
 
   SmallPtrSet<MachineBasicBlock*, 4> VisitedBBs;
   SmallPtrSet<MachineInstr*, 2> Incoming;
-  for (auto *Pred : MI->getParent()->predecessors())
+  MachineBasicBlock *Parent = MI->getParent();
+  VisitedBBs.insert(Parent);
+  for (auto *Pred : Parent->predecessors())
     getLiveOuts(Pred, PhysReg, Incoming, VisitedBBs);
 
   // If we have a local def and an incoming instruction, then there's not a


        


More information about the llvm-commits mailing list