[flang-commits] [flang] [flang][debug] Handle USE statements inside modules (PR #186184)

Abid Qadeer via flang-commits flang-commits at lists.llvm.org
Mon Mar 30 08:53:03 PDT 2026


abidh wrote:

 
> I think we should place this info on the side, that is we should create some module level operation for Fortran module that can point to the other module being used.
> 
> These could be generated when debug info is requested, and debug info could directly use them to generate the debug info for modules.
> 
> This will avoid duplicating the the fir.use_stmt in each small functions that is importing a top level module. As I understand, this would also allow generating smaller dwarf by leaving the debugger building the access hierarchy itself instead of flattening all the uses at the function level (not sure about that point).

Thanks @jeanPerier for your comment and suggestion. I agree that this is better approach and the debug info will reflect source code better. The `gfortran` uses this approach while `classic flang` does the flattening.

I have almost implemented the suggested approach and have already merged the mlir part of the change in [this](https://github.com/llvm/llvm-project/pull/188576) PR. But I just noticed that `GDB` does not handle this case when a module imports other. So even if we implement the suggested approach, it will not change the user experience. The bug will stay.

So we have the following options:

1. Do nothing at the moment and leave the bug as it.
2. Merge this flattening approach. It should fix the reported problem. But may increase debug info size.
3. Implement the new approach. It will add complexity in the code (as we will have to add recursive-ness in the `DICompileUnitAttr`) without changing user experience at the moment. We can open GDB issue and but It will be some time before the version with the fix become widely available (even if this get fixed promptly).


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


More information about the flang-commits mailing list