[PATCH] D25611: When moving a zext near to its associated load, do not retain the origial debug location.

Dehao Chen via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 14 08:29:36 PDT 2016


danielcdh added a comment.

The change in CGP LGTM, but as I am not debug info maintainer, I'll let someone else to sign off the patch.

But to fix the debug info problem in the given test case, it's better to fix it the place closest to the problem, which is ISel. (I do not mean that the CGP fix in this patch is wrong, it's worth fixing too)

In the generated assembly, we did not see the zext instruction, there is only one movl instruction.

Looking at the Isel, the following IR:

  %0 = load i32, i32* %ptr, align 4, !dbg !7
  %conv = zext i32 %0 to i64, !dbg !8

are translated to:

  %vreg5<def> = MOV32rm %vreg2, 1, %noreg, 0, %noreg; mem:LD4[%ptr] GR32:%vreg5 GR64:%vreg2 dbg:test.c:6:14
  %vreg0<def> = SUBREG_TO_REG 0, %vreg5<kill>, 4; GR64:%vreg0 GR32:%vreg5 dbg:test.c:6:14

Both MOV32rm and SUBREG_TO_REG are attributed to !dbg !8, while MOV32rm should be attributed to !dbg !7 instead. In this way we will not see line 6 attributed to the movl instruction.


https://reviews.llvm.org/D25611





More information about the llvm-commits mailing list