This is an archive of the discontinued LLVM Phabricator instance.

Use new TokenFactor chain when merging stores
ClosedPublic

Authored by arsenm on Sep 10 2015, 2:16 PM.

Details

Reviewers
hfinkel
Summary

If the stores are storing values from loads which partially
alias the stores, we could end up placing the merged loads
and stores on the same chain which has the potential to break.
Each store may have a different chain dependency on only some
of the original loads. Create a new TokenFactor to capture all
of the required dependencies of the stores rather than assuming
all stores can use the same chain.

The testcase is a situation where this happens, although
it does not have an observable change from this. The DAG nodes
just happened to not be reordered before despite this missing
chain dependency.

This is based on an off-list report for an out of tree target
which regressed due to r246307 and I haven't managed to find a case
where the nodes do end up reordered with an in tree target.

Diff Detail

Event Timeline

arsenm updated this revision to Diff 34491.Sep 10 2015, 2:16 PM
arsenm retitled this revision from to Use new TokenFactor chain when merging stores.
arsenm updated this object.
arsenm added a reviewer: hfinkel.
arsenm added a subscriber: llvm-commits.
arsenm updated this revision to Diff 34518.Sep 10 2015, 5:40 PM

Fix test to enable -combiner-alias-analysis

arsenm updated this revision to Diff 34619.Sep 11 2015, 9:50 PM

Fix not adding 1st store's chain to new TokenFactor

hfinkel edited edge metadata.Sep 18 2015, 7:41 PM

I haven't managed to find a case where the nodes do end up reordered with an in tree target.

Obviously less than ideal, but you can write a 'REQUIRES: asserts' test using -debug that directly checks the SDAG nodes.

test/CodeGen/X86/merge-store-partially-alias-loads.ll
11

Seems like these should be CHECK-DAG (with some regexes for the registers).

arsenm updated this revision to Diff 35179.Sep 19 2015, 1:37 PM
arsenm edited edge metadata.

Test DAG debug lines

arsenm added inline comments.Sep 19 2015, 1:40 PM
test/CodeGen/X86/merge-store-partially-alias-loads.ll
11

I changed to regexes for the registers, but kept the -NEXTs because the point of the test is how these are ordered

hfinkel added inline comments.Sep 20 2015, 5:10 AM
test/CodeGen/X86/merge-store-partially-alias-loads.ll
12

For all of them? Why does the relative order of the loads matter?

arsenm updated this revision to Diff 35205.Sep 20 2015, 10:43 AM

Use -DAG for load order

arsenm updated this revision to Diff 35210.Sep 20 2015, 6:59 PM

Fix not adding chains when storing constants. Fixes regressions from losing half of the stores in tests added by D12698

hfinkel accepted this revision.Sep 23 2015, 5:59 AM
hfinkel edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Sep 23 2015, 5:59 AM
arsenm closed this revision.Sep 24 2015, 12:24 AM

r248468