vnmakarov / mir

A lightweight JIT compiler based on MIR (Medium Internal Representation) and C11 JIT compiler and interpreter based on MIR
MIT License
2.29k stars 145 forks source link

Assert failed at machinize_call #278

Closed Itay2805 closed 1 year ago

Itay2805 commented 2 years ago

I am getting a really weird assert at assert (prev_call_insn != NULL) (mir-gen-x86_64.c:232). I am generating mir automatically:

The generated code: https://pastebin.com/RPvNBXcy The generated code right before the assert: https://pastebin.com/Gr0BbLu5

Now I assume it is searching for the previous instruction given that prev_call_insn comes from DLIST_PREV (MIR_insn_t, call_insn) but that makes little sense, since a simple test like

test: module
p_getchar: proto
import getchar
main: func 
    call p_getchar, getchar
    ret
endfunc
endmodule

works just fine... so I can't really fine a way to explain my error...

if you need anything else from the generated code just ask...

Itay2805 commented 2 years ago

trying to debug a little myself I see that for whatever reason after the build_func_cfg it doesn't put a label on the first block, which is a bit strange since from my testing when it doesn't fail it does have a label in there