[PATCH] D120330: [MachineSink] Fix CFG walk in clobber check (PR53990)
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 22 08:09:04 PST 2022
nikic created this revision.
nikic added reviewers: shchenz, qcolombet.
Herald added subscribers: pengfei, hiraditya.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
MachineSink::hasStoreBetween() determines that the code is "straight-line" by checking that From dominates To and To post-dominates From. Then it does a DFS walk starting at To, but only considers MBBs post-dominated by From.
The critical part this misses, is while the code is, in a certain sense of the word, "straight-line", it may still be part of a loop. To give a simple example:
From -> BB2
\ / A
v v |
To -> BB3
Here From dominates To, and To post-dominates From, and the current code would only check for a clobber in BB2, but not in BB3. (Unfortunately, I was not able to get MachineSink to trigger with a CFG that simple.)
What we actually want to determine is that no clobber is reverse-reachable from To (without going through From), so implement that, without the post-dominance check.
Fixes https://github.com/llvm/llvm-project/issues/53990.
https://reviews.llvm.org/D120330
Files:
llvm/lib/CodeGen/MachineSink.cpp
llvm/test/CodeGen/X86/pr53990-incorrect-machine-sink.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120330.410538.patch
Type: text/x-patch
Size: 5343 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220222/22c24e2e/attachment.bin>
More information about the llvm-commits
mailing list