[llvm] 85a5c65 - [NFC][RDA] Add explicit def check

Sam Parker via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 00:38:01 PDT 2020


Author: Sam Parker
Date: 2020-08-25T08:37:45+01:00
New Revision: 85a5c65f695deb13787889658cfcfbbfc1a42664

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

LOG: [NFC][RDA] Add explicit def check

Explicitly check that there is a local def prior to the given
instruction in getReachingLocalMIDef instead of just relying on
a nullptr return from getInstFromId.

Added: 
    

Modified: 
    llvm/lib/CodeGen/ReachingDefAnalysis.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
index dd70f91d481f..4e18c7deb3eb 100644
--- a/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
+++ b/llvm/lib/CodeGen/ReachingDefAnalysis.cpp
@@ -272,8 +272,10 @@ int ReachingDefAnalysis::getReachingDef(MachineInstr *MI, int PhysReg) const {
 }
 
 MachineInstr* ReachingDefAnalysis::getReachingLocalMIDef(MachineInstr *MI,
-                                                    int PhysReg) const {
-  return getInstFromId(MI->getParent(), getReachingDef(MI, PhysReg));
+                                                         int PhysReg) const {
+  return hasLocalDefBefore(MI, PhysReg)
+    ? getInstFromId(MI->getParent(), getReachingDef(MI, PhysReg))
+    : nullptr;
 }
 
 bool ReachingDefAnalysis::hasSameReachingDef(MachineInstr *A, MachineInstr *B,


        


More information about the llvm-commits mailing list