This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Remove duplicated line of code and unreachable check. NFC
ClosedPublic

Authored by ncw on Mar 6 2018, 5:57 AM.

Details

Summary

Note - the line of code removed is duplicated at the end of createCtorFunction. It *used* to do something different to the line at the top, but now after some refactoring the line has in fact become useless.

Note 2 - the liveness check came to my eye because there's a clear typo in the line ("return" instead of "continue"). I tried to write a test to exercise the bug, but found that in fact it's not possible, since relocatable can't be used with GC, so it's not possible to have non-Live symbols in the symtab.

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

ncw created this revision.Mar 6 2018, 5:57 AM
sbc100 added inline comments.Mar 6 2018, 11:45 AM
wasm/Writer.cpp
697–699

But this isn't iterating the symbol table, its iterating all symbols in all the objects. Surely some of them can be non-live. I don't quite understand why we not hitting this case in some unit test.

ncw added inline comments.Mar 6 2018, 2:29 PM
wasm/Writer.cpp
697–699

The entire method Writer::assignSymtab has an early-exit for non-relocatable output. So all symbols are always Live when generating a symtab, since that's the relocatable case (and GC and relocatable are exclusive).

sbc100 accepted this revision.Mar 6 2018, 2:42 PM

lgtm, with commets.

wasm/Writer.cpp
697–699

I see. That was non-obvious to me, so perhaps at least comment?

This makes two assumptions:

  1. liveness is only ever set by GC
  2. GC never applies in relocatable mode.

I guess as long as the assert is here we will know if we ever violate those assumption, but I'm on the fence as to weather to just leave the check in. I'd be happy with a comment here explaining the assumptions I think.

This revision is now accepted and ready to land.Mar 6 2018, 2:42 PM
ncw added inline comments.Mar 6 2018, 2:55 PM
wasm/Writer.cpp
697–699

I'll add a comment then, so we don't have a dead branch. As it is (with "return" rather than "continue") it needs to be changed somehow. Thanks!

This revision was automatically updated to reflect the committed changes.