llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
29.12k stars 12.01k forks source link

LLVM drops line number information for variables that have debug information attached to PHI nodes #10279

Open llvmbot opened 13 years ago

llvmbot commented 13 years ago
Bugzilla Link 9907
Version trunk
OS Windows NT
Attachments optimized bitcode that loosed debug information
Reporter LLVM Bugzilla Contributor
CC @asl,@jryans

Extended Description

This bug requires the patch from bug9879 to be applied to see the variables exist in the debug_info section.

This is what is produce with llc --march=x86 : _OpenCL_nbt01_kernel: Lfunc_begin0: .loc 1 2 0 pushl %ebx Ltmp0: pushl %edi Ltmp1: pushl %esi Ltmp2: Ltmp3: calll ___amdil_get_local_idint movd %xmm0, %esi movl 16(%esp), %edi calll amdil_get_global_id_int movd %xmm0, %ebx calll ___amdil_get_local_size_int movd %xmm0, %eax Ltmp4: .loc 1 9 26 addl %ebx, %esi Ltmp5: addl %eax, %esi movl %esi, (%edi) Ltmp6: .loc 1 10 1 popl %esi popl %edi Ltmp7: popl %ebx Ltmp8: ret Ltmp9: Lfunc_end0:

This is what is expected: _OpenCL_nbt01_kernel: Lfunc_begin0: .loc 1 2 0 pushl %ebx Ltmp0: pushl %edi Ltmp1: pushl %esi Ltmp2: Ltmp3: calll ___amdil_get_local_idint movd %xmm0, %esi Ltmp4: .loc 1 5 26 movl 16(%esp), %edi calll amdil_get_global_id_int movd %xmm0, %ebx Ltmp5: .loc 1 6 27 calll ___amdil_get_local_size_int movd %xmm0, %eax Ltmp6: .loc 1 7 28 Ltmp7: .loc 1 9 26 addl %ebx, %esi Ltmp8: addl %eax, %esi movl %esi, (%edi) Ltmp9: .loc 1 10 1 popl %esi popl %edi Ltmp10: popl %ebx Ltmp11: ret Ltmp12: Lfunc_end0:

llvmbot commented 13 years ago

patch that fixes the issue UnreachableBlockElim The problem is in the function MachineRegisterInfo::replaceRegWith which is called from UnreachableBlockElim. This function/pass does not propagate the dbg_value that was attached to the phi-node and does not guarantee that the new instruction has the correct debug_loc.

I've attached a patch that is my solution to the issue, but other solutions might be better.

On the x86, this produces the following code: _OpenCL_nbt01_kernel: Lfunc_begin0: .loc 1 2 0 pushl %ebx Ltmp0: pushl %edi Ltmp1: pushl %esi Ltmp2: Ltmp3: movl 16(%esp), %esi calll ___amdil_get_local_idint movd %xmm0, %edi calll amdil_get_global_id_int movd %xmm0, %ebx calll ___amdil_get_local_size_int .loc 1 7 28 Ltmp4: movd %xmm0, %eax Ltmp5: .loc 1 9 26 addl %ebx, %edi addl %eax, %edi movl %edi, (%esi) Ltmp6: .loc 1 10 1 popl %esi popl %edi popl %ebx ret Ltmp7: Lfunc_end0:

I'm not sure why the line 5 and line 6 debug information values are deleted yet. With our custom backend, this patch alone is enough to have them show up, but the x86 backend is deleting them before UnreachableBlockElim is executed.

llvmbot commented 13 years ago

Ahh, sorry about that, forgot to update that field.

llvmbot commented 13 years ago

This is with LLVM 2.9 release.

asl commented 13 years ago

Micah, are you sure the problem still exists in 2.9/ToT ?