Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPC: support closure cfunctions (aborts during codegen) #32154

Closed
vchuravy opened this issue May 27, 2019 · 3 comments
Closed

PPC: support closure cfunctions (aborts during codegen) #32154

vchuravy opened this issue May 27, 2019 · 3 comments
Labels
system:powerpc PowerPC upstream The issue is with an upstream dependency, e.g. LLVM

Comments

@vchuravy
Copy link
Member

vchuravy commented May 27, 2019

From worker 46: running testset ccall...

      From worker 46:
      From worker 46:   signal (6): Aborted
      From worker 46:   in expression starting at /autofs/nccsopen-svm1_home/vchuravy/julia/test/ccall.jl:837
      From worker 46:   gsignal at /lib64/libc.so.6 (unknown line)
      From worker 46:   abort at /lib64/libc.so.6 (unknown line)
      From worker 46:   unknown function (ip: 0x7fff843a83d7)
      From worker 46:   jl_get_cfunction_trampoline at /autofs/nccsopen-svm1_home/vchuravy/julia/src/runtime_ccall.cpp:322
      From worker 46:   Allocations: 11091552 (Pool: 11089407; Big: 2145); GC: 26

Upstream:

@vchuravy vchuravy added the system:powerpc PowerPC label May 27, 2019
@maleadt maleadt changed the title [PPC] abort during init_trampoline PPC: support closure cfunctions (aborts during codegen) Jan 14, 2020
@vchuravy vchuravy added the upstream The issue is with an upstream dependency, e.g. LLVM label Mar 19, 2020
@vchuravy
Copy link
Member Author

Turns out the abort is not due to lack of support in LLVM, but part of the implementation of __init_trampoline

#27174 (comment)

@vchuravy
Copy link
Member Author

So in r4 we are passing 48 which stems from https://github.com/llvm/llvm-project/blob/ffc3e800c65ee58166255ff897f8b7e6d850ddda/llvm/lib/Target/PowerPC/PPCISelLowering.cpp#L3485

0000000000008658 <__trampoline_setup>:
    8658:       03 00 4c 3c     addis   r2,r12,3
    865c:       a8 f6 42 38     addi    r2,r2,-2392
    8660:       fd ff e2 3c     addis   r7,r2,-3
    8664:       30 09 e7 38     addi    r7,r7,2352
    8668:       20 00 00 39     li      r8,32
    866c:       00 20 88 7c     cmpw    cr1,r8,r4
    8670:       fe e8 84 54     rlwinm  r4,r4,29,3,31
    8674:       f8 ff 23 39     addi    r9,r3,-8
    8678:       a6 03 89 7c     mtctr   r4
    867c:       38 00 84 41     blt     cr1,86b4 <__trampoline_setup+0x5c>
    8680:       09 00 47 e9     ldu     r10,8(r7)
    8684:       09 00 49 f9     stdu    r10,8(r9)
    8688:       f8 ff 00 42     bdnz    8680 <__trampoline_setup+0x28>
    868c:       10 00 a3 f8     std     r5,16(r3)
    8690:       18 00 c3 f8     std     r6,24(r3)
    8694:       a6 03 89 7c     mtctr   r4
    8698:       ac 1f 00 7c     icbi    0,r3
    869c:       ac 18 00 7c     dcbf    0,r3
    86a0:       08 00 63 38     addi    r3,r3,8
    86a4:       f4 ff 00 42     bdnz    8698 <__trampoline_setup+0x40>
    86a8:       ac 04 00 7c     hwsync
    86ac:       2c 01 00 4c     isync
    86b0:       20 00 80 4e     blr
    86b4:       bd a9 ff 4b     bl      3070 <00000017.plt_call.abort@@GLIBC_2.17>

I am slightly confused since

li      r8,32
cmpw cr1,r8,r4
blt     cr1,86b4 <__trampoline_setup+0x5c>

Means branch to <__trampoline_setup+0x5c> if r8 is less then r4. With r4=48 and r8=32 that is true, therefore we jump to abort.

I took https://github.com/gcc-mirror/gcc/blob/02551aa99960ff6b0d9a44d234b8f6c9b230788c/libgcc/config/rs6000/tramp.S#L159
to mean that we check whether the provided trampoline buffer is big enough, for that the check would be the wrong way around.

@vchuravy
Copy link
Member Author

This is fixed on recent glibc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
system:powerpc PowerPC upstream The issue is with an upstream dependency, e.g. LLVM
Projects
None yet
Development

No branches or pull requests

1 participant