Skip to content

bugc: a moved inlined invoke loses its call site's code range #390

Open

Description

@gnidan

When common subexpression elimination drops the first instruction of an inlined body, #384 moves its invoke onto the next instruction, but the call site's code range that inlining gathered onto that first instruction goes with the CSE merge onto the earlier, equal instruction instead. The entry of the inlined code (its JUMPDEST) then has only the callee body's source range, so the caller's locals are out of scope there and are not listed at all.

At -O 2:

name MovedInvoke;
define {
  struct P { a: uint64; b: uint32; };
  function f() -> uint256 { return (msg.sender as uint256) % 7; };
}
storage { [0] r: uint256; [1] ps: mapping<address, P>; }
create {}
code {
  let p: P = ps[msg.sender];
  p.a = p.a + 5;
  let h = f();
  p.b = p.b + 1;
  ps[msg.sender] = p;
  r = h;
}

The JUMP into f's code lists p and h. The JUMPDEST after it lists neither, and the op carrying invoke f has no code range for the call f().

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions