llvm.org GIT mirror llvm / c24f456
[MemorySSA] Additional handling of unreachable blocks. Summary: Whenever we get the previous definition, the assumption is that the recursion starts ina reachable block. If the recursion starts in an unreachable block, we may recurse indefinitely. Handle this case by returning LoE if the block is unreachable. Resolves PR43426. Reviewers: george.burgess.iv Subscribers: Prazek, sanjoy.google, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D68809 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374447 91177308-0d34-0410-b5e6-96231b3b80d8 Alina Sbirlea 1 year, 12 days ago
2 changed file(s) with 44 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
4646 if (Cached != CachedPreviousDef.end()) {
4747 return Cached->second;
4848 }
49
50 // If this method is called from an unreachable block, return LoE.
51 if (!MSSA->DT->isReachableFromEntry(BB))
52 return MSSA->getLiveOnEntryDef();
4953
5054 if (BasicBlock *Pred = BB->getSinglePredecessor()) {
5155 // Single predecessor case, just recurse, we can only have one definition.
0 ; RUN: opt -licm -enable-mssa-loop-dependency -S %s | FileCheck %s
1 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2 target triple = "x86_64-unknown-linux-gnu"
3
4 ; CHECK-LABEL: @d()
5 define dso_local void @d() {
6 entry:
7 br label %header
8
9 header:
10 store i32 1, i32* null, align 4
11 br i1 true, label %cleanup53, label %body
12
13 body:
14 br i1 undef, label %cleanup31, label %for.cond11
15
16 for.cond11: ; Needs branch as is
17 br i1 undef, label %unreachable, label %latch
18
19 cleanup31:
20 br label %unreachable
21
22 deadblock:
23 br i1 undef, label %unreachable, label %deadblock
24
25 cleanup53:
26 %val = load i32, i32* null, align 4
27 %cmpv = icmp eq i32 %val, 0
28 br i1 %cmpv, label %cleanup63, label %latch
29
30 latch:
31 br label %header
32
33 cleanup63:
34 ret void
35
36 unreachable:
37 unreachable
38 }
39