[llvm] aa99da5 - Avoid binding pointers to "auto&" (by dereferencing the pointer that's non-null anyway)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 11:40:14 PDT 2020


Author: David Blaikie
Date: 2020-05-12T11:40:00-07:00
New Revision: aa99da5ace4587440973c97a4cd5f486e7bb3c33

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

LOG: Avoid binding pointers to "auto&" (by dereferencing the pointer that's non-null anyway)

Based on @djtodoro's 2552dc5317e0

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 25b973ec836c..aefa94cec24c 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -652,9 +652,9 @@ static void collectCallSiteParameters(const MachineInstr *CallMI,
     return;
 
   auto *MBB = CallMI->getParent();
-  const auto &TRI = MF->getSubtarget().getRegisterInfo();
-  const auto &TII = MF->getSubtarget().getInstrInfo();
-  const auto &TLI = MF->getSubtarget().getTargetLowering();
+  const auto &TRI = *MF->getSubtarget().getRegisterInfo();
+  const auto &TII = *MF->getSubtarget().getInstrInfo();
+  const auto &TLI = *MF->getSubtarget().getTargetLowering();
 
   // Skip the call instruction.
   auto I = std::next(CallMI->getReverseIterator());
@@ -715,7 +715,7 @@ static void collectCallSiteParameters(const MachineInstr *CallMI,
       if (MO.isReg() && MO.isDef() &&
           Register::isPhysicalRegister(MO.getReg())) {
         for (auto FwdReg : ForwardedRegWorklist)
-          if (TRI->regsOverlap(FwdReg.first, MO.getReg()))
+          if (TRI.regsOverlap(FwdReg.first, MO.getReg()))
             Defs.insert(FwdReg.first);
       }
     }
@@ -743,17 +743,17 @@ static void collectCallSiteParameters(const MachineInstr *CallMI,
       continue;
 
     for (auto ParamFwdReg : FwdRegDefs) {
-      if (auto ParamValue = TII->describeLoadedValue(*I, ParamFwdReg)) {
+      if (auto ParamValue = TII.describeLoadedValue(*I, ParamFwdReg)) {
         if (ParamValue->first.isImm()) {
           int64_t Val = ParamValue->first.getImm();
           finishCallSiteParams(Val, ParamValue->second,
                                ForwardedRegWorklist[ParamFwdReg], Params);
         } else if (ParamValue->first.isReg()) {
           Register RegLoc = ParamValue->first.getReg();
-          unsigned SP = TLI->getStackPointerRegisterToSaveRestore();
-          Register FP = TRI->getFrameRegister(*MF);
+          unsigned SP = TLI.getStackPointerRegisterToSaveRestore();
+          Register FP = TRI.getFrameRegister(*MF);
           bool IsSPorFP = (RegLoc == SP) || (RegLoc == FP);
-          if (TRI->isCalleeSavedPhysReg(RegLoc, *MF) || IsSPorFP) {
+          if (TRI.isCalleeSavedPhysReg(RegLoc, *MF) || IsSPorFP) {
             MachineLocation MLoc(RegLoc, /*IsIndirect=*/IsSPorFP);
             finishCallSiteParams(MLoc, ParamValue->second,
                                  ForwardedRegWorklist[ParamFwdReg], Params);


        


More information about the llvm-commits mailing list