This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Support opaque pointers in FixFunctionBitcasts
ClosedPublic

Authored by nikic on Aug 28 2021, 2:58 PM.

Details

Summary

With opaque pointers, no actual bitcasts will be present. Instead, there will be a mismatch between the call FunctionType and the function ValueType. Change the code to collect CallBases specifically (rather than general Uses) and compare these types.

Diff Detail

Event Timeline

nikic created this revision.Aug 28 2021, 2:58 PM
nikic requested review of this revision.Aug 28 2021, 2:58 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 28 2021, 2:58 PM

@dschuff, IIRC, we were talking about what opaque pointers would mean for function pointer casts just the other day. Well here's the answer!

llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
84–86

Why can this logic be removed?

nikic added inline comments.Aug 30 2021, 12:54 AM
llvm/lib/Target/WebAssembly/WebAssemblyFixFunctionBitcasts.cpp
84–86

I dropped the RAUW call on constants that this is guarding against. With opaque pointers, there is no bitcast to RAUW (the only thing that could be potentially RAUWd is the GlobalAlias case).

I'm not sure if dropping the RAUW call itself is problematic, at least there was no test coverage for why it would be needed. I could imagine something like a function bitcast being called directly in one place, and then also being stored to memory in another place and then called indirectly or something like that? Though that already wouldn't work if there is no direct call and only indirect calls. So I'm not really sure why it was there.

tlively accepted this revision.Sep 1 2021, 12:47 PM
This revision is now accepted and ready to land.Sep 1 2021, 12:47 PM
This revision was automatically updated to reflect the committed changes.