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

IR program failed to compile with "-O0" "-S" options #33

Closed
stkeke opened this issue May 17, 2023 · 1 comment
Closed

IR program failed to compile with "-O0" "-S" options #33

stkeke opened this issue May 17, 2023 · 1 comment

Comments

@stkeke
Copy link
Contributor

stkeke commented May 17, 2023

tony@Win11Z790I:~/ir/tests/debug$ cat ./dce_001.ir
{
        uintptr_t c_1 = 0;
        bool c_2 = 0;
        bool c_3 = 1;
        int32_t c_4 = 10;
        int32_t c_5 = 2;
        int32_t c_6 = 1;
        int32_t c_7 = 0;
        l_1 = START(l_14);
        int32_t d_2 = PARAM(l_1, "x", 0);
        l_3 = END(l_1);
        l_4 = LOOP_BEGIN(l_3, l_12);
        int32_t d_5 = PHI(l_4, c_7, d_7);
        int32_t d_6 = ADD(d_2, c_6);
        int32_t d_7 = ADD(d_6, d_5);
        int32_t d_8 = MUL(d_7, c_5);
        int32_t xxx = DIV(d_8, c_4);
        bool d_9 = LT(d_7, c_4);
        l_10 = IF(l_4, d_9);
        l_11 = IF_TRUE(l_10);
        l_12 = LOOP_END(l_11);
        l_13 = IF_FALSE(l_10);
        l_14 = RETURN(l_13, d_8);
}

# failed with -O0 option
tony@Win11Z790I:~/ir/tests/debug$ ~/ir/ir -O0 ./dce_001.ir -S
ir: ./ir_x86.dasc:3173: ir_emit_mul_div_mod: Assertion `def_reg != -1' failed.
Aborted

# succeeded with -O2 option
tony@Win11Z790I:~/ir/tests/debug$ ~/ir/ir -O2 ./dce_001.ir -S
test:
        leal 1(%rdi), %eax
        xorl %ecx, %ecx
.L1:
        addl %eax, %ecx
        cmpl $0xa, %ecx
        jl .L1
        leal (%rcx, %rcx), %eax
        retq
@dstogov
Copy link
Owner

dstogov commented May 17, 2023

I suppose, something is wrong (may be recently broken) in -O0 register allocator.
I'm going to completely rewrite it, but this is not a top priority task.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants