matsc-at-sics-se / unison

Unison's source code
http://unison-code.github.io/
Other
5 stars 0 forks source link

Remat/remat not working, cases crash #16

Closed matsc-at-sics-se closed 6 years ago

matsc-at-sics-se commented 6 years ago

Reproducer: incore_insert_large_visitor.out.json.txt incore_insert_large_visitor.alt.uni.txt

uni export incore_insert_large_visitor.alt.uni --solfile=incore_insert_large_visitor.out.json --target=X86 -d

[...]

Output from unbundleSingletons:

// @lint: --nocostoverflow=false
function: incore_insert_large_visitor
b0 (entry, exit, return, freq: 1):
    o4: [rdx] <- MOV64rm [rsi,1,_,0,_] (reads: [control])
    o10: [rdi] <- ADD64ri8 [rdi,16] (reads: [control], writes: [eflags])
    {o7: [esi] <- MOV32rm [rsi,1,_,16,_] (reads: [control]); o12: [] <- ADJCALLSTACKDOWN64 [0,0] (reads: [control,rsp], writes: [rsp,eflags])}
    o13: [ecx] <- MOV32r0 [] (reads: [control], writes: [eflags])
    {o14: [rm0-3] <- MOV32r0_demat [ecx] (reads: [control], remat-origin: o13); o19: [] <- CALL64pcrel32 [@incore_insert_large] (reads: [control,rsp])}
    o18: [eax] <- MOV32r0_remat [rm0-3] (reads: [control], writes: [eflags], remat-origin: o13)
    {o22: [] <- ADJCALLSTACKUP64 [0,0] (reads: [control,rsp], writes: [rsp,eflags]); o28: [] <- RETQ [42] (writes: [control,pc])}
[...]

Output from simplifyFallthroughs:

toMachineOperand Register not targetreg
uni: src/Unison/Util.hs:(1355,1)-(1370,32): Non-exhaustive patterns in function toMachineOperand

In o18, the operand rm0-3, an infinite register, apparently gets passed to toMachineOperand, which can't handle it.

My take: MOV32r0_demat should have disappeared, and MOV32_remat should have been converted to MOV32r0, but they did not. When and where is that supposed to happen?

matsc-at-sics-se commented 6 years ago

Fixed by imitating the ARM version of fromCopy. Closing issue for now.