diff options
author | Florian Hahn <flo@fhahn.com> | 2023-05-24 20:16:41 +0100 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2023-05-24 20:16:42 +0100 |
commit | f0687b47a0ce82da07127fee4fe6af801df54ca6 (patch) | |
tree | 11230a0830b374845d6405ec2f3d42fd3c431856 /clang/lib/CodeGen/CGCall.cpp | |
parent | 0daa80e856152ed3250e2925195098f436531ce9 (diff) | |
download | llvm-f0687b47a0ce82da07127fee4fe6af801df54ca6.zip llvm-f0687b47a0ce82da07127fee4fe6af801df54ca6.tar.gz llvm-f0687b47a0ce82da07127fee4fe6af801df54ca6.tar.bz2 |
[IRGen] Handle infinite cycles in findDominatingStoreToReturnValue.
If there is an infinite cycle in the IR, the loop will never exit. Keep
track of visited basic blocks in a set and return nullptr if a block is
visited again.
Fixes #62830.
Reviewed By: rjmccall
Differential Revision: https://reviews.llvm.org/D151076
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 6a1d549..ec28c1d 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -3461,8 +3461,9 @@ static llvm::StoreInst *findDominatingStoreToReturnValue(CodeGenFunction &CGF) { // single-predecessors chain from the current insertion point. llvm::BasicBlock *StoreBB = store->getParent(); llvm::BasicBlock *IP = CGF.Builder.GetInsertBlock(); + llvm::SmallPtrSet<llvm::BasicBlock *, 4> SeenBBs; while (IP != StoreBB) { - if (!(IP = IP->getSinglePredecessor())) + if (!SeenBBs.insert(IP).second || !(IP = IP->getSinglePredecessor())) return nullptr; } |