[PATCH] D23539: Obtain the debug location for rematerialized instructions from the rematerialization point.

Wolfgang Pieb via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 15 18:25:28 PDT 2016


wolfgangp created this revision.
wolfgangp added reviewers: dblaikie, echristo, aprantl.
wolfgangp added subscribers: llvm-commits, andreadb.
Herald added subscribers: mehdi_amini, qcolombet.

When the inline spiller rematerializes an instruction (e.g. a load from a constant pool), it should take the debug location from the instruction that immediately follows the rematerialization point.
Currently the original line number's instruction is used, which may not be the right one. Consider:

```
typedef float __m128 __attribute__((__vector_size__(16)));
extern __m128 doSomething(__m128, __m128);

__m128 foo(__m128 X) {     // line 6
  const __m128 V = {0.5f, 0.5f, 0.5f, 0.5f};  // line 7
  __m128 Sub = X - V;  // line 8
  __m128 Add = X + V;  // line 9

  __m128 Result = doSomething(Add, Sub);  // line 11

  return V - Result;  // line 13
}
```
generates:

    pushq    %rbp
    movq    %rsp, %rbp

    .loc    1 8 0 prologue_end      # test.cpp:8:0
    vmovaps    .LCPI0_0(%rip), %xmm2   # xmm2 =
[5.000000e-01,5.000000e-01,5.000000e-01,5.000000e-01]
    vsubps    %xmm0, %xmm2, %xmm1

    .loc    1 9 0                   # test.cpp:9:0
    vaddps    %xmm2, %xmm0, %xmm0
    .loc    1 11 0 discriminator 1  # test.cpp:11:0
    callq    _Z11doSomethingDv4_fS_

    .loc    1 8 0                   # test.cpp:8:0            <==== back to line 8 from line 11.
    vmovaps    .LCPI0_0(%rip), %xmm1   # xmm1 =
[5.000000e-01,5.000000e-01,5.000000e-01,5.000000e-01]
    .loc    1 13 0                  # test.cpp:13:0
    vsubps    %xmm0, %xmm1, %xmm0
    popq    %rbp
    retq



https://reviews.llvm.org/D23539

Files:
  lib/CodeGen/InlineSpiller.cpp
  test/DebugInfo/X86/rematerialize.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23539.68122.patch
Type: text/x-patch
Size: 5556 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160816/73e633d4/attachment.bin>


More information about the llvm-commits mailing list