This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Add missing --demangle arg
ClosedPublic

Authored by ncw on Mar 9 2018, 6:27 AM.

Details

Summary

Previously, Config->Demangle was not only not hooked up to commandline handling, but was uninitialised

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

ncw created this revision.Mar 9 2018, 6:27 AM
sbc100 added a comment.Mar 9 2018, 3:26 PM

I think perhaps we should just drop the max-memory flag completely? At least until we know they its needed. emscripten doesn't need it and nor does the wasm waterfall.

Common/Args.cpp
30 ↗(On Diff #137739)

I would hope we don't need to add this.

wasm/Writer.cpp
120 ↗(On Diff #137739)

I'm OK with 0 meaning no max. Especially if i means you can avoid adding an duplicate getInteger helper for options?

TBH, I'm torn about weather to just remove this option though. Do you know of any users who what to set a max?

618 ↗(On Diff #137739)

Should probably error out if InitialMemory is not enough, rather than just making it bigger.

Also, should we have have these value specific in page size?

If not we should error out if user specified a non-aligned value (like we do for StackSize).

ruiu added a comment.Mar 9 2018, 4:42 PM

Please split it into two patches, one for --demangle and the other for --initial/max-memory.

ncw added a comment.Mar 10 2018, 8:08 AM

OK, I'll split this in two, and fix the nits regarding 0 for unset and forcing aligned values.

I think it is worth keeping MaxMemory and InitialMemory, even though they have limited use-cases. It's a memory-sanity feature, to ask the browser to keep a lid on your memory usage (based on what you know your code should be using), rather than letting bugs and leaks chew up RAM until it's exhausted. I think people probably should use it as a matter of course, to avoid reports of spiralling memory usage from users of their Wasm library! Maybe no-one will bother using it though.

Common/Args.cpp
30 ↗(On Diff #137739)

It's there to prevent people entering a negative number. Is that right, to have an unsigned variant? I mean we could parse it as a signed int, but then we'd have to add error-checking code to handle negative values, whereas punting that problem to llvm::to_integer seems simpler.

ncw added inline comments.Mar 10 2018, 8:15 AM
wasm/Writer.cpp
120 ↗(On Diff #137739)

Oh - a further thought on zero. I remember now why I didn't do that, it's because for both Initial and Max is it possible to have zero as a legal value? Can a module not use the memory at all? I'm not sure we currently support it, but one day we might do. Zero does have a real "semantic" meaning for maximum, which is the opposite of "no maximum", whereas UINT32_MAX has a "semantic" meaning that exactly matches "no maximum".

ncw updated this revision to Diff 138032.Mar 12 2018, 9:16 AM
ncw retitled this revision from [WebAssembly] Add missing --demangle and --initial/max-memory args to [WebAssembly] Add missing --demangle arg.
ncw edited the summary of this revision. (Show Details)

Updated to remove max/initial mem args, this just covers demangle now

sbc100 accepted this revision.Mar 12 2018, 1:03 PM

Great! Much more precise.

This revision is now accepted and ready to land.Mar 12 2018, 1:03 PM
This revision was automatically updated to reflect the committed changes.