[flang-commits] [flang] [flang] Remove hardcoded bits from AddDebugInfo. (PR #89231)

via flang-commits flang-commits at lists.llvm.org
Fri Apr 19 04:10:20 PDT 2024


abidh wrote:

> Thanks! My main comment is that I do not get why you need to pass the filename from the driver, it was not hardcoded since it came from the module location which is created in lowering from the source file name.

The name and path field in the DICompileUnit are used to set the `DW_AT_name` and `DW_AT-comp_dir` attribute in the `DWARF`. Here is the description of these 2 attributes from the DWARF5 standard.

```
A DW_AT_name attribute whose value is a null-terminated string containing
the full or relative path name (relative to the value of the DW_AT_comp_dir
attribute, see below) of the primary source file from which the compilation
unit was derived.

A DW_AT_comp_dir attribute whose value is a null-terminated string
containing the current working directory of the compilation command that
produced this compilation unit in whatever form makes sense for the host
system 
```

Please also see the example below. It demonstrates where the gfortran was invoked from and what we get in the `DWARF`. Passing file from driver to AddDebugInfo will allow us to generate similar `DWARF
```
/home/haqadeer/build$ gfortran ../src/test.f90
              DW_AT_name	("../src/test.f90")
              DW_AT_comp_dir	("/home/haqadeer/build")
```

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


More information about the flang-commits mailing list