diff options
author | Andrew Wei <weiwei64@huawei.com> | 2021-08-26 22:52:42 +0800 |
---|---|---|
committer | Andrew Wei <weiwei64@huawei.com> | 2021-08-26 22:52:42 +0800 |
commit | c9066c5d37755c7d9049dd1fb7bd365bdef6155f (patch) | |
tree | f8622f5981b7dcdb007f7774d5a6ed7c8e33f5ad /llvm/lib/CodeGen/CodeGenPrepare.cpp | |
parent | 05f3219b38dad2806beda523fe83d43ffae3927c (diff) | |
download | llvm-c9066c5d37755c7d9049dd1fb7bd365bdef6155f.zip llvm-c9066c5d37755c7d9049dd1fb7bd365bdef6155f.tar.gz llvm-c9066c5d37755c7d9049dd1fb7bd365bdef6155f.tar.bz2 |
[CGP] Fix the crash for combining address mode when having cyclic dependency
In the combination of addressing modes, when replacing the matched phi nodes,
sometimes the phi node to be replaced has been modified. For example,
there’s matcher set [A, B] and [C, A], which will have cyclic dependency:
A is replaced by B and C will be replaced by A. Because we tried to match new phi node
to another new phi node, we should ignore new phi nodes when mapping new phi node to old one.
Reviewed By: skatkov
Differential Revision: https://reviews.llvm.org/D108635
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/CodeGenPrepare.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 50e5939..fba8f6d 100644 --- a/llvm/lib/CodeGen/CodeGenPrepare.cpp +++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp @@ -3718,7 +3718,8 @@ private: // Traverse all Phis until we found equivalent or fail to do that. bool IsMatched = false; for (auto &P : PHI->getParent()->phis()) { - if (&P == PHI) + // Skip new Phi nodes. + if (PhiNodesToMatch.count(&P)) continue; if ((IsMatched = MatchPhiNode(PHI, &P, Matched, PhiNodesToMatch))) break; |