[llvm] [DebugInfo][RemoveDIs] Interpret DPValue objects in SelectionDAG (PR #72253)

via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 14 05:46:47 PST 2023


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff da843aa09f4cb5caab1cf0c802f2d203ada84c54 5c5d4cde58eea08348ff8a2c2d8125a5781bc261 -- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp llvm/tools/llc/llc.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 408c084ee4..f78535cd84 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1168,7 +1168,9 @@ void SelectionDAGBuilder::visitDbgInfo(const Instruction &I) {
         SmallVector<Value *, 4> Vals;
         for (Value *V : It->Values.location_ops())
           Vals.push_back(V);
-        addDanglingDebugInfo(Vals, FnVarLocs->getDILocalVariable(It->VariableID), It->Expr, Vals.size() > 1, It->DL, SDNodeOrder);
+        addDanglingDebugInfo(Vals,
+                             FnVarLocs->getDILocalVariable(It->VariableID),
+                             It->Expr, Vals.size() > 1, It->DL, SDNodeOrder);
       }
     }
   }
@@ -1183,20 +1185,24 @@ void SelectionDAGBuilder::visitDbgInfo(const Instruction &I) {
     // A DPValue with no locations is a kill location.
     SmallVector<Value *, 4> Values(DPV.location_ops());
     if (Values.empty()) {
-      handleKillDebugValue(Variable, Expression, DPV.getDebugLoc(), SDNodeOrder);
+      handleKillDebugValue(Variable, Expression, DPV.getDebugLoc(),
+                           SDNodeOrder);
       continue;
     }
 
     // A DPValue with an undef or absent location is also a kill location.
-    if (llvm::any_of(Values, [](Value *V) { return !V || isa<UndefValue>(V);})) {
-      handleKillDebugValue(Variable, Expression, DPV.getDebugLoc(), SDNodeOrder);
+    if (llvm::any_of(Values,
+                     [](Value *V) { return !V || isa<UndefValue>(V); })) {
+      handleKillDebugValue(Variable, Expression, DPV.getDebugLoc(),
+                           SDNodeOrder);
       continue;
     }
 
     bool IsVariadic = DPV.hasArgList();
     if (!handleDebugValue(Values, Variable, Expression, DPV.getDebugLoc(),
                           SDNodeOrder, IsVariadic)) {
-      addDanglingDebugInfo(Values, Variable, Expression, IsVariadic, DPV.getDebugLoc(), SDNodeOrder);
+      addDanglingDebugInfo(Values, Variable, Expression, IsVariadic,
+                           DPV.getDebugLoc(), SDNodeOrder);
     }
   }
 }
@@ -1267,7 +1273,7 @@ void SelectionDAGBuilder::visit(unsigned Opcode, const User &I) {
 static bool handleDanglingVariadicDebugInfo(SelectionDAG &DAG,
                                             DILocalVariable *Variable,
                                             DebugLoc DL, unsigned Order,
-                                            SmallVectorImpl<Value*> &Values,
+                                            SmallVectorImpl<Value *> &Values,
                                             DIExpression *Expression) {
   // For variadic dbg_values we will now insert an undef.
   // FIXME: We can potentially recover these!
@@ -1284,11 +1290,12 @@ static bool handleDanglingVariadicDebugInfo(SelectionDAG &DAG,
 }
 
 void SelectionDAGBuilder::addDanglingDebugInfo(SmallVectorImpl<Value *> &Values,
-                                               DILocalVariable *Var, DIExpression *Expr, bool IsVariadic,
-                                               DebugLoc DL, unsigned Order) {
+                                               DILocalVariable *Var,
+                                               DIExpression *Expr,
+                                               bool IsVariadic, DebugLoc DL,
+                                               unsigned Order) {
   if (IsVariadic) {
-    handleDanglingVariadicDebugInfo(
-          DAG, Var, DL, Order, Values, Expr);
+    handleDanglingVariadicDebugInfo(DAG, Var, DL, Order, Values, Expr);
     return;
   }
   // TODO: Dangling debug info will eventually either be resolved or produce
@@ -1307,8 +1314,8 @@ void SelectionDAGBuilder::dropDanglingDebugInfo(const DILocalVariable *Variable,
     DIVariable *DanglingVariable = DDI.getVariable();
     DIExpression *DanglingExpr = DDI.getExpression();
     if (DanglingVariable == Variable && Expr->fragmentsOverlap(DanglingExpr)) {
-      LLVM_DEBUG(dbgs() << "Dropping dangling debug info for " << printDDI(nullptr, DDI)
-                        << "\n");
+      LLVM_DEBUG(dbgs() << "Dropping dangling debug info for "
+                        << printDDI(nullptr, DDI) << "\n");
       return true;
     }
     return false;
@@ -1354,8 +1361,8 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V,
       // calling EmitFuncArgumentDbgValue here.
       if (!EmitFuncArgumentDbgValue(V, Variable, Expr, DL,
                                     FuncArgumentDbgValueKind::Value, Val)) {
-        LLVM_DEBUG(dbgs() << "Resolve dangling debug info for " << printDDI(V, DDI)
-                          << "\n");
+        LLVM_DEBUG(dbgs() << "Resolve dangling debug info for "
+                          << printDDI(V, DDI) << "\n");
         LLVM_DEBUG(dbgs() << "  By mapping to:\n    "; Val.dump());
         // Increase the SDNodeOrder for the DbgValue here to make sure it is
         // inserted after the definition of Val when emitting the instructions
@@ -1369,9 +1376,11 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V,
         DAG.AddDbgValue(SDV, false);
       } else
         LLVM_DEBUG(dbgs() << "Resolved dangling debug info for "
-                          << printDDI(V, DDI) << " in EmitFuncArgumentDbgValue\n");
+                          << printDDI(V, DDI)
+                          << " in EmitFuncArgumentDbgValue\n");
     } else {
-      LLVM_DEBUG(dbgs() << "Dropping debug info for " << printDDI(V, DDI) << "\n");
+      LLVM_DEBUG(dbgs() << "Dropping debug info for " << printDDI(V, DDI)
+                        << "\n");
       auto Undef = UndefValue::get(V->getType());
       auto SDV =
           DAG.getConstantDbgValue(Variable, Expr, Undef, DL, DbgSDNodeOrder);
@@ -1381,7 +1390,8 @@ void SelectionDAGBuilder::resolveDanglingDebugInfo(const Value *V,
   DDIV.clear();
 }
 
-void SelectionDAGBuilder::salvageUnresolvedDbgValue(const Value *V, DanglingDebugInfo &DDI) {
+void SelectionDAGBuilder::salvageUnresolvedDbgValue(const Value *V,
+                                                    DanglingDebugInfo &DDI) {
   // TODO: For the variadic implementation, instead of only checking the fail
   // state of `handleDebugValue`, we need know specifically which values were
   // invalid, so that we attempt to salvage only those values when processing
@@ -1408,7 +1418,7 @@ void SelectionDAGBuilder::salvageUnresolvedDbgValue(const Value *V, DanglingDebu
     // Temporary "0", awaiting real implementation.
     SmallVector<uint64_t, 16> Ops;
     SmallVector<Value *, 4> AdditionalValues;
-    V = salvageDebugInfoImpl(const_cast<Instruction&>(VAsInst),
+    V = salvageDebugInfoImpl(const_cast<Instruction &>(VAsInst),
                              Expr->getNumLocationOperands(), Ops,
                              AdditionalValues);
     // If we cannot salvage any further, and haven't yet found a suitable debug
@@ -1442,8 +1452,8 @@ void SelectionDAGBuilder::salvageUnresolvedDbgValue(const Value *V, DanglingDebu
   auto *Undef = UndefValue::get(OrigV->getType());
   auto *SDV = DAG.getConstantDbgValue(Var, Expr, Undef, DL, SDNodeOrder);
   DAG.AddDbgValue(SDV, false);
-  LLVM_DEBUG(dbgs() << "Dropping debug value info for:\n  " << printDDI(OrigV, DDI)
-                    << "\n");
+  LLVM_DEBUG(dbgs() << "Dropping debug value info for:\n  "
+                    << printDDI(OrigV, DDI) << "\n");
 }
 
 void SelectionDAGBuilder::handleKillDebugValue(DILocalVariable *Var,
@@ -1593,7 +1603,7 @@ void SelectionDAGBuilder::resolveOrClearDbgInfo() {
   // Try to fixup any remaining dangling debug info -- and drop it if we can't.
   for (auto &Pair : DanglingDebugInfoMap)
     for (auto &DDI : Pair.second)
-      salvageUnresolvedDbgValue(const_cast<Value*>(Pair.first), DDI);
+      salvageUnresolvedDbgValue(const_cast<Value *>(Pair.first), DDI);
   clearDanglingDebugInfo();
 }
 
@@ -6334,7 +6344,8 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
     bool IsVariadic = DI.hasArgList();
     if (!handleDebugValue(Values, Variable, Expression, DI.getDebugLoc(),
                           SDNodeOrder, IsVariadic))
-      addDanglingDebugInfo(Values, Variable, Expression, IsVariadic, DI.getDebugLoc(), SDNodeOrder);
+      addDanglingDebugInfo(Values, Variable, Expression, IsVariadic,
+                           DI.getDebugLoc(), SDNodeOrder);
     return;
   }
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index f49aab2c30..48a9f6c98c 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -113,26 +113,21 @@ class SelectionDAGBuilder {
     DIExpression *Expression;
     DebugLoc dl;
     DanglingDebugInfo() = default;
-    DanglingDebugInfo(DILocalVariable *Var, DIExpression *Expr, DebugLoc DL, unsigned SDNO)
-        : SDNodeOrder(SDNO), Variable(Var), Expression(Expr), dl(std::move(DL)) {}
-
-    DILocalVariable *getVariable() const {
-      return Variable;
-    }
-    DIExpression *getExpression() const {
-      return Expression;
-    }
-    DebugLoc getDebugLoc() const {
-      return dl;
-    }
+    DanglingDebugInfo(DILocalVariable *Var, DIExpression *Expr, DebugLoc DL,
+                      unsigned SDNO)
+        : SDNodeOrder(SDNO), Variable(Var), Expression(Expr),
+          dl(std::move(DL)) {}
+
+    DILocalVariable *getVariable() const { return Variable; }
+    DIExpression *getExpression() const { return Expression; }
+    DebugLoc getDebugLoc() const { return dl; }
     unsigned getSDNodeOrder() const { return SDNodeOrder; }
 
     /// Helper for printing DanglingDebugInfo. This hoop-jumping is to
     /// accommodate the fact that an argument is required for getVariable.
     /// Call SelectionDAGBuilder::printDDI instead of using directly.
     struct Print {
-      Print(const Value *V, const DanglingDebugInfo &DDI)
-          : V(V), DDI(DDI) {}
+      Print(const Value *V, const DanglingDebugInfo &DDI) : V(V), DDI(DDI) {}
       const Value *V;
       const DanglingDebugInfo &DDI;
       friend raw_ostream &operator<<(raw_ostream &OS,
@@ -154,7 +149,8 @@ class SelectionDAGBuilder {
   /// Returns an object that defines `raw_ostream &operator<<` for printing.
   /// Usage example:
   ////    errs() << printDDI(MyDanglingInfo) << " is dangling\n";
-  DanglingDebugInfo::Print printDDI(const Value *V, const DanglingDebugInfo &DDI) {
+  DanglingDebugInfo::Print printDDI(const Value *V,
+                                    const DanglingDebugInfo &DDI) {
     return DanglingDebugInfo::Print(V, DDI);
   }
 
@@ -344,8 +340,8 @@ public:
 
   /// Register a dbg_value which relies on a Value which we have not yet seen.
   void addDanglingDebugInfo(SmallVectorImpl<Value *> &Values,
-    DILocalVariable *Var, DIExpression *Expr, bool IsVariadic,
-                                                 DebugLoc DL, unsigned Order);
+                            DILocalVariable *Var, DIExpression *Expr,
+                            bool IsVariadic, DebugLoc DL, unsigned Order);
 
   /// If we have dangling debug info that describes \p Variable, or an
   /// overlapping part of variable considering the \p Expr, then this method
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index bf6298c752..e42032e121 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -225,8 +225,9 @@ namespace llvm {
       IS.TM.setOptLevel(NewOptLevel);
       LLVM_DEBUG(dbgs() << "\nChanging optimization level for Function "
                         << IS.MF->getFunction().getName() << "\n");
-      LLVM_DEBUG(dbgs() << "\tBefore: -O" << static_cast<int>(SavedOptLevel) << " ; After: -O"
-                        << static_cast<int>(NewOptLevel) << "\n");
+      LLVM_DEBUG(dbgs() << "\tBefore: -O" << static_cast<int>(SavedOptLevel)
+                        << " ; After: -O" << static_cast<int>(NewOptLevel)
+                        << "\n");
       if (NewOptLevel == CodeGenOptLevel::None) {
         IS.TM.setFastISel(IS.TM.getO0WantsFastISel());
         LLVM_DEBUG(
diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp
index 5d2af9c210..b569dbb09e 100644
--- a/llvm/tools/llc/llc.cpp
+++ b/llvm/tools/llc/llc.cpp
@@ -186,7 +186,8 @@ static cl::opt<std::string> RemarksFormat(
     cl::desc("The format used for serializing remarks (default: YAML)"),
     cl::value_desc("format"), cl::init("yaml"));
 
-static cl::opt<bool> TryUseNewDbgInfoFormat("try-experimental-debuginfo-iterators",
+static cl::opt<bool> TryUseNewDbgInfoFormat(
+    "try-experimental-debuginfo-iterators",
     cl::desc("Enable debuginfo iterator positions, if they're built in"),
     cl::init(false));
 
@@ -383,14 +384,14 @@ int main(int argc, char **argv) {
 
   cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
 
-   // RemoveDIs debug-info transition: tests may request that we /try/ to use the
-   // new debug-info format, if it's built in.
+  // RemoveDIs debug-info transition: tests may request that we /try/ to use the
+  // new debug-info format, if it's built in.
 #ifdef EXPERIMENTAL_DEBUGINFO_ITERATORS
   if (TryUseNewDbgInfoFormat) {
-     // If LLVM was built with support for this, turn the new debug-info format
-     // on.
-     UseNewDbgInfoFormat = true;
-   }
+    // If LLVM was built with support for this, turn the new debug-info format
+    // on.
+    UseNewDbgInfoFormat = true;
+  }
 #endif
   (void)TryUseNewDbgInfoFormat;
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/72253


More information about the llvm-commits mailing list