1; SROA fails to rewrite allocs but does rewrite some phis and delete 2; dead instructions. Ensure that this invalidates analyses required 3; for other passes. 4; RUN: opt < %s -passes=bdce,sroa,bdce -o %t -debug-pass-manager 2>&1 | FileCheck %s 5; CHECK: Running pass: BDCEPass on H 6; CHECK: Running analysis: DemandedBitsAnalysis on H 7; CHECK: Running pass: SROA on H 8; CHECK: Invalidating all non-preserved analyses for: H 9; CHECK: Invalidating analysis: DemandedBitsAnalysis on H 10; CHECK: Running pass: BDCEPass on H 11; CHECK: Running analysis: DemandedBitsAnalysis on H 12; CHECK: Finished llvm::Function pass manager run. 13 14target datalayout = "e-m:e-i64:64-n32:64" 15target triple = "powerpc64le-grtev4-linux-gnu" 16 17%class.b = type { i64 } 18 19declare void @D(%class.b* sret, %class.b* dereferenceable(32)) local_unnamed_addr 20 21; Function Attrs: nounwind 22define hidden fastcc void @H(%class.b* noalias nocapture readnone, [2 x i64]) unnamed_addr { 23 %3 = alloca %class.b, align 8 24 %.sroa.0 = alloca i64, align 8 25 store i64 0, i64* %.sroa.0, align 8 26 %4 = extractvalue [2 x i64] %1, 1 27 switch i64 %4, label %6 [ 28 i64 4, label %foo 29 i64 5, label %5 30 ] 31 32; <label>:5: 33 %.sroa.0.0..sroa_cast3 = bitcast i64* %.sroa.0 to i8** 34 br label %12 35 36; <label>:6: 37 %7 = icmp ugt i64 %4, 5 38 %.sroa.0.0..sroa_cast5 = bitcast i64* %.sroa.0 to i8** 39 br i1 %7, label %8, label %12 40 41; <label>:8: 42 %9 = load i8, i8* inttoptr (i64 4 to i8*), align 4 43 %10 = icmp eq i8 %9, 47 44 %11 = select i1 %10, i64 5, i64 4 45 br label %12 46 47; <label>:12: 48 %13 = phi i8** [ %.sroa.0.0..sroa_cast3, %5 ], [ %.sroa.0.0..sroa_cast5, %8 ], [ %.sroa.0.0..sroa_cast5, %6 ] 49 %14 = phi i64 [ 4, %5 ], [ %11, %8 ], [ 4, %6 ] 50 %15 = icmp ne i64 %4, 0 51 %16 = icmp ugt i64 %4, %14 52 %17 = and i1 %15, %16 53 br i1 %17, label %18, label %a.exit 54 55; <label>:18: 56 %19 = tail call i8* @memchr(i8* undef, i32 signext undef, i64 undef) 57 %20 = icmp eq i8* %19, null 58 %21 = sext i1 %20 to i64 59 br label %a.exit 60 61a.exit: 62 %22 = phi i64 [ -1, %12 ], [ %21, %18 ] 63 %23 = load i8*, i8** %13, align 8 64 %24 = sub nsw i64 %22, %14 65 %25 = bitcast %class.b* %3 to i8* 66 call void @llvm.lifetime.start.p0i8(i64 32, i8* nonnull %25) 67 %26 = icmp ult i64 %24, 2 68 br i1 %26, label %G.exit, label %27 69 70; <label>:27: 71 %28 = getelementptr inbounds i8, i8* %23, i64 undef 72 %29 = icmp eq i8* %28, null 73 br i1 %29, label %30, label %31 74 75; <label>:30: 76 unreachable 77 78; <label>:31: 79 call void @D(%class.b* nonnull sret %3, %class.b* nonnull dereferenceable(32) undef) 80 br label %G.exit 81 82G.exit: 83 call void @llvm.lifetime.end.p0i8(i64 32, i8* nonnull %25) 84 br label %foo 85 86foo: 87 ret void 88} 89 90; Function Attrs: nounwind readonly 91declare i8* @memchr(i8*, i32 signext, i64) local_unnamed_addr 92 93; Function Attrs: argmemonly nounwind 94declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) 95 96; Function Attrs: argmemonly nounwind 97declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) 98