matt-kempster/m2c

Sometimes missing args in function calls with more than 4 parameters

zbanks opened this issue · 0 comments

There's a small bug with subroutine_args in translate_node_body. This array keeps track of the arguments after the 4th for the next function call. However, it is only local to the single node.

If there is a branch while the asm is setting up for a function call with many arguments, then the subroutine_args from before the branch are dropped. This seems to happen mostly from float/int conversions.

I put together a hack to keep this array across node boundaries -- but this has a few problems:

  • The expressions in the array should probably be turned into phi expressions. (Maybe it would then be more elegant to shove these into the register dict?)
  • Maybe a better "fix" would be to add an asm pattern for the float/int conversions, to sidestep the issue?
    • Maybe add a warning for gaps in the subroutine_args array, or for unused args?

I ran the hack branch against MM & PM as a resource for decompers -- but in many cases the changes aren't correct.