This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix libcall signature lookup
ClosedPublic

Authored by dschuff on Jan 18 2018, 4:24 PM.

Details

Summary

RuntimeLibcallSignatures previously manually initialized all the libcall
names into an array and searched it linearly for the first match to lookup
the corresponding index.
r322802 switched that to initializing a map keyed by the libcall name.
Neither of these approaches works correctly because some libcall numbers use
the same name on different platforms (e.g. the "l" suffixed functions
use f80 or f128 or ppcf128).

This change fixes that by ensuring that each name only goes into the map
once. It also adds tests.

Diff Detail

Event Timeline

dschuff created this revision.Jan 18 2018, 4:24 PM
dschuff updated this revision to Diff 130521.Jan 18 2018, 4:42 PM
  • fix build
sbc100 added inline comments.Jan 18 2018, 5:45 PM
lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
468

No need for StringRefOrEmpty anymore since its already inside a null check?

dschuff added inline comments.Jan 19 2018, 8:43 AM
lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
468

Actually it is needed because the macro expands to Map.find(nullptr) and you can't construct a StringRef from nullptr. However I just double-checked that and discovered that I duplicated StringRef::withNullAsEmpty() so, switched to that 👍

dschuff updated this revision to Diff 130630.Jan 19 2018, 8:44 AM
  • use StringRef::withNullAsEmpty() and clang-format
This revision was not accepted when it landed; it landed in state Needs Review.Jan 19 2018, 9:49 AM
This revision was automatically updated to reflect the committed changes.