This is an archive of the discontinued LLVM Phabricator instance.

Obtain the debug location for rematerialized instructions from the rematerialization point.
ClosedPublic

Authored by wolfgangp on Aug 15 2016, 6:25 PM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

wolfgangp updated this revision to Diff 68122.Aug 15 2016, 6:25 PM
wolfgangp retitled this revision from to Obtain the debug location for rematerialized instructions from the rematerialization point..
wolfgangp updated this object.
wolfgangp added reviewers: dblaikie, echristo, aprantl.
wolfgangp added subscribers: llvm-commits, andreadb.
aprantl accepted this revision.Aug 16 2016, 8:59 AM
aprantl edited edge metadata.

This looks reasonable to me. Thanks!

lib/CodeGen/InlineSpiller.cpp
556 ↗(On Diff #68122)

Typo in context :-)

This revision is now accepted and ready to land.Aug 16 2016, 8:59 AM

This looks reasonable to me. Thanks!

Thanks for the quick turnaround!

This revision was automatically updated to reflect the committed changes.