Use the lazy instruction ordering facility for block-local dominance
queries. IIUC this was just left out of https://reviews.llvm.org/D51664
as it was rebased.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lgtm
I don't think it got lost in the rebase, I just never actually did this, the obvious thing. The next cleanup is to get rid of OrderedInstructions which is now a glorified wrapper of DominatorTree.
llvm/lib/IR/Dominators.cpp | ||
---|---|---|
284 | This code makes every user that is a phi be dominated by the def? Not sure if I got confused here, but this looks fishy to me. Do we need this if at all? |
llvm/lib/IR/Dominators.cpp | ||
---|---|---|
284 | Yes, that's what this is doing, and no, I'm not sure this is /really/ needed. IIUC all phis in a block are thought to execute "instantly, together". The verifier tries to make this clear by enforcing grouping of phis at the start of a block. Perhaps this is part of the enforcement mechanism, by making phi1 dom phi2 = phi2 dom phi1? I find this inherently confusing, fwiw it's mentioned as a motivation for basic block arguments in the SIL/MLIR docs. |
llvm/lib/IR/Dominators.cpp | ||
---|---|---|
284 | Ugh. But what happens when a phi has an incoming value that is another phi? Consider this pseudocode: llvm ; predecessors %A, %B %a = phi i32, [0, %A], [%b, %B] %b = phi i32 [1, %A], [%2, %B] The use of b in a's definition is considered valid from the perspective of dominance according to this code. Quickly glancing the llvm language reference I don't see anything saying you cannot use a phi value from the same basic block as an incoming value in another phi. |
llvm/lib/IR/Dominators.cpp | ||
---|---|---|
284 | Thanks for the example. That's.. weird. But, yes, I think that is allowed under the "phis execute instantly, together" interpretation. I've added a unit test that shows this. |
llvm/lib/IR/Dominators.cpp | ||
---|---|---|
284 | Great, thanks for including this, especially since this isn't a part of your change. Note that the unit test is not exectly what I described, though: in my example, the first phi was forward-referencing the second phi. I'll try to follow up on this in a separe revision this weekend of the next week. |
llvm/lib/IR/Dominators.cpp | ||
---|---|---|
284 | Hi @vsk, I've just checked this and both the pattern I described and the one that you added in the test are invalid; there's verification rules and LIT tests that make sure phi nodes in the same block don't cross-reference each other. Empirically, removing this special case for phi nodes breaks lots of existing tests. |
This code makes every user that is a phi be dominated by the def?
So if we have two phis, the one that comes later may be said to dominate its predecessor?
Not sure if I got confused here, but this looks fishy to me. Do we need this if at all?