This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix fixBrTableIndex removing instruction without checking uses
ClosedPublic

Authored by aardappel on Nov 4 2021, 5:23 PM.

Diff Detail

Event Timeline

aardappel created this revision.Nov 4 2021, 5:23 PM
aardappel requested review of this revision.Nov 4 2021, 5:23 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 4 2021, 5:23 PM

There might be a more elegant way to test if an instruction still has users for its def/reg, anyone know?

Also I could add a test for this.. this particular situation does not come up in C/C++, but I could de-compile the Rust generated bitcode (see linked bug) to ll and generate a test from that. Not sure how useful that is though, as eraseFromParent was clearly wrong here and this is the code that should have been there in the first place.

tlively added inline comments.Nov 5 2021, 11:41 AM
llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
68–71

Looks like we probably want to use MachineRegisterInfo::hasOneNonDBGUser(Register RegNo) here. Hopefully that lets us get rid of the goto ;)

Also, it would be nice to have a test for this, but if it would be too much trouble, then I guess it's fine.

aardappel updated this revision to Diff 385595.Nov 8 2021, 12:29 PM

Simplified using use_nodbg_empty

aardappel added inline comments.Nov 8 2021, 12:30 PM
llvm/lib/Target/WebAssembly/WebAssemblyFixBrTableDefaults.cpp
68–71

Thanks! Not sure how I managed to miss those functions. In this case use_nodbg_empty is the one we actually want, since the use by br_table has already been removed.

tlively accepted this revision.Nov 8 2021, 2:02 PM
This revision is now accepted and ready to land.Nov 8 2021, 2:02 PM