[flang-commits] [flang] [flang][debug] Add accurate line number information to module. (PR #214011)
Abid Qadeer via flang-commits
flang-commits at lists.llvm.org
Thu Aug 6 04:58:19 PDT 2026
================
@@ -0,0 +1,44 @@
+// RUN: fir-opt --add-debug-info --mlir-print-debuginfo %s | FileCheck %s
+
+// The line of a DIModuleAttr comes from the location of the module's
+// `fir.module_debug_imports`, which is that of the MODULE statement. Without
+// one, it falls back to a guess based on the first member of the module.
+
+module {
+ // A module whose MODULE statement is on line 4, well before its first
+ // member on line 20. The region is empty because the module has no USE.
+ fir.module_debug_imports "no_use" {
+ } loc(#loc_no_use)
+ fir.global @_QMno_useEx : i32 {
+ %0 = fir.zero_bits i32
+ fir.has_value %0 : i32
+ } loc(#loc_x)
+
+ // Same, but with a USE statement in the region.
+ fir.module_debug_imports "with_use" {
+ fir.use_stmt "no_use"
----------------
abidh wrote:
That indeed looks confusing. I have fixed it now by introducing `other_mod` here.
https://github.com/llvm/llvm-project/pull/214011
More information about the flang-commits
mailing list