1; This test exercises that we don't corrupt a loop-analysis when running loop 2; unrolling in a way that deletes a loop. To do that, we first ensure the 3; analysis is cached, then unroll the loop (deleting it) and make sure that the 4; next function doesn't get a cache "hit" for this stale analysis result. 5; 6; RUN: opt -S -passes='loop(require<access-info>),loop-unroll,loop(print-access-info)' -debug-pass-manager < %s 2>&1 | FileCheck %s 7; 8; CHECK: Starting llvm::Function pass manager run. 9; CHECK: Running analysis: LoopAnalysis 10; CHECK: Running analysis: InnerAnalysisManagerProxy< 11; CHECK: Starting Loop pass manager run. 12; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis 13; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner1.header 14; CHECK: Finished Loop pass manager run. 15; CHECK: Starting Loop pass manager run. 16; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis 17; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 2 containing: %inner2.header 18; CHECK: Finished Loop pass manager run. 19; CHECK: Starting Loop pass manager run. 20; CHECK: Running pass: RequireAnalysisPass<{{.*}}LoopAccessAnalysis 21; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %outer.header 22; CHECK: Finished Loop pass manager run. 23; CHECK: Running pass: LoopUnrollPass 24; CHECK: Clearing all analysis results for: inner2.header 25; CHECK: Clearing all analysis results for: outer.header 26; CHECK: Invalidating analysis: LoopAccessAnalysis on inner1.header 27; CHECK-NOT: Invalidating analysis: LoopAccessAnalysis on inner1.header.1 28; CHECK: Starting Loop pass manager run. 29; CHECK: Running pass: LoopAccessInfoPrinterPass 30; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header 31; CHECK: Loop access info in function 'test': 32; CHECK: inner1.header: 33; CHECK: Finished Loop pass manager run. 34; CHECK: Starting Loop pass manager run. 35; CHECK: Running pass: LoopAccessInfoPrinterPass 36; CHECK: Running analysis: LoopAccessAnalysis on Loop at depth 1 containing: %inner1.header.1 37; CHECK: Loop access info in function 'test': 38; CHECK: inner1.header.1: 39; CHECK: Finished Loop pass manager run. 40 41target triple = "x86_64-unknown-linux-gnu" 42 43define void @test(i32 %inner1.count) { 44; CHECK-LABEL: define void @test( 45bb: 46 br label %outer.ph 47 48outer.ph: 49 br label %outer.header 50 51outer.header: 52 %outer.i = phi i32 [ 0, %outer.ph ], [ %outer.i.next, %outer.latch ] 53 br label %inner1.ph 54 55inner1.ph: 56 br label %inner1.header 57 58inner1.header: 59 %inner1.i = phi i32 [ 0, %inner1.ph ], [ %inner1.i.next, %inner1.header ] 60 %inner1.i.next = add i32 %inner1.i, 1 61 %inner1.cond = icmp eq i32 %inner1.i, %inner1.count 62 br i1 %inner1.cond, label %inner1.exit, label %inner1.header 63; We should have two unrolled copies of this loop and nothing else. 64; 65; CHECK-NOT: icmp eq 66; CHECK-NOT: br i1 67; CHECK: %[[COND1:.*]] = icmp eq i32 %{{.*}}, %inner1.count 68; CHECK: br i1 %[[COND1]], 69; CHECK-NOT: icmp eq 70; CHECK-NOT: br i1 71; CHECK: %[[COND2:.*]] = icmp eq i32 %{{.*}}, %inner1.count 72; CHECK: br i1 %[[COND2]], 73; CHECK-NOT: icmp eq 74; CHECK-NOT: br i1 75 76 77inner1.exit: 78 br label %inner2.ph 79 80inner2.ph: 81 br label %inner2.header 82 83inner2.header: 84 %inner2.i = phi i32 [ 0, %inner2.ph ], [ %inner2.i.next, %inner2.header ] 85 %inner2.i.next = add i32 %inner2.i, 1 86 %inner2.cond = icmp eq i32 %inner2.i, 4 87 br i1 %inner2.cond, label %inner2.exit, label %inner2.header 88 89inner2.exit: 90 br label %outer.latch 91 92outer.latch: 93 %outer.i.next = add i32 %outer.i, 1 94 %outer.cond = icmp eq i32 %outer.i.next, 2 95 br i1 %outer.cond, label %outer.exit, label %outer.header 96 97outer.exit: 98 br label %exit 99 100exit: 101 ret void 102} 103