This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Generate unreachable after __stack_chk_fail
ClosedPublic

Authored by aheejin on Jul 6 2020, 10:06 PM.

Details

Summary

__stack_chk_fail does not return, but unreachable was not generated
following call __stack_chk_fail. This had a possibility to generate an
invalid binary for functions with a return type, because
__stack_chk_fail's return type is void and call __stack_chk_fail can
be the last instruction in the function whose return type is non-void.
Generating unreachable after it makes sure CFGStackify's
fixEndsAtEndOfFunction handles it correctly.

Diff Detail

Event Timeline

aheejin created this revision.Jul 6 2020, 10:06 PM
aheejin updated this revision to Diff 275904.Jul 6 2020, 10:08 PM
aheejin marked an inline comment as done.
  • Align FileCheck lines
llvm/test/CodeGen/WebAssembly/stack-protector.ll
4

After adding unreachable, somehow the branch order changed and this became i32.eq instead, so I deleted this.

aheejin edited the summary of this revision. (Show Details)Jul 6 2020, 10:11 PM
tlively accepted this revision.Jul 6 2020, 11:35 PM
tlively added a subscriber: tlively.

LGTM!

This revision is now accepted and ready to land.Jul 6 2020, 11:35 PM
aheejin edited the summary of this revision. (Show Details)Jul 8 2020, 12:41 AM
This revision was automatically updated to reflect the committed changes.