[llvm] c23b35a - [FastISel][NFC] Remove repeated calls to get{Variable, Expr}

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Fri May 26 04:12:11 PDT 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-05-26T07:10:58-04:00
New Revision: c23b35a224d889acbdfd828ac7f0420d2ad2ad03

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

LOG: [FastISel][NFC] Remove repeated calls to get{Variable,Expr}

This will make it easy to reuse these values in subsequent commits.

Depends on D151331

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
index 8a8aaad1bea1..abad7adfaae6 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
@@ -1272,31 +1272,32 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
     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 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
       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 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
       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 @@ bool FastISel::selectIntrinsicCall(const IntrinsicInst *II) {
           /* 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.


        


More information about the llvm-commits mailing list