This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix fixEndsAtEndOfFunction for delegate
ClosedPublic

Authored by aheejin on Apr 22 2021, 2:15 AM.

Details

Summary

Background:
CFGStackify's fixEndsAtEndOfFunction fixes block/loop/try's return
type when the end of function is unreachable and the function return
type is not void. So if a function returns i32 and block-end wraps the
whole function, i.e., the block's end is the last instruction of the
function, the block's return type should be i32 too:

block i32
  ...
end
end_function

If there are consecutive ends, this signature has to be propagate to
those blocks too, like:

block i32
  ...
  block i32
    ...
  end
end
end_function

This applies to try-end too:

try i32
  ...
catch
  ...
end
end_function

In case of try, we not only follow consecutive ends but also follow
catch, because for the type of the whole try to be i32, both try
and catch parts have to be i32:

try i32
  ...
  block i32
    ...
  end
catch
  ...
  block i32
    ...
  end
end
end_function

Previously we only handled consecutive ends or end before a catch.
But now we have delegate, which serves like end for
try-delegate. So we have to follow delegate too and mark its
corresponding try as i32 (the function's return type):

try i32
  ...
catch
  ...
  try i32    ;; Here
    ...
  delegate N
end
end_function

Diff Detail

Event Timeline

aheejin created this revision.Apr 22 2021, 2:15 AM
aheejin requested review of this revision.Apr 22 2021, 2:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 22 2021, 2:15 AM
tlively accepted this revision.Apr 22 2021, 11:06 AM
This revision is now accepted and ready to land.Apr 22 2021, 11:06 AM
This revision was automatically updated to reflect the committed changes.