[llvm] Dummy pass (PR #165533)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 29 02:44:57 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-debuginfo

Author: None (anamaoh)

<details>
<summary>Changes</summary>



---

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


15 Files Affected:

- (modified) .gitignore (+1-1) 
- (added) foo_00.ll (+81) 
- (added) llvm/include/llvm/Transforms/Utils/DebugRecordCounter.h (+15) 
- (added) llvm/include/llvm/Transforms/Utils/DebugRecordDeleter.h (+15) 
- (modified) llvm/lib/CMakeLists.txt (+1-1) 
- (modified) llvm/lib/Passes/PassBuilder.cpp (+2) 
- (modified) llvm/lib/Passes/PassBuilderPipelines.cpp (+8-1) 
- (modified) llvm/lib/Passes/PassRegistry.def (+2) 
- (modified) llvm/lib/Transforms/Utils/CMakeLists.txt (+2) 
- (added) llvm/lib/Transforms/Utils/DebugRecordCounter.cpp (+31) 
- (added) llvm/lib/Transforms/Utils/DebugRecordDeleter.cpp (+20) 
- (added) llvm/test/Transforms/Util/dbgi-counter-1.ll (+91) 
- (added) llvm/test/Transforms/Util/dbgi-counter-2.ll (+183) 
- (added) llvm/test/Transforms/Util/dbgi-deleter-1.ll (+109) 
- (added) llvm/test/Transforms/Util/dbgi-deleter-2.ll (+206) 


``````````diff
diff --git a/.gitignore b/.gitignore
index 860b8ea12abd4..2fe0cdf332236 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,7 +27,7 @@
 /*/CMakeUserPresets.json
 
 # Nested build directory
-/build*
+/build*  
 
 #==============================================================================#
 # Explicit files to ignore (only matches one).
diff --git a/foo_00.ll b/foo_00.ll
new file mode 100644
index 0000000000000..6a9cff3891632
--- /dev/null
+++ b/foo_00.ll
@@ -0,0 +1,81 @@
+; ModuleID = '/home/ana-marija/Documents/foo.c'
+source_filename = "/home/ana-marija/Documents/foo.c"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @foo() #0 !dbg !10 {
+  %1 = alloca i32, align 4
+  %2 = alloca i32, align 4
+  %3 = alloca i32, align 4
+    #dbg_declare(ptr %1, !16, !DIExpression(), !17)
+  store i32 21, ptr %1, align 4, !dbg !17
+    #dbg_declare(ptr %2, !18, !DIExpression(), !19)
+  store i32 22, ptr %2, align 4, !dbg !19
+    #dbg_declare(ptr %3, !20, !DIExpression(), !22)
+  store i32 23, ptr %3, align 4, !dbg !22
+  %4 = load i32, ptr %1, align 4, !dbg !23
+  store i32 %4, ptr %3, align 4, !dbg !24
+  %5 = load i32, ptr %2, align 4, !dbg !25
+  store i32 %5, ptr %1, align 4, !dbg !26
+  %6 = load i32, ptr %1, align 4, !dbg !27
+  %7 = load i32, ptr %2, align 4, !dbg !28
+  %8 = add nsw i32 %6, %7, !dbg !29
+  ret i32 %8, !dbg !30
+}
+
+; Function Attrs: noinline nounwind optnone uwtable
+define dso_local i32 @main() #0 !dbg !31 {
+  %1 = alloca i32, align 4
+  %2 = alloca i32, align 4
+  store i32 0, ptr %1, align 4
+    #dbg_declare(ptr %2, !32, !DIExpression(), !33)
+  %3 = call i32 @foo(), !dbg !34
+  store i32 %3, ptr %2, align 4, !dbg !33
+  %4 = load i32, ptr %2, align 4, !dbg !35
+  ret i32 %4, !dbg !36
+}
+
+attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 22.0.0git (https://github.com/anamaoh/llvm-project.git 782a91e1fc94d9c82495f60afc5ed5edd72de776)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/home/ana-marija/Documents/foo.c", directory: "/home/ana-marija/Desktop/LLVM/llvm-project", checksumkind: CSK_MD5, checksum: "22bc4641d6e8e63df371a758d86cafff")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}
+!7 = !{i32 7, !"uwtable", i32 2}
+!8 = !{i32 7, !"frame-pointer", i32 2}
+!9 = !{!"clang version 22.0.0git (https://github.com/anamaoh/llvm-project.git 782a91e1fc94d9c82495f60afc5ed5edd72de776)"}
+!10 = distinct !DISubprogram(name: "foo", scope: !11, file: !11, line: 1, type: !12, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
+!11 = !DIFile(filename: "Documents/foo.c", directory: "/home/ana-marija", checksumkind: CSK_MD5, checksum: "22bc4641d6e8e63df371a758d86cafff")
+!12 = !DISubroutineType(types: !13)
+!13 = !{!14}
+!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!15 = !{}
+!16 = !DILocalVariable(name: "X", scope: !10, file: !11, line: 2, type: !14)
+!17 = !DILocation(line: 2, column: 6, scope: !10)
+!18 = !DILocalVariable(name: "Y", scope: !10, file: !11, line: 3, type: !14)
+!19 = !DILocation(line: 3, column: 6, scope: !10)
+!20 = !DILocalVariable(name: "Z", scope: !21, file: !11, line: 5, type: !14)
+!21 = distinct !DILexicalBlock(scope: !10, file: !11, line: 4, column: 2)
+!22 = !DILocation(line: 5, column: 8, scope: !21)
+!23 = !DILocation(line: 6, column: 8, scope: !21)
+!24 = !DILocation(line: 6, column: 6, scope: !21)
+!25 = !DILocation(line: 8, column: 6, scope: !10)
+!26 = !DILocation(line: 8, column: 4, scope: !10)
+!27 = !DILocation(line: 9, column: 9, scope: !10)
+!28 = !DILocation(line: 9, column: 13, scope: !10)
+!29 = !DILocation(line: 9, column: 11, scope: !10)
+!30 = !DILocation(line: 9, column: 2, scope: !10)
+!31 = distinct !DISubprogram(name: "main", scope: !11, file: !11, line: 12, type: !12, scopeLine: 12, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
+!32 = !DILocalVariable(name: "A", scope: !31, file: !11, line: 13, type: !14)
+!33 = !DILocation(line: 13, column: 6, scope: !31)
+!34 = !DILocation(line: 13, column: 10, scope: !31)
+!35 = !DILocation(line: 14, column: 9, scope: !31)
+!36 = !DILocation(line: 14, column: 2, scope: !31)
diff --git a/llvm/include/llvm/Transforms/Utils/DebugRecordCounter.h b/llvm/include/llvm/Transforms/Utils/DebugRecordCounter.h
new file mode 100644
index 0000000000000..f8a4e5bd671e7
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Utils/DebugRecordCounter.h
@@ -0,0 +1,15 @@
+#ifndef LLVM_TRANSFORMS_UTILS_DEBUG_RECORD_COUNTER_H
+#define LLVM_TRANSFORMS_UTILS_DEBUG_RECORD_COUNTER_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+    class DebugRecordCounterPass : public PassInfoMixin<DebugRecordCounterPass> {
+    public:
+        PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+    };
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_DEBUG_RECORD_COUNTER_H
diff --git a/llvm/include/llvm/Transforms/Utils/DebugRecordDeleter.h b/llvm/include/llvm/Transforms/Utils/DebugRecordDeleter.h
new file mode 100644
index 0000000000000..e40ed00b8095e
--- /dev/null
+++ b/llvm/include/llvm/Transforms/Utils/DebugRecordDeleter.h
@@ -0,0 +1,15 @@
+#ifndef LLVM_TRANSFORMS_UTILS_DEBUG_RECORD_DELETER_H
+#define LLVM_TRANSFORMS_UTILS_DEBUG_RECORD_DELETER_H
+
+#include "llvm/IR/PassManager.h"
+
+namespace llvm {
+
+    class DebugRecordDeleterPass : public PassInfoMixin<DebugRecordDeleterPass> {
+    public:
+        PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
+    };
+
+} // namespace llvm
+
+#endif // LLVM_TRANSFORMS_UTILS_DEBUG_RECORD_DELETER_H
diff --git a/llvm/lib/CMakeLists.txt b/llvm/lib/CMakeLists.txt
index a9432977718c6..7667a279bf504 100644
--- a/llvm/lib/CMakeLists.txt
+++ b/llvm/lib/CMakeLists.txt
@@ -68,6 +68,6 @@ else()
   add_llvm_component_group(NativeCodeGen)
 endif()
 
-# Component post-processing
+# Component post-processing  
 LLVMBuildResolveComponentsLink()
 LLVMBuildGenerateCFragment(OUTPUT ${LLVMCONFIGLIBRARYDEPENDENCIESINC})
diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp
index 53cf0046bd858..0723a6b8b92e0 100644
--- a/llvm/lib/Passes/PassBuilder.cpp
+++ b/llvm/lib/Passes/PassBuilder.cpp
@@ -350,6 +350,8 @@
 #include "llvm/Transforms/Utils/CountVisits.h"
 #include "llvm/Transforms/Utils/DXILUpgrade.h"
 #include "llvm/Transforms/Utils/Debugify.h"
+#include "llvm/Transforms/Utils/DebugRecordCounter.h"
+#include "llvm/Transforms/Utils/DebugRecordDeleter.h"
 #include "llvm/Transforms/Utils/DeclareRuntimeLibcalls.h"
 #include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
 #include "llvm/Transforms/Utils/FixIrreducible.h"
diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp
index fea0d255cc91a..912baacb64053 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -148,6 +148,8 @@
 #include "llvm/Transforms/Vectorize/SLPVectorizer.h"
 #include "llvm/Transforms/Vectorize/VectorCombine.h"
 
+#include "llvm/Transforms/Utils/DebugRecordDeleter.h"
+
 using namespace llvm;
 
 namespace llvm {
@@ -1676,6 +1678,11 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
   // Now add the optimization pipeline.
   MPM.addPass(buildModuleOptimizationPipeline(Level, Phase));
 
+  // Include the DebugRecordDeleter passinto the -O2 pipeline.
+  if(Level == OptimizationLevel::O2) {
+    MPM.addPass(DebugRecordDeleterPass());
+  }
+
   if (PGOOpt && PGOOpt->PseudoProbeForProfiling &&
       PGOOpt->Action == PGOOptions::SampleUse)
     MPM.addPass(PseudoProbeUpdatePass());
@@ -1684,7 +1691,7 @@ PassBuilder::buildPerModuleDefaultPipeline(OptimizationLevel Level,
   addAnnotationRemarksPass(MPM);
 
   if (isLTOPreLink(Phase))
-    addRequiredLTOPreLinkPasses(MPM);
+    addRequiredLTOPreLinkPasses(MPM); 
   return MPM;
 }
 
diff --git a/llvm/lib/Passes/PassRegistry.def b/llvm/lib/Passes/PassRegistry.def
index 1b1652555cd28..e34866485fba3 100644
--- a/llvm/lib/Passes/PassRegistry.def
+++ b/llvm/lib/Passes/PassRegistry.def
@@ -49,6 +49,8 @@ MODULE_ALIAS_ANALYSIS("globals-aa", GlobalsAA())
 #ifndef MODULE_PASS
 #define MODULE_PASS(NAME, CREATE_PASS)
 #endif
+MODULE_PASS("dbg-counter", DebugRecordCounterPass())
+MODULE_PASS("dbg-deleter", DebugRecordDeleterPass())
 MODULE_PASS("always-inline", AlwaysInlinerPass())
 MODULE_PASS("annotation2metadata", Annotation2MetadataPass())
 MODULE_PASS("assign-guid", AssignGUIDPass())
diff --git a/llvm/lib/Transforms/Utils/CMakeLists.txt b/llvm/lib/Transforms/Utils/CMakeLists.txt
index f367ca2fdf56b..d6bc72055a5ef 100644
--- a/llvm/lib/Transforms/Utils/CMakeLists.txt
+++ b/llvm/lib/Transforms/Utils/CMakeLists.txt
@@ -20,6 +20,8 @@ add_llvm_component_library(LLVMTransformUtils
   CtorUtils.cpp
   CountVisits.cpp
   Debugify.cpp
+  DebugRecordCounter.cpp
+  DebugRecordDeleter.cpp
   DebugSSAUpdater.cpp
   DeclareRuntimeLibcalls.cpp
   DemoteRegToStack.cpp
diff --git a/llvm/lib/Transforms/Utils/DebugRecordCounter.cpp b/llvm/lib/Transforms/Utils/DebugRecordCounter.cpp
new file mode 100644
index 0000000000000..2aa9fc2e044fe
--- /dev/null
+++ b/llvm/lib/Transforms/Utils/DebugRecordCounter.cpp
@@ -0,0 +1,31 @@
+#include "llvm/Transforms/Utils/DebugRecordCounter.h"
+#include "llvm/IR/Function.h" 
+#include "llvm/IR/Module.h" 
+
+using namespace llvm;
+
+// build/bin/opt -disable-output /home/ana-marija/Documents/foo_00.ll -passes=dbg-counter
+PreservedAnalyses DebugRecordCounterPass::run(Module &M, ModuleAnalysisManager &AM) {
+    
+    int dbg_values, dbg_declares, dbg_assigns;
+
+    for (Function &F : M) { 
+        errs() << "Function: " << F.getName() << "\n"; 
+
+        dbg_assigns = dbg_declares = dbg_values = 0;
+
+        for(BasicBlock &BB : F) {
+            for(Instruction &I : BB) {
+                for(DbgVariableRecord &DVR : filterDbgVars(I.getDbgRecordRange())) {
+                    if(DVR.isDbgDeclare()) dbg_declares++;
+                    if(DVR.isDbgValue())   dbg_values++;
+                    if(DVR.isDbgAssign())  dbg_assigns++;
+                }
+            }
+        }
+        errs() << "\t#dbg_value:   " << dbg_values   << "\n";  
+        errs() << "\t#dbg_declare: " << dbg_declares << "\n";  
+        errs() << "\t#dbg_assign:  " << dbg_assigns  << "\n"; 
+    }
+    return PreservedAnalyses::all(); 
+}
diff --git a/llvm/lib/Transforms/Utils/DebugRecordDeleter.cpp b/llvm/lib/Transforms/Utils/DebugRecordDeleter.cpp
new file mode 100644
index 0000000000000..9ac6a43a7a202
--- /dev/null
+++ b/llvm/lib/Transforms/Utils/DebugRecordDeleter.cpp
@@ -0,0 +1,20 @@
+#include "llvm/Transforms/Utils/DebugRecordDeleter.h"
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h" 
+#include "llvm/IR/DebugInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+
+#include "llvm/Passes/PassBuilder.h"
+#include "llvm/Passes/PassPlugin.h" 
+#include "llvm/Passes/OptimizationLevel.h" 
+
+using namespace llvm;
+
+// build/bin/opt -S /home/ana-marija/Documents/foo_00.ll -passes=dbg-deleter
+PreservedAnalyses DebugRecordDeleterPass::run(Module &M, ModuleAnalysisManager &AM) {
+    
+    bool modified = StripDebugInfo(M); 
+
+    return PreservedAnalyses::all();
+         
+}
\ No newline at end of file
diff --git a/llvm/test/Transforms/Util/dbgi-counter-1.ll b/llvm/test/Transforms/Util/dbgi-counter-1.ll
new file mode 100644
index 0000000000000..000436ff88623
--- /dev/null
+++ b/llvm/test/Transforms/Util/dbgi-counter-1.ll
@@ -0,0 +1,91 @@
+; RUN: opt -S -passes=dbg-counter < %s 2>&1 | FileCheck %s  
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: Function: foo
+; CHECK-NEXT: #dbg_value: 0
+; CHECK-NEXT: #dbg_declare: 3
+; CHECK-NEXT: #dbg_assign: 0
+
+define dso_local i32 @foo() #0 !dbg !10 {
+  %1 = alloca i32, align 4
+  %2 = alloca i32, align 4
+  %3 = alloca i32, align 4
+    #dbg_declare(ptr %1, !16, !DIExpression(), !17)
+  store i32 21, ptr %1, align 4, !dbg !17
+    #dbg_declare(ptr %2, !18, !DIExpression(), !19)
+  store i32 22, ptr %2, align 4, !dbg !19
+    #dbg_declare(ptr %3, !20, !DIExpression(), !22)
+  store i32 23, ptr %3, align 4, !dbg !22
+  %4 = load i32, ptr %1, align 4, !dbg !23
+  store i32 %4, ptr %3, align 4, !dbg !24
+  %5 = load i32, ptr %2, align 4, !dbg !25
+  store i32 %5, ptr %1, align 4, !dbg !26
+  %6 = load i32, ptr %1, align 4, !dbg !27
+  %7 = load i32, ptr %2, align 4, !dbg !28
+  %8 = add nsw i32 %6, %7, !dbg !29
+  ret i32 %8, !dbg !30
+}
+
+; Function Attrs: noinline nounwind optnone uwtable
+
+; CHECK: Function: main
+; CHECK-NEXT: #dbg_value: 0
+; CHECK-NEXT: #dbg_declare: 1
+; CHECK-NEXT: #dbg_assign: 0
+
+define dso_local i32 @main() #0 !dbg !31 {
+  %1 = alloca i32, align 4
+  %2 = alloca i32, align 4
+  store i32 0, ptr %1, align 4
+    #dbg_declare(ptr %2, !32, !DIExpression(), !33)
+  %3 = call i32 @foo(), !dbg !34
+  store i32 %3, ptr %2, align 4, !dbg !33
+  %4 = load i32, ptr %2, align 4, !dbg !35
+  ret i32 %4, !dbg !36
+}
+
+attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
+!llvm.ident = !{!9}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 22.0.0git (https://github.com/anamaoh/llvm-project.git 782a91e1fc94d9c82495f60afc5ed5edd72de776)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "/home/ana-marija/Documents/foo.c", directory: "/home/ana-marija/Desktop/LLVM/llvm-project", checksumkind: CSK_MD5, checksum: "22bc4641d6e8e63df371a758d86cafff")
+!2 = !{i32 7, !"Dwarf Version", i32 5}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 8, !"PIC Level", i32 2}
+!6 = !{i32 7, !"PIE Level", i32 2}
+!7 = !{i32 7, !"uwtable", i32 2}
+!8 = !{i32 7, !"frame-pointer", i32 2}
+!9 = !{!"clang version 22.0.0git (https://github.com/anamaoh/llvm-project.git 782a91e1fc94d9c82495f60afc5ed5edd72de776)"}
+!10 = distinct !DISubprogram(name: "foo", scope: !11, file: !11, line: 1, type: !12, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
+!11 = !DIFile(filename: "Documents/foo.c", directory: "/home/ana-marija", checksumkind: CSK_MD5, checksum: "22bc4641d6e8e63df371a758d86cafff")
+!12 = !DISubroutineType(types: !13)
+!13 = !{!14}
+!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!15 = !{}
+!16 = !DILocalVariable(name: "X", scope: !10, file: !11, line: 2, type: !14)
+!17 = !DILocation(line: 2, column: 6, scope: !10)
+!18 = !DILocalVariable(name: "Y", scope: !10, file: !11, line: 3, type: !14)
+!19 = !DILocation(line: 3, column: 6, scope: !10)
+!20 = !DILocalVariable(name: "Z", scope: !21, file: !11, line: 5, type: !14)
+!21 = distinct !DILexicalBlock(scope: !10, file: !11, line: 4, column: 2)
+!22 = !DILocation(line: 5, column: 8, scope: !21)
+!23 = !DILocation(line: 6, column: 8, scope: !21)
+!24 = !DILocation(line: 6, column: 6, scope: !21)
+!25 = !DILocation(line: 8, column: 6, scope: !10)
+!26 = !DILocation(line: 8, column: 4, scope: !10)
+!27 = !DILocation(line: 9, column: 9, scope: !10)
+!28 = !DILocation(line: 9, column: 13, scope: !10)
+!29 = !DILocation(line: 9, column: 11, scope: !10)
+!30 = !DILocation(line: 9, column: 2, scope: !10)
+!31 = distinct !DISubprogram(name: "main", scope: !11, file: !11, line: 12, type: !12, scopeLine: 12, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
+!32 = !DILocalVariable(name: "A", scope: !31, file: !11, line: 13, type: !14)
+!33 = !DILocation(line: 13, column: 6, scope: !31)
+!34 = !DILocation(line: 13, column: 10, scope: !31)
+!35 = !DILocation(line: 14, column: 9, scope: !31)
+!36 = !DILocation(line: 14, column: 2, scope: !31)
\ No newline at end of file
diff --git a/llvm/test/Transforms/Util/dbgi-counter-2.ll b/llvm/test/Transforms/Util/dbgi-counter-2.ll
new file mode 100644
index 0000000000000..69756bcf80b08
--- /dev/null
+++ b/llvm/test/Transforms/Util/dbgi-counter-2.ll
@@ -0,0 +1,183 @@
+; RUN: opt -S -passes=dbg-counter < %s 2>&1 | FileCheck %s  
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK: Function: main
+; CHECK-NEXT: #dbg_value: 30
+; CHECK-NEXT: #dbg_declare: 0
+; CHECK-NEXT: #dbg_assign: 0
+
+%struct.student = type { [50 x i8], i32, float }
+
+ at s = dso_local local_unnamed_addr global [10 x %struct.student] zeroinitializer, align 16, !dbg !0
+
+define dso_local noundef i32 @main() local_unnamed_addr #0 !dbg !28 {
+    #dbg_value(i32 2, !32, !DIExpression(), !43)
+    #dbg_value(i32 3, !33, !DIExpression(), !43)
+    #dbg_value(i32 4, !34, !DIExpression(), !43)
+    #dbg_value(ptr poison, !35, !DIExpression(), !43)
+    #dbg_value(ptr poison, !37, !DIExpression(), !43)
+    #dbg_value(ptr poison, !38, !DIExpression(), !43)
+    #dbg_value(i32 5, !34, !DIExpression(), !43)
+    #dbg_value(i32 0, !39, !DIExpression(), !44)
+    #dbg_value(i64 0, !39, !DIExpression(), !44)
+  store i32 6, ptr getelementptr inbounds nuw (i8, ptr @s, i64 52), align 4, !dbg !45, !tbaa !48
+    #dbg_value(i64 1, !39, !DIExpression(), !44)
+  store i32 7, ptr getelementptr inbounds nuw (i8, ptr @s, i64 112), align 16, !dbg !54, !tbaa !48
+    #dbg_value(i64 2, !39, !DIExpression(), !44)
+  store i32 8, ptr getelementptr inbounds nuw (i8, ptr @s, i64 172), align 4, !dbg !55, !tbaa !48
+    #dbg_value(i64 3, !39, !DIExpression(), !44)
+  store i32 9, ptr getelementptr inbounds nuw (i8, ptr @s, i64 232), align 8, !dbg !56, !tbaa !48
+    #dbg_value(i64 4, !39, !DIExpression(), !44)
+  store i32 10, ptr getelementptr inbounds nuw (i8, ptr @s, i64 292), align 4, !dbg !57, !tbaa !48
+    #dbg_value(i64 5, !39, !DIExpression(), !44)
+  store i32 11, ptr getelementptr inbounds nuw (i8, ptr @s, i64 352), align 16, !dbg !58, !tbaa !48
+    #dbg_value(i64 6, !39, !DIExpression(), !44)
+  store i32 12, ptr getelementptr inbounds nuw (i8, ptr @s, i64 412), align 4, !dbg !59, !tbaa !48
+    #dbg_value(i64 7, !39, !DIExpression(), !44)
+  store i32 13, ptr getelementptr inbounds nuw (i8, ptr @s, i64 472), align 8, !dbg !60, !tbaa !48
+    #dbg_value(i64 8, !39, !DIExpression(), !44)
+  store i32 14, ptr getelementptr inbounds nuw (i8, ptr @s, i64 532), align 4, !dbg !61, !tbaa !48
+    #dbg_value(i64 9, !39, !DIExpression(), !44)
+  store i32 15, ptr getelementptr inbounds nuw (i8, ptr @s, i64 592), align 16, !dbg !62, !tbaa !48
+    #dbg_value(i64 10, !39, !DIExpression(), !44)
+    #dbg_value(i64 0, !41, !DIExpression(), !63)
+  %1 = load float, ptr getelementptr inbounds nuw (i8, ptr @s, i64 56), align 8, !dbg !64, !tbaa !67
+  %2 = fadd float %1, 1.000000e+00, !dbg !68
+  store float %2, ptr getelementptr inbounds nuw (i8, ptr @s, i64 56), align 8, !dbg !69, !tbaa !67
+    #dbg_value(i64 1, !41, !DIExpression(), !63)
+  %3 = load float, ptr getelementptr inbounds nuw (i8, ptr @s, i64 116), align 4, !dbg !64, !tbaa !67
+  %4 = fadd float %3, 1.000000e+00, !dbg !70
+  store float %4, ptr getelementptr inbounds nuw (i8, ptr @s, i64 116), align 4, !dbg !71, !tbaa !67
+    #dbg_value(i64 2, !41, !DIExpression(), !63)
+  %5 = load float, ptr getelementptr inbounds nuw (i8, ptr @s, i64 176), align 16, !dbg !64, !tbaa !67
+  %6 = fadd float %5, 1.000000e+00, !dbg !72
+  store float %6, ptr getelementptr inbounds nuw (i8, ptr @s, i64 176), align 16, !dbg !73, !tbaa !67
+    #dbg_value(i64 3, !41, !DIExpressi...
[truncated]

``````````

</details>


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


More information about the llvm-commits mailing list