If a function's return type gets changed, but there are still BB's left to be inserted, CurFunction will not point to the modified function.
This commit fixes this by always querying for the current function.
The added test case compiles to the following:
assert_func: # @assert_func
push rax
cmp dword ptr [rdi], 0
je .LBB0_1
cmp qword ptr [rdi + 8], 0
je .LBB0_4
pop rax
ret
.LBB0_1:
mov edi, offset .Lstr
jmp .LBB0_2
.LBB0_4:
mov edi, offset .Lstr.4
.LBB0_2:
call puts@PLT
mov edi, 1
call exit
Initially, llvm-mctoll assumes that this is a function returning i64, as rax is defined before the ret instruction. However, when raising the function, mctoll adjusts the return type to void, triggering incorrect behavior, as LBB0_1 and onwards still need to be raised.
If a function's return type gets changed, but there are still BB's left to be inserted, CurFunction will not point to the modified function. This commit fixes this by always querying for the current function.
The added test case compiles to the following:
Initially, llvm-mctoll assumes that this is a function returning
i64
, asrax
is defined before theret
instruction. However, when raising the function, mctoll adjusts the return type tovoid
, triggering incorrect behavior, asLBB0_1
and onwards still need to be raised.