Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DebugInfo][RemoveDIs] Handle dbg.declares in SelectionDAGISel #73496

Merged
merged 7 commits into from
Dec 12, 2023

Conversation

OCHyams
Copy link
Contributor

@OCHyams OCHyams commented Nov 27, 2023

This is a boring mechanical update to support DPValues that look like dbg.declares in SelectionDAG.


The only question I have is, how many tests should get upgraded with --try-experimental-debuginfo-iterators? The set that's included in this patch is arbitrary-ish -- I tried to pick ones that looked like they were probably testing the SelectionDAGBuilder specifically, but a bunch more snuck in too. Should I add it to all MIR tests that include a dbg.declare?

This is a boring mechanical update to support DPValues in SelectionDAG.
@llvmbot
Copy link
Collaborator

llvmbot commented Nov 27, 2023

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-llvm-selectiondag

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

This is a boring mechanical update to support DPValues that look like dbg.declares in SelectionDAG.


The only question I have is, how many tests should get upgraded with --try-experimental-debuginfo-iterators? The set that's included in this patch is arbitrary-ish -- I tried to pick ones that looked like they were probably testing the SelectionDAGBuilder specifically, but a bunch more snuck in too. Should I add it to all MIR tests that include a dbg.declare?


Patch is 24.54 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/73496.diff

26 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/FunctionLoweringInfo.h (+1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (+1)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+68-52)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h (+3)
  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (+8)
  • (modified) llvm/test/CodeGen/X86/dbg-combine.ll (+1)
  • (modified) llvm/test/CodeGen/X86/selectiondag-order.ll (+1)
  • (modified) llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll (+1)
  • (modified) llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll (+1)
  • (modified) llvm/test/DebugInfo/X86/DW_AT_const_value.ll (+1)
  • (modified) llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll (+1)
  • (modified) llvm/test/DebugInfo/X86/block-capture.ll (+3)
  • (modified) llvm/test/DebugInfo/X86/dbg-empty-metadata-lowering.ll (+6)
  • (modified) llvm/test/DebugInfo/X86/debug-info-block-captured-self.ll (+3)
  • (modified) llvm/test/DebugInfo/X86/debug-info-blocks.ll (+3)
  • (modified) llvm/test/DebugInfo/X86/empty-metadata-dbg-declare.ll (+1)
  • (modified) llvm/test/DebugInfo/X86/pieces-3.ll (+1)
  • (modified) llvm/test/DebugInfo/X86/pieces-4.ll (+2)
  • (modified) llvm/test/DebugInfo/X86/safestack-byval.ll (+2)
  • (modified) llvm/test/DebugInfo/X86/salvage-add-node-indirect.ll (+1)
  • (modified) llvm/test/DebugInfo/X86/spill-indirect-nrvo.ll (+5-1)
  • (modified) llvm/test/DebugInfo/X86/spill-nontrivial-param.ll (+2)
  • (modified) llvm/test/DebugInfo/X86/sret.ll (+2)
  • (modified) llvm/test/DebugInfo/X86/union-const.ll (+2)
  • (modified) llvm/test/DebugInfo/X86/vla-global.ll (+2)
  • (modified) llvm/test/DebugInfo/X86/vla-multi.ll (+2)
diff --git a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
index 4c17e8dcc41a66e..79fcedd5dfc166a 100644
--- a/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/FunctionLoweringInfo.h
@@ -191,6 +191,7 @@ class FunctionLoweringInfo {
   /// Collection of dbg.declare instructions handled after argument
   /// lowering and before ISel proper.
   SmallPtrSet<const DbgDeclareInst *, 8> PreprocessedDbgDeclares;
+  SmallPtrSet<const DPValue *, 8> PreprocessedDPVs;
 
   /// set - Initialize this FunctionLoweringInfo with the given Function
   /// and its associated MachineFunction.
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
index 1d0a03ccfcdc6ae..2cb790590ae2dda 100644
--- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
@@ -350,6 +350,7 @@ void FunctionLoweringInfo::clear() {
   StatepointRelocationMaps.clear();
   PreferredExtendType.clear();
   PreprocessedDbgDeclares.clear();
+  PreprocessedDPVs.clear();
 }
 
 /// CreateReg - Allocate a single virtual register for the given type.
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index da7d9ace4114a62..0e3f0c86538d915 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1148,6 +1148,60 @@ SDValue SelectionDAGBuilder::getControlRoot() {
   return updateRoot(PendingExports);
 }
 
+void SelectionDAGBuilder::handleDebugDeclare(Value *Address,
+                                             DILocalVariable *Variable,
+                                             DIExpression *Expression,
+                                             DebugLoc dl) {
+  assert(Variable && "Missing variable");
+
+  // Check if address has undef value.
+  if (!Address || isa<UndefValue>(Address) ||
+      (Address->use_empty() && !isa<Argument>(Address))) {
+    LLVM_DEBUG(
+        dbgs()
+        << "dbg_declare: Dropping debug info (bad/undef/unused-arg address)\n");
+    return;
+  }
+
+  bool isParameter = Variable->isParameter() || isa<Argument>(Address);
+
+  SDValue &N = NodeMap[Address];
+  if (!N.getNode() && isa<Argument>(Address))
+    // Check unused arguments map.
+    N = UnusedArgNodeMap[Address];
+  SDDbgValue *SDV;
+  if (N.getNode()) {
+    if (const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
+      Address = BCI->getOperand(0);
+    // Parameters are handled specially.
+    auto FINode = dyn_cast<FrameIndexSDNode>(N.getNode());
+    if (isParameter && FINode) {
+      // Byval parameter. We have a frame index at this point.
+      SDV = DAG.getFrameIndexDbgValue(Variable, Expression, FINode->getIndex(),
+                                      /*IsIndirect*/ true, dl, SDNodeOrder);
+    } else if (isa<Argument>(Address)) {
+      // Address is an argument, so try to emit its dbg value using
+      // virtual register info from the FuncInfo.ValueMap.
+      EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
+                               FuncArgumentDbgValueKind::Declare, N);
+      return;
+    } else {
+      SDV = DAG.getDbgValue(Variable, Expression, N.getNode(), N.getResNo(),
+                            true, dl, SDNodeOrder);
+    }
+    DAG.AddDbgValue(SDV, isParameter);
+  } else {
+    // If Address is an argument then try to emit its dbg value using
+    // virtual register info from the FuncInfo.ValueMap.
+    if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
+                                  FuncArgumentDbgValueKind::Declare, N)) {
+      LLVM_DEBUG(dbgs() << "dbg_declare: Dropping debug info"
+                        << " (could not emit func-arg dbg_value)\n");
+    }
+  }
+  return;
+}
+
 void SelectionDAGBuilder::visitDbgInfo(const Instruction &I) {
   // Add SDDbgValue nodes for any var locs here. Do so before updating
   // SDNodeOrder, as this mapping is {Inst -> Locs BEFORE Inst}.
@@ -1182,6 +1236,14 @@ void SelectionDAGBuilder::visitDbgInfo(const Instruction &I) {
     DIExpression *Expression = DPV.getExpression();
     dropDanglingDebugInfo(Variable, Expression);
 
+    if (DPV.getType() == DPValue::LocationType::Declare) {
+      LLVM_DEBUG(dbgs() << "SelectionDAG visiting dbg_declare: " << DPV
+                        << "\n");
+      handleDebugDeclare(DPV.getVariableLocationOp(0), Variable, Expression,
+                         DPV.getDebugLoc());
+      continue;
+    }
+
     // A DPValue with no locations is a kill location.
     SmallVector<Value *, 4> Values(DPV.location_ops());
     if (Values.empty()) {
@@ -6243,61 +6305,15 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
     if (AssignmentTrackingEnabled ||
         FuncInfo.PreprocessedDbgDeclares.count(&DI))
       return;
-    // Assume dbg.declare can not currently use DIArgList, i.e.
-    // it is non-variadic.
-    assert(!DI.hasArgList() && "Only dbg.value should currently use DIArgList");
+    LLVM_DEBUG(dbgs() << "SelectionDAG visiting dbg_declare: " << DI << "\n");
     DILocalVariable *Variable = DI.getVariable();
     DIExpression *Expression = DI.getExpression();
     dropDanglingDebugInfo(Variable, Expression);
-    assert(Variable && "Missing variable");
-    LLVM_DEBUG(dbgs() << "SelectionDAG visiting debug intrinsic: " << DI
-                      << "\n");
-    // Check if address has undef value.
-    const Value *Address = DI.getVariableLocationOp(0);
-    if (!Address || isa<UndefValue>(Address) ||
-        (Address->use_empty() && !isa<Argument>(Address))) {
-      LLVM_DEBUG(dbgs() << "Dropping debug info for " << DI
-                        << " (bad/undef/unused-arg address)\n");
-      return;
-    }
-
-    bool isParameter = Variable->isParameter() || isa<Argument>(Address);
-
-    SDValue &N = NodeMap[Address];
-    if (!N.getNode() && isa<Argument>(Address))
-      // Check unused arguments map.
-      N = UnusedArgNodeMap[Address];
-    SDDbgValue *SDV;
-    if (N.getNode()) {
-      if (const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
-        Address = BCI->getOperand(0);
-      // Parameters are handled specially.
-      auto FINode = dyn_cast<FrameIndexSDNode>(N.getNode());
-      if (isParameter && FINode) {
-        // Byval parameter. We have a frame index at this point.
-        SDV =
-            DAG.getFrameIndexDbgValue(Variable, Expression, FINode->getIndex(),
-                                      /*IsIndirect*/ true, dl, SDNodeOrder);
-      } else if (isa<Argument>(Address)) {
-        // Address is an argument, so try to emit its dbg value using
-        // virtual register info from the FuncInfo.ValueMap.
-        EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
-                                 FuncArgumentDbgValueKind::Declare, N);
-        return;
-      } else {
-        SDV = DAG.getDbgValue(Variable, Expression, N.getNode(), N.getResNo(),
-                              true, dl, SDNodeOrder);
-      }
-      DAG.AddDbgValue(SDV, isParameter);
-    } else {
-      // If Address is an argument then try to emit its dbg value using
-      // virtual register info from the FuncInfo.ValueMap.
-      if (!EmitFuncArgumentDbgValue(Address, Variable, Expression, dl,
-                                    FuncArgumentDbgValueKind::Declare, N)) {
-        LLVM_DEBUG(dbgs() << "Dropping debug info for " << DI
-                          << " (could not emit func-arg dbg_value)\n");
-      }
-    }
+    // Assume dbg.declare can not currently use DIArgList, i.e.
+    // it is non-variadic.
+    assert(!DI.hasArgList() && "Only dbg.value should currently use DIArgList");
+    handleDebugDeclare(DI.getVariableLocationOp(0), Variable,
+                       Expression, DI.getDebugLoc());
     return;
   }
   case Intrinsic::dbg_label: {
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
index 5b55c3461b0b672..2e102c002c093ee 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
@@ -368,6 +368,9 @@ class SelectionDAGBuilder {
   void handleKillDebugValue(DILocalVariable *Var, DIExpression *Expr,
                             DebugLoc DbgLoc, unsigned Order);
 
+  void handleDebugDeclare(Value *Address, DILocalVariable *Variable,
+                          DIExpression *Expression, DebugLoc DL);
+
   /// Evict any dangling debug information, attempting to salvage it first.
   void resolveOrClearDbgInfo();
 
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index a0af6faa7fbcefb..45e1815161272bf 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -1461,6 +1461,14 @@ static void processDbgDeclares(FunctionLoweringInfo &FuncInfo) {
     if (DI && processDbgDeclare(FuncInfo, DI->getAddress(), DI->getExpression(),
                                 DI->getVariable(), DI->getDebugLoc()))
       FuncInfo.PreprocessedDbgDeclares.insert(DI);
+
+    for (const DPValue &DPV : I.getDbgValueRange()) {
+      if (DPV.getType() == DPValue::LocationType::Declare &&
+          processDbgDeclare(FuncInfo, DPV.getVariableLocationOp(0),
+                            DPV.getExpression(), DPV.getVariable(),
+                            DPV.getDebugLoc()))
+        FuncInfo.PreprocessedDPVs.insert(&DPV);
+    }
   }
 }
 
diff --git a/llvm/test/CodeGen/X86/dbg-combine.ll b/llvm/test/CodeGen/X86/dbg-combine.ll
index b3d2213b90c0a61..d6065f1318ae050 100644
--- a/llvm/test/CodeGen/X86/dbg-combine.ll
+++ b/llvm/test/CodeGen/X86/dbg-combine.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple x86_64-pc-linux -O0 < %s | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple x86_64-pc-linux -O0 < %s | FileCheck %s
 
 ; Make sure that the sequence of debug locations for function foo is correctly
 ; generated. More specifically, .loc entries for lines 4,5,6,7 must appear in
diff --git a/llvm/test/CodeGen/X86/selectiondag-order.ll b/llvm/test/CodeGen/X86/selectiondag-order.ll
index 163e2cb90b2febd..417b12bbd73f17b 100644
--- a/llvm/test/CodeGen/X86/selectiondag-order.ll
+++ b/llvm/test/CodeGen/X86/selectiondag-order.ll
@@ -1,6 +1,7 @@
 ; Check that debug intrinsics do not affect code generation.
 
 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck --check-prefix=X86-CHECK %s
+; RUN: llc --try-experimental-debuginfo-iterators < %s -mtriple=x86_64-unknown-unknown -mattr=+avx | FileCheck --check-prefix=X86-CHECK %s
 
 define i64 @simulate(<2 x i32> %a) {
 entry:
diff --git a/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll b/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll
index 87d75c16dd8e34e..2a5d5e776b9347a 100644
--- a/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll
+++ b/llvm/test/DebugInfo/Generic/2010-06-29-InlinedFnLocalVar.ll
@@ -1,4 +1,5 @@
 ; RUN: %llc_dwarf -O2 %s -o - | FileCheck %s
+; RUN: %llc_dwarf --try-experimental-debuginfo-iterators -O2 %s -o - | FileCheck %s
 ; Check struct X for dead variable xyz from inlined function foo.
 
 ; CHECK: {{.section.*debug_info|.*dwinfo:}}
diff --git a/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll b/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll
index 9e5bc3ed0db5886..d4d0ec2d813ca90 100644
--- a/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll
+++ b/llvm/test/DebugInfo/Mips/InlinedFnLocalVar.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple mips-linux-gnu -O2 %s -o - | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple mips-linux-gnu -O2 %s -o - | FileCheck %s
 ; Check struct X for dead variable xyz from inlined function foo.
 
 ; CHECK: .section .debug_info,"",@0x7000001e
diff --git a/llvm/test/DebugInfo/X86/DW_AT_const_value.ll b/llvm/test/DebugInfo/X86/DW_AT_const_value.ll
index 39d718a457d3534..ecb423a0a113946 100644
--- a/llvm/test/DebugInfo/X86/DW_AT_const_value.ll
+++ b/llvm/test/DebugInfo/X86/DW_AT_const_value.ll
@@ -1,4 +1,5 @@
 ; RUN: llc %s -o - | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators %s -o - | FileCheck %s
 
 ;; Check single location variables of various types with a constant value are
 ;; emitted with a DW_AT_const_value attribute.
diff --git a/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll b/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll
index 7f659bf9042a9d7..0b27ec8194a1cd6 100644
--- a/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll
+++ b/llvm/test/DebugInfo/X86/InlinedFnLocalVar.ll
@@ -1,4 +1,5 @@
 ; RUN: llc -mtriple i686-pc-cygwin -O2 %s -o - | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple i686-pc-cygwin -O2 %s -o - | FileCheck %s
 ; Check struct X for dead variable xyz from inlined function foo.
 
 ; CHECK: Lsection_info
diff --git a/llvm/test/DebugInfo/X86/block-capture.ll b/llvm/test/DebugInfo/X86/block-capture.ll
index f78ce32fb34aee0..585526fea148c0c 100644
--- a/llvm/test/DebugInfo/X86/block-capture.ll
+++ b/llvm/test/DebugInfo/X86/block-capture.ll
@@ -1,6 +1,9 @@
 ; RUN: llc %s -o %t -filetype=obj
 ; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
 
+; RUN: llc --try-experimental-debuginfo-iterators %s -o %t -filetype=obj
+; RUN: llvm-dwarfdump -v -debug-info %t | FileCheck %s
+
 ; Checks that we emit debug info for the block variable declare.
 ; CHECK: DW_TAG_subprogram
 ; CHECK: DW_TAG_variable
diff --git a/llvm/test/DebugInfo/X86/dbg-empty-metadata-lowering.ll b/llvm/test/DebugInfo/X86/dbg-empty-metadata-lowering.ll
index b98e99c53dfe613..a5edac3ead5046f 100644
--- a/llvm/test/DebugInfo/X86/dbg-empty-metadata-lowering.ll
+++ b/llvm/test/DebugInfo/X86/dbg-empty-metadata-lowering.ll
@@ -2,6 +2,9 @@
 ; RUN: | FileCheck %s --implicit-check-not=DBG --check-prefixes=AT-DISABLED,BOTH
 ; RUN: llc %s -stop-after=finalize-isel -o - --try-experimental-debuginfo-iterators \
 ; RUN: | FileCheck %s --implicit-check-not=DBG --check-prefixes=AT-DISABLED,BOTH
+; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - \
+; RUN: | FileCheck %s --implicit-check-not=DBG --check-prefixes=AT-DISABLED,BOTH
+
 ;; Check that dbg.values with empty metadata are treated as kills (i.e. become
 ;; DBG_VALUE $noreg, ...). dbg.declares with empty metadata location operands
 ;; should be ignored.
@@ -9,6 +12,9 @@
 ; RUN: sed 's/;Uncomment-with-sed//g' < %s \
 ; RUN: | llc -stop-after=finalize-isel -o - \
 ; RUN: | FileCheck %s --implicit-check-not=DBG --check-prefixes=AT-ENABLED,BOTH
+; RUN: sed 's/;Uncomment-with-sed//g' < %s \
+; RUN: | llc --try-experimental-debuginfo-iterators -stop-after=finalize-isel -o - \
+; RUN: | FileCheck %s --implicit-check-not=DBG --check-prefixes=AT-ENABLED,BOTH
 ;; Check the same behaviour occurs with assignment tracking enabled.
 
 ;; First ensure assignment tracking is truly unset/set.
diff --git a/llvm/test/DebugInfo/X86/debug-info-block-captured-self.ll b/llvm/test/DebugInfo/X86/debug-info-block-captured-self.ll
index d96ea5190b864bf..c70b51f7f8d10cd 100644
--- a/llvm/test/DebugInfo/X86/debug-info-block-captured-self.ll
+++ b/llvm/test/DebugInfo/X86/debug-info-block-captured-self.ll
@@ -1,6 +1,9 @@
 ; RUN: llc -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s
 ; RUN: llvm-dwarfdump %t.o | FileCheck %s
 ;
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s
+; RUN: llvm-dwarfdump %t.o | FileCheck %s
+;
 ; Test that DW_AT_location is generated for a captured "self" inside a
 ; block.
 ;
diff --git a/llvm/test/DebugInfo/X86/debug-info-blocks.ll b/llvm/test/DebugInfo/X86/debug-info-blocks.ll
index 0914fa68620c98f..5dacd711ad60497 100644
--- a/llvm/test/DebugInfo/X86/debug-info-blocks.ll
+++ b/llvm/test/DebugInfo/X86/debug-info-blocks.ll
@@ -1,6 +1,9 @@
 ; RUN: llc -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s
 ; RUN: llvm-dwarfdump -v -debug-info %t.o | FileCheck %s
 
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple x86_64-apple-darwin -filetype=obj -o %t.o < %s
+; RUN: llvm-dwarfdump -v -debug-info %t.o | FileCheck %s
+
 ; Generated from llvm/tools/clang/test/CodeGenObjC/debug-info-blocks.m
 ; rdar://problem/9279956
 ; test that the DW_AT_location of self is at ( fbreg +{{[0-9]+}}, deref, +{{[0-9]+}} )
diff --git a/llvm/test/DebugInfo/X86/empty-metadata-dbg-declare.ll b/llvm/test/DebugInfo/X86/empty-metadata-dbg-declare.ll
index 8ae4e7b183e9a0c..241a39f3d899a95 100644
--- a/llvm/test/DebugInfo/X86/empty-metadata-dbg-declare.ll
+++ b/llvm/test/DebugInfo/X86/empty-metadata-dbg-declare.ll
@@ -1,4 +1,5 @@
 ; RUN: llc %s -stop-after=finalize-isel -o - | FileCheck %s --implicit-check-not=DBG
+; RUN: llc --try-experimental-debuginfo-iterators %s -stop-after=finalize-isel -o - | FileCheck %s --implicit-check-not=DBG
 
 ;; Check that a single "empty metadata" dbg.declare doesn't accidentally cause
 ;; other dbg.declares in the function to go missing.
diff --git a/llvm/test/DebugInfo/X86/pieces-3.ll b/llvm/test/DebugInfo/X86/pieces-3.ll
index dfd7b3c48ef93b0..60bf758b4985650 100644
--- a/llvm/test/DebugInfo/X86/pieces-3.ll
+++ b/llvm/test/DebugInfo/X86/pieces-3.ll
@@ -1,4 +1,5 @@
 ; RUN: llc %s -filetype=obj -o - -experimental-debug-variable-locations=true | llvm-dwarfdump -v - | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators %s -filetype=obj -o - -experimental-debug-variable-locations=true | llvm-dwarfdump -v - | FileCheck %s
 ;
 ;    // Compile with -O1
 ;    typedef struct {
diff --git a/llvm/test/DebugInfo/X86/pieces-4.ll b/llvm/test/DebugInfo/X86/pieces-4.ll
index adc93fc93a2cd5a..aa93bd6a7f5f069 100644
--- a/llvm/test/DebugInfo/X86/pieces-4.ll
+++ b/llvm/test/DebugInfo/X86/pieces-4.ll
@@ -1,5 +1,7 @@
 ; RUN: llc < %s -experimental-debug-variable-locations=true | FileCheck %s
 ; RUN: llc -filetype=obj < %s -experimental-debug-variable-locations=true | llvm-dwarfdump -debug-loc - | FileCheck %s --check-prefix=DWARF
+; RUN: llc --try-experimental-debuginfo-iterators < %s -experimental-debug-variable-locations=true | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators -filetype=obj < %s -experimental-debug-variable-locations=true | llvm-dwarfdump -debug-loc - | FileCheck %s --check-prefix=DWARF
 
 ; Compile the following with -O1:
 
diff --git a/llvm/test/DebugInfo/X86/safestack-byval.ll b/llvm/test/DebugInfo/X86/safestack-byval.ll
index acaa8031537cabf..168cddd80633d98 100644
--- a/llvm/test/DebugInfo/X86/safestack-byval.ll
+++ b/llvm/test/DebugInfo/X86/safestack-byval.ll
@@ -3,6 +3,8 @@
 ; SafeStack for unsafe byval arguments.
 ; RUN: llc -mtriple=x86_64-unknown-unknown --experimental-debug-variable-locations=false -stop-after finalize-isel %s -o - | FileCheck %s --check-prefixes=CHECK,NORMAL
 ; RUN: llc -mtriple=x86_64-unknown-unknown --experimental-debug-variable-locations -stop-after finalize-isel %s -o - | FileCheck %s --check-prefixes=CHECK,INSTRREF
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple=x86_64-unknown-unknown --experimental-debug-variable-locations=false -stop-after finalize-isel %s -o - | FileCheck %s --check-prefixes=CHECK,NORMAL
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple=x86_64-unknown-unknown --experimental-debug-variable-locations -stop-after finalize-isel %s -o - | FileCheck %s --check-prefixes=CHECK,INSTRREF
 
 ; This was built by compiling the following source with SafeStack and
 ; simplifying the result a little.
diff --git a/llvm/test/DebugInfo/X86/salvage-add-node-indirect.ll b/llvm/test/DebugInfo/X86/salvage-add-node-indirect.ll
index cae8a479a5ad9da..967721bde8a34ca 100644
--- a/llvm/test/DebugInfo/X86/salvage-add-node-indirect.ll
+++ b/llvm/test/DebugInfo/X86/salvage-add-node-indirect.ll
@@ -1,5 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 3
 ; RUN: llc -mtriple=x86_64 %s -start-before=x86-isel -o - -stop-after=x86-isel | FileCheck %s
+; RUN: llc --try-experimental-debuginfo-iterators -mtriple=x86_64 %s -start-before=x86-isel -o - -stop-after=x86-isel | FileCheck %s
 
 ; Verify that we don't crash due to attempting to turn the indirect debug value
 ; in @test_non_constant variadic when salvaging the ADD node with non-constant
diff --git a/llvm/test/DebugInfo/X86/spill-indirect-nrvo.ll b/llvm/test/DebugInfo/X...
[truncated]

Copy link

github-actions bot commented Nov 27, 2023

:white_check_mark: With the latest revision this PR passed the C/C++ code formatter.

N = UnusedArgNodeMap[Address];
SDDbgValue *SDV;
if (N.getNode()) {
if (const BitCastInst *BCI = dyn_cast<BitCastInst>(Address))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need this with opaque pointers? stripPointerCasts?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just moved this blob of existing code from SelectionDAGBuilder::visitIntrinsicCall into its own function.

I could change this in a separate patch?

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; Matt raises a good point about the bitcast, but as this is just a refactor + adding two new calls to handle dbg.declares stored in DPValues, I think it's best treated elsewhere. We've already got some tickets hanging around about how the handling of debug-info for arguments in SelectionDAG is a bit of a hack.

llvm/include/llvm/CodeGen/FunctionLoweringInfo.h Outdated Show resolved Hide resolved
@OCHyams OCHyams merged commit 5ee0881 into llvm:main Dec 12, 2023
3 of 4 checks passed
OCHyams added a commit that referenced this pull request Jan 2, 2024
The disabled line should be checking FastISel but was incorrectly checking
SelectionDAG due to a copy-paste error in #73496.
@OCHyams OCHyams deleted the ddd/isel branch January 5, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants