[PATCH] D122584: [DebugInfo] Use DW_ATE_signed encoding when creating a Fortran array index type.
Chih-Ping Chen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 1 10:55:25 PDT 2022
cchen15 added a comment.
For my experiment, I use the two files in the attachment: test-c.cpp is the main program. It calls the Fortran function DegCtoF in test.f90.
I follow the test strategy in test/DebugInfo/Generic/cross-cu-inlining.ll, and compile the program files this way:
$ clang++ -g -c -emit-llvm test-c.cpp
$ fortran-comp -g -c -emit-llvm test.f90
Since in test.bc the Fortran subroutine has the attribute noinline and optnone, I manually modify the .bc to replace noinline with alwaysinline and remove optnone. Then
$ llvm-link test-c.bc test.bc -o com.bc
$ opt -inline com.bc -o com-opt.bc
$ llc --filetype=obj com-opt.bc
$ clang++ -g -o com-opt.exe com-opt.o
I verify with gdb that the Fortran function is inlined and debugging works as expected.
gdb) b 23
warning: Could not recognize version of Intel Compiler in: "Intel(R) Fortran 22.0-1478"
Breakpoint 1 at 0x401179: file test-c.cpp, line 23.
(gdb) r
Starting program: /localdisk2/cchen15/examples/tests/signed-encoding/lto/new/com-opt.exe
C/C++ and Fortran together!
Breakpoint 1, main (argc=1, argv=0x7fffffff8c28) at test-c.cpp:23
23 DegCtoF(DegreesC, DegreesF, &N);
(gdb) x/20i $pc
=> 0x401179 <main(int, char**)+73>: lea -0x30(%rbp),%rax
0x40117d <main(int, char**)+77>: lea -0x60(%rbp),%rcx
0x401181 <main(int, char**)+81>: mov %rax,-0x48(%rbp)
0x401185 <main(int, char**)+85>: mov -0x48(%rbp),%rax
0x401189 <main(int, char**)+89>: mov %rcx,-0x40(%rbp)
0x40118d <main(int, char**)+93>: mov -0x40(%rbp),%rcx
0x401191 <main(int, char**)+97>: lea -0x14(%rbp),%rdx
0x401195 <main(int, char**)+101>: mov %rdx,-0x38(%rbp)
0x401199 <main(int, char**)+105>: mov -0x38(%rbp),%rdx
0x40119d <main(int, char**)+109>: mov (%rdx),%esi
0x40119f <main(int, char**)+111>: mov %esi,-0x10(%rbp)
0x4011a2 <main(int, char**)+114>: movslq -0x10(%rbp),%rsi
0x4011a6 <main(int, char**)+118>: mov %rsi,-0x78(%rbp)
0x4011aa <main(int, char**)+122>: movslq -0x10(%rbp),%rsi
0x4011ae <main(int, char**)+126>: mov %rsi,-0x70(%rbp)
0x4011b2 <main(int, char**)+130>: mov (%rdx),%edx
0x4011b4 <main(int, char**)+132>: mov %edx,-0xc(%rbp)
0x4011b7 <main(int, char**)+135>: movl $0x1,-0x8(%rbp)
0x4011be <main(int, char**)+142>: cmpl $0x1,-0xc(%rbp)
0x4011c2 <main(int, char**)+146>:
jl 0x401207 <main(int, char**)+215>
(gdb) s
DegCtoF (degc=..., degf=..., n=2) at test.f90:14
14 subroutine DegCtoF(degC, degF, n)&
(gdb) n
24 do i = 1, n
(gdb) p/x $pc
$1 = 0x4011b2
Last but not least, I do a dwarfdump on com-opt.exe and the signed encoding for the Fortran array index type is preserved:
0x00000166: DW_TAG_formal_parameter
DW_AT_name ("degc")
DW_AT_decl_file ("/iusers/cchen15/examples/tests/signed-encoding/lto/new/test.f90")
DW_AT_decl_line (14)
DW_AT_type (0x000001ac "REAL*8[]")
...
0x000001ac: DW_TAG_array_type
DW_AT_type (0x000001b7 "REAL*8")
0x000001b1: DW_TAG_subrange_type
DW_AT_type (0x000001be "__ARRAY_SIZE_TYPE__")
0x000001b6: NULL
0x000001b7: DW_TAG_base_type
DW_AT_name ("REAL*8")
DW_AT_encoding (DW_ATE_float)
DW_AT_byte_size (0x08)
0x000001be: DW_TAG_base_type
DW_AT_name ("__ARRAY_SIZE_TYPE__")
DW_AT_byte_size (0x08)
DW_AT_encoding (DW_ATE_signed)
The complete dwarfdump is in com-opt.exe.ddump.F22621459: test-c.cpp <https://reviews.llvm.org/F22621459>
F22621458: com-opt.exe.ddump <https://reviews.llvm.org/F22621458>
F22621457: test.f90 <https://reviews.llvm.org/F22621457>
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D122584/new/
https://reviews.llvm.org/D122584
More information about the llvm-commits
mailing list