Page MenuHomePhabricator

[WebAssembly] Add memory intrinsics handling to mayThrow()

Authored by aheejin on Oct 6 2019, 7:18 AM.



Previously, WebAssembly::mayThrow() assumed all inputs are global
addresses. But when intrinsics, such as memcpy, memmove, or memset
are lowered to external symbols in instruction selection and later
emitted as library calls. And these functions don't throw.

This patch adds handling to those memory intrinsics to mayThrow
function. But while most of libcalls don't throw, we can't guarantee all
of them don't throw, so currently we conservatively return true for all
other external symbols.

I think a better way to solve this problem is to embed 'nounwind' info
in [[ | TargetLowering::CallLoweringInfo ]], so that we can access the info
from the backend. This will also enable transferring 'nounwind'
properties of LLVM IR instructions. Currently we don't transfer that
info and we can only access properties of callee functions, if the
callees are within the module. Other targets don't need this info in the
backend because they do all the processing before isel, but it will help
us because that info will reduce code size increase in fixing unwind
destination mismatches in CFGStackify.

But for now we return false for these memory intrinsics and true for all
other libcalls conservatively.

Diff Detail


Event Timeline

aheejin created this revision.Oct 6 2019, 7:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 6 2019, 7:18 AM
aheejin edited the summary of this revision. (Show Details)Oct 6 2019, 9:37 AM
dschuff accepted this revision.Oct 7 2019, 8:51 AM

LGTM. It does seem probably worthwhile to go ahead and try out a patch for CallLoweringInfo at some point.

This revision is now accepted and ready to land.Oct 7 2019, 8:51 AM
aheejin edited the summary of this revision. (Show Details)Oct 7 2019, 2:11 PM
This revision was automatically updated to reflect the committed changes.