This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix broken assumption that all bitcasts are to functions types
ClosedPublic

Authored by sbc100 on Nov 12 2018, 2:02 PM.

Details

Summary

Handle bitcasts to non-function (integer) pointer types and also handle cast
instructions as well as cast const exprs.

Fixes PR39591

Diff Detail

Repository
rL LLVM

Event Timeline

sbc100 created this revision.Nov 12 2018, 2:02 PM
sbc100 edited the summary of this revision. (Show Details)Nov 12 2018, 2:04 PM
sbc100 added a reviewer: dschuff.
sbc100 updated this revision to Diff 173759.Nov 12 2018, 2:08 PM
  • improve tests
sbc100 updated this revision to Diff 173760.Nov 12 2018, 2:10 PM
  • improve tests
dschuff added inline comments.Nov 12 2018, 3:38 PM
lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
123 ↗(On Diff #173760)

nit: this (and below) could be auto because of the dyn_cast

129 ↗(On Diff #173760)

isn't this modifying F.uses while iterating over it?

sbc100 updated this revision to Diff 173788.Nov 12 2018, 5:07 PM
  • feedbac + clang-format
lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
129 ↗(On Diff #173760)

I'm not sure. Is the eraseFromParent call that makes you think that? Any idea how would I validate that?

sbc100 updated this revision to Diff 173791.Nov 12 2018, 5:18 PM
  • erase after uses iteration
dschuff accepted this revision.Nov 13 2018, 11:09 AM
dschuff added inline comments.
lib/Target/WebAssembly/WebAssemblyAddMissingPrototypes.cpp
129 ↗(On Diff #173760)

Yes, Inst is a user of F, and I'm pretty sure eraseFromParent removes the instruction from the BB list and also drops its use references.
edit: yes, it's the operator delete of User that does that.

This revision is now accepted and ready to land.Nov 13 2018, 11:09 AM
This revision was automatically updated to reflect the committed changes.