llvm.org GIT mirror llvm / 7956582
[LICM] Allow AliasSetMap to contain top-level loops. When an outer loop gets deleted by a different pass, before LICM visits it, we cannot clean up its sub-loops in AliasSetMap, because at the point we receive the deleteAnalysisLoop callback for the outer loop, the loop object is already invalid and we cannot access its sub-loops any longer. Reviewers: asbirlea, sanjoy, chandlerc Reviewed By: asbirlea Differential Revision: https://reviews.llvm.org/D61904 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360704 91177308-0d34-0410-b5e6-96231b3b80d8 Florian Hahn 4 months ago
2 changed file(s) with 55 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
243243 using llvm::Pass::doFinalization;
244244
245245 bool doFinalization() override {
246 assert(LICM.getLoopToAliasSetMap().empty() &&
246 auto &AliasSetMap = LICM.getLoopToAliasSetMap();
247 // All loops in the AliasSetMap should be cleaned up already. The only case
248 // where we fail to do so is if an outer loop gets deleted before LICM
249 // visits it.
250 assert(all_of(AliasSetMap,
251 [](LoopInvariantCodeMotion::ASTrackerMapTy::value_type &KV) {
252 return !KV.first->getParentLoop();
253 }) &&
247254 "Didn't free loop alias sets");
255 AliasSetMap.clear();
248256 return false;
249257 }
250258
0 ; RUN: opt %s -S -loop-unroll -licm | FileCheck %s
1
2 ; Check that we can deal with loops where a parent loop gets deleted before it
3 ; is visited by LICM.
4 define void @test() {
5 ; CHECK-LABEL: define void @test() {
6 ; CHECK-LABEL: entry:
7 ; CHECK-NEXT: br label %for.body43
8
9 ; CHECK-LABEL: for.body43: ; preds = %entry
10 ; CHECK-NEXT: br label %if.else75
11
12 ; CHECK-LABEL: if.else75: ; preds = %for.body43
13 ; CHECK-NEXT: br label %for.body467
14
15 ; CHECK-LABEL: for.body467: ; preds = %for.body467.for.body467_crit_edge, %if.else75
16 ; CHECK-NEXT: br label %for.body467.for.body467_crit_edge
17
18 ; CHECK-LABEL: for.body467.for.body467_crit_edge: ; preds = %for.body467
19 ; CHECK-NEXT: br i1 false, label %for.end539, label %for.body467
20
21 ; CHECK-LABEL: for.end539: ; preds = %for.body467.for.body467_crit_edge
22 ; CHECK-NEXT: ret void
23 ;
24
25 entry:
26 br label %for.body43
27
28 for.body43: ; preds = %for.end539, %entry
29 br label %if.else75
30
31 if.else75: ; preds = %for.body43
32 br label %for.body467
33
34 for.body467: ; preds = %for.body467.for.body467_crit_edge, %if.else75
35 br label %for.body467.for.body467_crit_edge
36
37 for.body467.for.body467_crit_edge: ; preds = %for.body467
38 br i1 false, label %for.end539, label %for.body467
39
40 for.end539: ; preds = %for.body467
41 br i1 undef, label %for.body43, label %for.end547
42
43 for.end547: ; preds = %for.body43
44 ret void
45 }