[PATCH] D151332: [FastISel][NFC] Remove repeated calls to get{Variable,Expr}Depends on D151331

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 06:18:19 PDT 2023


fdeazeve created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

aprantl


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D151332

Files:
  llvm/lib/CodeGen/SelectionDAG/FastISel.cpp


Index: llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1272,31 +1272,32 @@
     const DbgValueInst *DI = cast<DbgValueInst>(II);
     const MCInstrDesc &II = TII.get(TargetOpcode::DBG_VALUE);
     const Value *V = DI->getValue();
-    assert(DI->getVariable()->isValidLocationForIntrinsic(MIMD.getDL()) &&
+    DIExpression *Expr = DI->getExpression();
+    DILocalVariable *Var = DI->getVariable();
+    assert(Var->isValidLocationForIntrinsic(MIMD.getDL()) &&
            "Expected inlined-at fields to agree");
     if (!V || isa<UndefValue>(V) || DI->hasArgList()) {
       // DI is either undef or cannot produce a valid DBG_VALUE, so produce an
       // undef DBG_VALUE to terminate any prior location.
       BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(), II, false, 0U,
-              DI->getVariable(), DI->getExpression());
+              Var, Expr);
       return true;
     }
     if (const auto *CI = dyn_cast<ConstantInt>(V)) {
       // See if there's an expression to constant-fold.
-      DIExpression *Expr = DI->getExpression();
       if (Expr)
         std::tie(Expr, CI) = Expr->constantFold(CI);
       if (CI->getBitWidth() > 64)
         BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II)
             .addCImm(CI)
             .addImm(0U)
-            .addMetadata(DI->getVariable())
+            .addMetadata(Var)
             .addMetadata(Expr);
       else
         BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II)
             .addImm(CI->getZExtValue())
             .addImm(0U)
-            .addMetadata(DI->getVariable())
+            .addMetadata(Var)
             .addMetadata(Expr);
       return true;
     }
@@ -1304,8 +1305,8 @@
       BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, II)
           .addFPImm(CF)
           .addImm(0U)
-          .addMetadata(DI->getVariable())
-          .addMetadata(DI->getExpression());
+          .addMetadata(Var)
+          .addMetadata(Expr);
       return true;
     }
     if (Register Reg = lookUpRegForValue(V)) {
@@ -1313,7 +1314,7 @@
       if (!FuncInfo.MF->useDebugInstrRef()) {
         bool IsIndirect = false;
         BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(), II, IsIndirect,
-                Reg, DI->getVariable(), DI->getExpression());
+                Reg, Var, Expr);
         return true;
       }
       // If using instruction referencing, produce this as a DBG_INSTR_REF,
@@ -1324,10 +1325,10 @@
           /* isUndef */ false, /* isEarlyClobber */ false,
           /* SubReg */ 0, /* isDebug */ true)});
       SmallVector<uint64_t, 2> Ops({dwarf::DW_OP_LLVM_arg, 0});
-      auto *NewExpr = DIExpression::prependOpcodes(DI->getExpression(), Ops);
+      auto *NewExpr = DIExpression::prependOpcodes(Expr, Ops);
       BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD.getDL(),
               TII.get(TargetOpcode::DBG_INSTR_REF), /*IsIndirect*/ false, MOs,
-              DI->getVariable(), NewExpr);
+              Var, NewExpr);
       return true;
     }
     // We don't know how to handle other cases, so we drop.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151332.525144.patch
Type: text/x-patch
Size: 3210 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230524/5835c240/attachment.bin>


More information about the llvm-commits mailing list