[WebAssembly] Generate unreachable after __stack_chk_fail
authorHeejin Ahn <aheejin@gmail.com>
Wed, 8 Jul 2020 07:59:21 +0000 (00:59 -0700)
committerHeejin Ahn <aheejin@gmail.com>
Wed, 8 Jul 2020 08:02:05 +0000 (01:02 -0700)
commit7e6793aa33dd61ed9dd531871fce30c1b7978e13
tree82b8f6e3e1f3a2f22f1a882574f433efeefadb76
parent80970ac87574c6d0292894a4a912fa512336f434
[WebAssembly] Generate unreachable after __stack_chk_fail

`__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.

Reviewed By: tlively

Differential Revision: https://reviews.llvm.org/D83277
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/test/CodeGen/WebAssembly/stack-protector.ll