[flang-commits] [flang] [flang][debug] Add accurate line number information to module. (PR #214011)
Tarun Prabhu via flang-commits
flang-commits at lists.llvm.org
Wed Aug 5 07:18:52 PDT 2026
================
@@ -0,0 +1,36 @@
+! The location of fir.module_debug_imports is what tells AddDebugInfo the line
+! of the MODULE statement, so the operation is emitted for every module, even
+! one with no USE statement, and only when full debug info is requested.
+
+! RUN: %flang_fc1 -emit-hlfir -debug-info-kind=standalone %s -o - \
+! RUN: -mmlir -mlir-print-debuginfo -mmlir -mlir-print-local-scope \
+! RUN: | FileCheck %s --check-prefix=WITH_DEBUG
+! RUN: %flang_fc1 -emit-hlfir %s -o - | FileCheck %s --check-prefix=NO_DEBUG
+! RUN: %flang_fc1 -emit-hlfir -debug-info-kind=line-tables-only %s -o - \
+! RUN: | FileCheck %s --check-prefix=NO_DEBUG
+
+! NO_DEBUG-NOT: fir.module_debug_imports
+
+module no_use_mod
+ integer :: mod_var
+contains
+ subroutine test_sub()
+ mod_var = 100
+ end subroutine test_sub
+end module no_use_mod
+! WITH_DEBUG: fir.module_debug_imports "no_use_mod" {
+! WITH_DEBUG-NEXT: } loc("{{.*}}":[[@LINE-8]]:{{[0-9]+}})
----------------
tarunprabhu wrote:
Might it be "safer" to move this above the module and use `[[@LINE+1]]` instead of `[[@LINE-8]]`? Just a thought.
https://github.com/llvm/llvm-project/pull/214011
More information about the flang-commits
mailing list