llvm-project/flang/test/Transforms/debug-dwarf-version.fir
Abid Qadeer 453e4102bd
[flang] Lowering support for -gdwarf-N flag. (#159137)
This PR builds on the https://github.com/llvm/llvm-project/pull/158314
and adds the lowering support for `-gdwarf-N` flag. The changes to pass
the information to `AddDebugInfo` pass are mostly mechanical. The
`AddDebugInfo` pass adds `ModuleFlagsOp` in the module which gets
translated to correct llvm metadata during mlir->llvmir translation.

There is minor correction where the version is set to 0 in case no
-debug-version flag is provided. Previously it was set to 2 in this case
due to misreading of clang code.
2025-09-17 18:16:36 +01:00

22 lines
1.1 KiB
Plaintext

// RUN: fir-opt --add-debug-info="dwarf-version=5" --mlir-print-debuginfo %s \
// RUN: | FileCheck --check-prefix=CHECK-DWARF5 %s
// RUN: fir-opt --add-debug-info="dwarf-version=4" --mlir-print-debuginfo %s \
// RUN: | FileCheck --check-prefix=CHECK-DWARF4 %s
// RUN: fir-opt --add-debug-info="dwarf-version=3" --mlir-print-debuginfo %s \
// RUN: | FileCheck --check-prefix=CHECK-DWARF3 %s
// RUN: fir-opt --add-debug-info="dwarf-version=2" --mlir-print-debuginfo %s \
// RUN: | FileCheck --check-prefix=CHECK-DWARF2 %s
// RUN: fir-opt --add-debug-info= --mlir-print-debuginfo %s \
// RUN: | FileCheck --check-prefix=CHECK-WITHOUT-VERSION %s
// REQUIRES: system-linux
module {
} loc(#loc)
#loc = loc("simple.f90":0:0)
// CHECK-DWARF5: llvm.module_flags [#llvm.mlir.module_flag<max, "Dwarf Version", 5 : i32>]
// CHECK-DWARF4: llvm.module_flags [#llvm.mlir.module_flag<max, "Dwarf Version", 4 : i32>]
// CHECK-DWARF3: llvm.module_flags [#llvm.mlir.module_flag<max, "Dwarf Version", 3 : i32>]
// CHECK-DWARF2: llvm.module_flags [#llvm.mlir.module_flag<max, "Dwarf Version", 2 : i32>]
// CHECK-WITHOUT-VERSION-NOT: llvm.module_flags