[flang-commits] [flang] [llvm] [DebugInfo] Soft-disable the production of debug intrinsics (PR #133933)

Jeremy Morse via flang-commits flang-commits at lists.llvm.org
Wed Apr 9 12:58:54 PDT 2025


https://github.com/jmorse updated https://github.com/llvm/llvm-project/pull/133933

>From 707b6f75aac9c783e40d0583a14da7f67176f507 Mon Sep 17 00:00:00 2001
From: Jeremy Morse <jeremy.morse at sony.com>
Date: Tue, 1 Apr 2025 15:52:28 +0100
Subject: [PATCH 1/2] [DebugInfo] Soft-disable the production of debug
 intrinsics

This patch switches the --experimental-debuginfo-iterators flag to be
stored to an otherwise unused cl-opt. This is a deliberate attempt to break
downstream tests that are relying on the use of debug intrinsics, because
they're imminently going away! If this commit breaks your tests, please
just revert the commit upstream, and then make contact with us here:

https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578

So that we can work out whether there's any further transition work needed
to support the move away from using debug intrinsics.
---
 llvm/lib/IR/BasicBlock.cpp | 25 +++++++++++++++++++++----
 1 file changed, 21 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index aa3c2cfa056fe..a6d16b157c0ad 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -30,11 +30,28 @@ using namespace llvm;
 #define DEBUG_TYPE "ir"
 STATISTIC(NumInstrRenumberings, "Number of renumberings across all blocks");
 
+// This cl-opt exists to control whether variable-location information is
+// produced using intrinsics, or whether DbgRecords are produced. However,
+// it's imminently being phased out, so give it a flag-name that is very
+// unlikely to be used anywhere.
+//
+// If you find yourself needing to use this flag for any period longer than
+// five minutes, please revert the patch making this change, and make contact
+// in this discourse post, where we can discuss any further transition work
+// that might be needed to remove debug intrinsics.
+//
+// https://discourse.llvm.org/t/psa-ir-output-changing-from-debug-intrinsics-to-debug-records/79578
 cl::opt<bool> UseNewDbgInfoFormat(
-    "experimental-debuginfo-iterators",
-    cl::desc("Enable communicating debuginfo positions through iterators, "
-             "eliminating intrinsics. Has no effect if "
-             "--preserve-input-debuginfo-format=true."),
+    "dont-pass-this-flag-please-experimental-debuginfo", cl::Hidden,
+    cl::init(true));
+
+// This cl-opt collects the --experimental-debuginfo-iterators flag and then
+// does nothing with it (because the it gets stored into an otherwise unused
+// cl-opt), so that we can disable debug-intrinsic production without
+// immediately modifying lots of tests. If your tests break because of this
+// change, please see the next comment up.
+static cl::opt<bool> DeliberatelyUnseenDbgInfoFlag(
+    "experimental-debuginfo-iterators", cl::Hidden,
     cl::init(true));
 
 DbgMarker *BasicBlock::createMarker(Instruction *I) {

>From b2c03c58cfc2f329326ab83d88b2261661f727d1 Mon Sep 17 00:00:00 2001
From: Jeremy Morse <jeremy.morse at sony.com>
Date: Wed, 9 Apr 2025 20:57:52 +0100
Subject: [PATCH 2/2] Remove intrinsic-testing in a flang test

Intrinsics are about to go away, so this is now needless coverage.
---
 flang/test/Integration/debug-local-var-2.f90 | 15 ---------------
 1 file changed, 15 deletions(-)

diff --git a/flang/test/Integration/debug-local-var-2.f90 b/flang/test/Integration/debug-local-var-2.f90
index 7e6398f284ba0..08aeb0999b01b 100644
--- a/flang/test/Integration/debug-local-var-2.f90
+++ b/flang/test/Integration/debug-local-var-2.f90
@@ -1,4 +1,3 @@
-! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --experimental-debuginfo-iterators=false -o - | FileCheck %s --check-prefixes=BOTH,INTRINSICS
 ! RUN: %flang_fc1 -emit-llvm -debug-info-kind=standalone %s -mllvm --experimental-debuginfo-iterators=true -o - | FileCheck %s --check-prefixes=BOTH,RECORDS
 ! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --experimental-debuginfo-iterators=false -o - | FileCheck --check-prefix=LINEONLY %s
 ! RUN: %flang_fc1 -emit-llvm -debug-info-kind=line-tables-only %s -mllvm --experimental-debuginfo-iterators=true -o - | FileCheck --check-prefix=LINEONLY %s
@@ -12,12 +11,6 @@
 ! BOTH-DAG: %[[AL13:.*]] = alloca i8
 ! BOTH-DAG: %[[AL12:.*]] = alloca i64
 ! BOTH-DAG: %[[AL11:.*]] = alloca i32
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL11]], metadata ![[I4:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL12]], metadata ![[I8:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL13]], metadata ![[L1:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL14]], metadata ![[L4:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL15]], metadata ![[R4:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL16]], metadata ![[R8:.*]], metadata !DIExpression())
 ! RECORDS-DAG: #dbg_declare(ptr %[[AL11]], ![[I4:.*]], !DIExpression(), !{{.*}})
 ! RECORDS-DAG: #dbg_declare(ptr %[[AL12]], ![[I8:.*]], !DIExpression(), !{{.*}})
 ! RECORDS-DAG: #dbg_declare(ptr %[[AL13]], ![[L1:.*]], !DIExpression(), !{{.*}})
@@ -28,27 +21,19 @@
 
 ! BOTH-LABEL: define {{.*}}i64 @_QFPfn1
 ! BOTH-SAME: (ptr captures(none) %[[ARG1:.*]], ptr captures(none) %[[ARG2:.*]], ptr captures(none) %[[ARG3:.*]])
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG1]], metadata ![[A1:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG2]], metadata ![[B1:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[ARG3]], metadata ![[C1:.*]], metadata !DIExpression())
 ! RECORDS-DAG: #dbg_declare(ptr %[[ARG1]], ![[A1:.*]], !DIExpression(), !{{.*}})
 ! RECORDS-DAG: #dbg_declare(ptr %[[ARG2]], ![[B1:.*]], !DIExpression(), !{{.*}})
 ! RECORDS-DAG: #dbg_declare(ptr %[[ARG3]], ![[C1:.*]], !DIExpression(), !{{.*}})
 ! BOTH-DAG: %[[AL2:.*]] = alloca i64
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL2]], metadata ![[RES1:.*]], metadata !DIExpression())
 ! RECORDS-DAG: #dbg_declare(ptr %[[AL2]], ![[RES1:.*]], !DIExpression(), !{{.*}})
 ! BOTH-LABEL: }
 
 ! BOTH-LABEL: define {{.*}}i32 @_QFPfn2
 ! BOTH-SAME: (ptr captures(none) %[[FN2ARG1:.*]], ptr captures(none) %[[FN2ARG2:.*]], ptr captures(none) %[[FN2ARG3:.*]])
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG1]], metadata ![[A2:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG2]], metadata ![[B2:.*]], metadata !DIExpression())
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[FN2ARG3]], metadata ![[C2:.*]], metadata !DIExpression())
 ! RECORDS-DAG: #dbg_declare(ptr %[[FN2ARG1]], ![[A2:.*]], !DIExpression(), !{{.*}})
 ! RECORDS-DAG: #dbg_declare(ptr %[[FN2ARG2]], ![[B2:.*]], !DIExpression(), !{{.*}})
 ! RECORDS-DAG: #dbg_declare(ptr %[[FN2ARG3]], ![[C2:.*]], !DIExpression(), !{{.*}})
 ! BOTH-DAG: %[[AL3:.*]] = alloca i32
-! INTRINSICS-DAG: call void @llvm.dbg.declare(metadata ptr %[[AL3]], metadata ![[RES2:.*]], metadata !DIExpression())
 ! RECORDS-DAG: #dbg_declare(ptr %[[AL3]], ![[RES2:.*]], !DIExpression(), !{{.*}})
 ! BOTH-LABEL: }
 



More information about the flang-commits mailing list