This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Disable offset folding for function addresses
ClosedPublic

Authored by aheejin on Aug 11 2021, 6:20 PM.

Details

Summary

Wasm does not support function addresses with offsets, but isel can
generate folded SDValues in the form of (@func + offset) without this
patch.

Fixes https://bugs.llvm.org/show_bug.cgi?id=43133.

Diff Detail

Event Timeline

aheejin created this revision.Aug 11 2021, 6:20 PM
aheejin requested review of this revision.Aug 11 2021, 6:20 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2021, 6:20 PM
aheejin updated this revision to Diff 365888.Aug 11 2021, 6:23 PM

Change target triple to wasm32-unknown-unknown (Doesn't matter here though)

I love how precise this patch is. Does exactly what we need.

llvm/test/CodeGen/WebAssembly/function-pointer-offset.ll
19

Seems odd not to have any checks here other than the successful compile.. but maybe just the fact that we don't see the fatal error is enough? Perhaps mention that if folding did occur a fatal error would be generated in the backend?

aheejin updated this revision to Diff 365892.Aug 11 2021, 6:37 PM

Add CHECK lines

aheejin marked an inline comment as done.Aug 11 2021, 6:38 PM
aheejin added inline comments.
llvm/test/CodeGen/WebAssembly/function-pointer-offset.ll
19

Yeah this shouldn't crash. But added some CHECK lines too, and added a description that this shouldn't crash in MCInstLower.

sbc100 accepted this revision.Aug 11 2021, 6:56 PM

Maybe add Fixes: https://bugs.llvm.org/show_bug.cgi?id=43133 to the description?

lgtm but maybe wait for final review from @dschuff

This revision is now accepted and ready to land.Aug 11 2021, 6:56 PM
aheejin edited the summary of this revision. (Show Details)Aug 11 2021, 7:02 PM
aheejin updated this revision to Diff 365897.Aug 11 2021, 7:03 PM
aheejin marked an inline comment as done.

More comment

aheejin updated this revision to Diff 365902.Aug 11 2021, 8:39 PM

function-pointer-offset.ll -> function-offset.ll

aheejin updated this revision to Diff 365903.Aug 11 2021, 8:41 PM

function-offset.ll -> function-addr-offset.ll

dschuff accepted this revision.Aug 12 2021, 11:48 AM
This revision was landed with ongoing or failed builds.Aug 12 2021, 1:41 PM
This revision was automatically updated to reflect the committed changes.