[llvm-bugs] [Bug 28111] New: RuntimeDyldCOFFI386 ignores relocation addend

via llvm-bugs llvm-bugs at lists.llvm.org
Mon Jun 13 09:48:09 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=28111

            Bug ID: 28111
           Summary: RuntimeDyldCOFFI386 ignores relocation addend
           Product: new-bugs
           Version: trunk
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: normal
          Priority: P
         Component: new bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: jon at kingstar.demon.co.uk
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

Created attachment 16533
  --> https://llvm.org/bugs/attachment.cgi?id=16533&action=edit
Illustrative patch

This stops mesa llvmpipe on Cygwin x86 from working usefully, but probably
affects many uses of MCJIT on x86/Windows.

For example, mesa's lp_test_arit test fails in sgn.v2.  Examining the JIT-ed
code before an after relocations
are applied shows the problem.

> # gdb ./lp_test_arit
> [...]
> (gdb) b test_unary
> Breakpoint 1 at 0x401577: file ../../../../../src/gallium/drivers/llvmpipe/lp_test_arit.c, line 402.
> (gdb) ignore 1 7
> Will ignore next 7 crossings of breakpoint 1.
> (gdb) r
> [...]
> (gdb) b llvm::RuntimeDyldCOFFI386::resolveRelocation
> Breakpoint 2 at 0x6b756290: file /usr/src/debug/llvm-3.7.1-1.1/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFI386.h, line 126.
> (gdb) c
> [...]
> (gdb) up 8
> #8  0x00401670 in test_unary (verbose=0, fp=0x0, test=0x45b3a0 <unary_tests+64>, length=2) at ../../../../../src/gallium/drivers/llvmpipe/lp_test_arit.c:426
> (gdb) x/33i test_func_jit
>    0x7ffa0000:  push   %ebp
>    0x7ffa0001:  mov    %esp,%ebp
>    0x7ffa0003:  and    $0xfffffff8,%esp
>    0x7ffa0006:  sub    $0x8,%esp
>    0x7ffa0009:  mov    0x8(%ebp),%eax
>    0x7ffa000c:  mov    0xc(%ebp),%ecx
>    0x7ffa000f:  movss  (%ecx),%xmm0
>    0x7ffa0013:  movss  0x4(%ecx),%xmm1
>    0x7ffa0018:  movss  %xmm1,0x4(%esp)
>    0x7ffa001e:  movss  %xmm0,(%esp)
>    0x7ffa0023:  insertps $0x10,%xmm1,%xmm0
>    0x7ffa0029:  pmovzxdq (%esp),%xmm1
>    0x7ffa002f:  pand   0x0,%xmm1              <== addend 0
>    0x7ffa0037:  por    0x10,%xmm1             <== addend 10
>    0x7ffa003f:  xorps  %xmm2,%xmm2
>    0x7ffa0042:  movaps %xmm0,%xmm3
>    0x7ffa0045:  cmpeqps %xmm2,%xmm3
>    0x7ffa0049:  cmpunordps %xmm2,%xmm0
>    0x7ffa004d:  orps   %xmm3,%xmm0
>    0x7ffa0050:  pmovzxdq %xmm0,%xmm0
>    0x7ffa0055:  psllq  $0x20,%xmm0
>    0x7ffa005a:  pshufd $0xf5,%xmm0,%xmm3
>    0x7ffa005f:  psrad  $0x1f,%xmm0
>    0x7ffa0064:  pblendw $0x33,%xmm3,%xmm0
>    0x7ffa006a:  pshufd $0xe8,%xmm0,%xmm0
>    0x7ffa006f:  pslld  $0x1f,%xmm0
>    0x7ffa0074:  pshufd $0xe8,%xmm1,%xmm1
>    0x7ffa0079:  blendvps %xmm0,%xmm2,%xmm1
>    0x7ffa007e:  extractps $0x1,%xmm1,0x4(%eax)
>    0x7ffa0085:  movss  %xmm1,(%eax)
>    0x7ffa0089:  mov    %ebp,%esp
>    0x7ffa008b:  pop    %ebp
>    0x7ffa008c:  ret
> (gdb) disable 2
> (gdb) b 428
> Breakpoint 3 at 0x401673: file ../../../../../src/gallium/drivers/llvmpipe/lp_test_arit.c, line 428.
> (gdb) c
> [...]
> (gdb) x/33i test_func_jit
>    0x7ffa0000:  push   %ebp
>    0x7ffa0001:  mov    %esp,%ebp
>    0x7ffa0003:  and    $0xfffffff8,%esp
>    0x7ffa0006:  sub    $0x8,%esp
>    0x7ffa0009:  mov    0x8(%ebp),%eax
>    0x7ffa000c:  mov    0xc(%ebp),%ecx
>    0x7ffa000f:  movss  (%ecx),%xmm0
>    0x7ffa0013:  movss  0x4(%ecx),%xmm1
>    0x7ffa0018:  movss  %xmm1,0x4(%esp)
>    0x7ffa001e:  movss  %xmm0,(%esp)
>    0x7ffa0023:  insertps $0x10,%xmm1,%xmm0
>    0x7ffa0029:  pmovzxdq (%esp),%xmm1
>    0x7ffa002f:  pand   0x7ff90000,%xmm1    <== addend was 0
>    0x7ffa0037:  por    0x7ff90000,%xmm1    <== addend ignored
>    0x7ffa003f:  xorps  %xmm2,%xmm2
>    0x7ffa0042:  movaps %xmm0,%xmm3
>    0x7ffa0045:  cmpeqps %xmm2,%xmm3
>    0x7ffa0049:  cmpunordps %xmm2,%xmm0
>    0x7ffa004d:  orps   %xmm3,%xmm0
>    0x7ffa0050:  pmovzxdq %xmm0,%xmm0
>    0x7ffa0055:  psllq  $0x20,%xmm0
>    0x7ffa005a:  pshufd $0xf5,%xmm0,%xmm3
>    0x7ffa005f:  psrad  $0x1f,%xmm0
>    0x7ffa0064:  pblendw $0x33,%xmm3,%xmm0
>    0x7ffa006a:  pshufd $0xe8,%xmm0,%xmm0
>    0x7ffa006f:  pslld  $0x1f,%xmm0
>    0x7ffa0074:  pshufd $0xe8,%xmm1,%xmm1
>    0x7ffa0079:  blendvps %xmm0,%xmm2,%xmm1
>    0x7ffa007e:  extractps $0x1,%xmm1,0x4(%eax)
>    0x7ffa0085:  movss  %xmm1,(%eax)
>    0x7ffa0089:  mov    %ebp,%esp
>    0x7ffa008b:  pop    %ebp
>    0x7ffa008c:  ret

Attached is an illustrative patch, based on how RuntimeDyldCOFFX86_64 handles
this.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160613/197054db/attachment.html>


More information about the llvm-bugs mailing list