This is an archive of the discontinued LLVM Phabricator instance.

[WebAssembly] Fix dominance check for PHIs in the StoreResult pass
ClosedPublic

Authored by sunfish on Dec 3 2015, 2:33 PM.

Details

Summary

When a block has no terminator instructions, getFirstTerminator() returns end(), which can't be used in dominance checks. Check dominance for phi operands separately.

Also, remove some bits from WebAssemblyRegStackify.cpp that were causing trouble on the same testcase; they were left behind from an earlier experiment.

Diff Detail

Repository
rL LLVM

Event Timeline

sunfish updated this revision to Diff 41805.Dec 3 2015, 2:33 PM
sunfish retitled this revision from to [WebAssembly] Fix dominance check for PHIs in the StoreResult pass.
sunfish updated this object.
sunfish added a reviewer: dschuff.
sunfish set the repository for this revision to rL LLVM.
sunfish added a subscriber: llvm-commits.
dschuff accepted this revision.Dec 3 2015, 2:55 PM
dschuff edited edge metadata.

otherwise LGTM

lib/Target/WebAssembly/WebAssemblyStoreResults.cpp
95 ↗(On Diff #41805)

I don't really understand what this arithmetic on the MachineOperands actually means.
I guess it's just trying to find which operand on Where is the use of MI.

Actually there's also nothing that explicitly says what the pass even does.
IIUC we are attempting to find uses of the stored value and make them uses of the result of the store instead (which we can do if the store dominates the use), so maybe it should say that somewhere.

test/CodeGen/WebAssembly/store-results.ll
26 ↗(On Diff #41805)

could this maybe say what the nature of the corner case is for each of these functions?

This revision is now accepted and ready to land.Dec 3 2015, 2:55 PM
This revision was automatically updated to reflect the committed changes.

Thanks!

lib/Target/WebAssembly/WebAssemblyStoreResults.cpp
95 ↗(On Diff #41805)

Yes, it's computing the block paired with a use in the phi. I expanded the comment.

The comment at the top of the file describes what this pass does, but it was pretty terse. I expanded it now.

test/CodeGen/WebAssembly/store-results.ll
26 ↗(On Diff #41805)

I expanded the comment describing these tests.