jacobly0 / llvm-project

This fork of the canonical git mirror of the LLVM subversion repository adds (e)Z80 targets. Please refer to the wiki for important build instructions.
https://github.com/jacobly0/llvm-project/wiki
123 stars 15 forks source link

Compiler Crash (unable to legalize) #41

Closed mateoconlechuga closed 12 months ago

mateoconlechuga commented 1 year ago

Compiler crashes when any of O1,O2,O3,Os,Ofast is used.

main.c

extern void a(int k);
void m(void)
{
    for (int k = 0;;)
    {
        a(k++ / 3);
    }
}

error:

fatal error: error in backend: unable to legalize instruction: %26:_(s48) = G_LSHR %24:_, %27:_(s8) (in function: m)
adriweb commented 12 months ago

The nightly toolchain just wasn't pulling the "correct" compiler build (due to one of the CI thing failing (the old mac build can be fixed or removed @jacobly0 :P) I can confirm the latest compiler works fine:

    section .text,"ax",@progbits
    assume  adl = 1
    section .text,"ax",@progbits
    public  _m
_m:
    ld  hl, -3
    call    __frameset
    or  a, a
    sbc hl, hl
    push    hl
    pop de
BB0_1:
    inc de
    ld  (ix - 3), de
    ld  bc, 3
    call    __idivu
    push    hl
    call    _a
    ld  de, (ix - 3)
    pop hl
    push    de
    pop hl
    jr  BB0_1
    section .text,"ax",@progbits

    ident   "clang version 15.0.0 (https://github.com/jacobly0/llvm-project.git 87dbcb9ad4aac66fa28b578e02021919589d3e82)"
    extern  __idivu
    extern  __Unwind_SjLj_Register
    extern  __Unwind_SjLj_Unregister
    extern  __frameset
    extern  _a
mateoconlechuga commented 12 months ago

This is because the actions are broken so I was testing the wrong compiler version