This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Consolidate sectionTypeToString in BinaryFormat [NFC]
ClosedPublic

Authored by dschuff on May 27 2022, 8:31 AM.

Details

Summary

Currently there are 2 duplicate implementation, and I want to add
a use in a 3rd place. Combine them in lib/BinaryFormat so they can
be shared.

Also update the return values of the reloc and symbol type toString functions to use StringRef.

Diff Detail

Event Timeline

dschuff created this revision.May 27 2022, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2022, 8:31 AM
Herald added subscribers: pmatos, asb, wingo and 4 others. · View Herald Transcript
dschuff requested review of this revision.May 27 2022, 8:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 27 2022, 8:31 AM
sbc100 added inline comments.May 27 2022, 8:33 AM
llvm/include/llvm/BinaryFormat/Wasm.h
474

Use std::string for consistency with the two above? Or convert them all the StringRef?

dschuff added inline comments.
llvm/include/llvm/BinaryFormat/Wasm.h
474

I had originally planned that for after D126509 but I guess since this is now just a pure refactor, we can add it in. As I said there, IMO StringRef would be better since the backing store is just a static const char* and then we wouldn't need to copy. But I'll check whether any of the uses of relocTypeToString and toString really do need to be std::string.

dschuff updated this revision to Diff 432581.May 27 2022, 9:08 AM

also update reloc and symbol type functions

dschuff updated this revision to Diff 432582.May 27 2022, 9:09 AM

include all the diffs

llvm/include/llvm/BinaryFormat/Wasm.h
474

OK, they're all stringref now, no callsite changes were needed.

sbc100 accepted this revision.May 27 2022, 9:17 AM
This revision is now accepted and ready to land.May 27 2022, 9:17 AM
dschuff edited the summary of this revision. (Show Details)May 27 2022, 9:25 AM
This revision was landed with ongoing or failed builds.May 27 2022, 9:28 AM
This revision was automatically updated to reflect the committed changes.