1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -gvn -S < %s | FileCheck %s 3 4; Memdep had funny bug related to invariant.groups - because it did not 5; invalidated cache, in some very rare cases it was possible to show memory 6; dependence of the instruction that was deleted, but because other instruction 7; took it's place it resulted in call to vtable! Removing any of the branch 8; hides the bug. 9 10target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 11target triple = "x86_64-grtev4-linux-gnu" 12 13%0 = type { i32 (...)**, %1 } 14%1 = type { %2 } 15%2 = type { %3 } 16%3 = type { %4, i64, %5 } 17%4 = type { i8* } 18%5 = type { i64, [8 x i8] } 19 20define void @fail(i1* noalias sret, %0*, %1*, i8*) local_unnamed_addr #0 { 21; CHECK-LABEL: @fail( 22; CHECK-NEXT: [[TMP5:%.*]] = bitcast %0* [[TMP1:%.*]] to i64 (%0*)*** 23; CHECK-NEXT: [[TMP6:%.*]] = load i64 (%0*)**, i64 (%0*)*** [[TMP5]], align 8, !invariant.group !6 24; CHECK-NEXT: [[TMP7:%.*]] = getelementptr inbounds i64 (%0*)*, i64 (%0*)** [[TMP6]], i64 6 25; CHECK-NEXT: [[TMP8:%.*]] = load i64 (%0*)*, i64 (%0*)** [[TMP7]], align 8, !invariant.load !6 26; CHECK-NEXT: [[TMP9:%.*]] = tail call i64 [[TMP8]](%0* [[TMP1]]) #1 27; CHECK-NEXT: [[TMP10:%.*]] = getelementptr inbounds [[TMP1]], %1* [[TMP2:%.*]], i64 0, i32 0, i32 0, i32 0, i32 0 28; CHECK-NEXT: [[TMP11:%.*]] = load i8*, i8** [[TMP10]], align 8 29; CHECK-NEXT: store i8 0, i8* [[TMP11]], align 1 30; CHECK-NEXT: [[TMP12:%.*]] = bitcast i64 (%0*)** [[TMP6]] to i64 (%0*, i8*, i64)** 31; CHECK-NEXT: br i1 undef 32; CHECK: [[TMP14:%.*]] = bitcast %0* [[TMP1]] to i64 (%0*, i8*, i64)*** 33; CHECK-NEXT: [[DOTPHI_TRANS_INSERT:%.*]] = getelementptr inbounds i64 (%0*, i8*, i64)*, i64 (%0*, i8*, i64)** [[TMP12]], i64 22 34; CHECK-NEXT: [[DOTPRE:%.*]] = load i64 (%0*, i8*, i64)*, i64 (%0*, i8*, i64)** [[DOTPHI_TRANS_INSERT]], align 8, !invariant.load !6 35; CHECK-NEXT: br label [[TMP15:%.*]] 36; CHECK: [[TMP16:%.*]] = call i64 [[DOTPRE]](%0* nonnull [[TMP1]], i8* null, i64 0) #1 37 38 %5 = bitcast %0* %1 to i64 (%0*)*** 39 %6 = load i64 (%0*)**, i64 (%0*)*** %5, align 8, !invariant.group !6 40 %7 = getelementptr inbounds i64 (%0*)*, i64 (%0*)** %6, i64 6 41 %8 = load i64 (%0*)*, i64 (%0*)** %7, align 8, !invariant.load !6 42 %9 = tail call i64 %8(%0* %1) #1 43 %10 = getelementptr inbounds %1, %1* %2, i64 0, i32 0, i32 0, i32 0, i32 0 44 %11 = load i8*, i8** %10, align 8 45 store i8 0, i8* %11, align 1 46 br i1 undef, label %12, label %31 47 48; <label>:12: ; preds = %4 49 %13 = bitcast %0* %1 to i64 (%0*, i8*, i64)*** 50 br label %14 51 52; <label>:14: ; preds = %30, %12 53 %15 = load i64 (%0*, i8*, i64)**, i64 (%0*, i8*, i64)*** %13, align 8, !invariant.group !6 54 %16 = getelementptr inbounds i64 (%0*, i8*, i64)*, i64 (%0*, i8*, i64)** %15, i64 22 55 %17 = load i64 (%0*, i8*, i64)*, i64 (%0*, i8*, i64)** %16, align 8, !invariant.load !6 56 %18 = call i64 %17(%0* nonnull %1, i8* null, i64 0) #1 57 br i1 undef, label %30, label %19 58 59; <label>:19: ; preds = %14 60 br i1 undef, label %20, label %23 61 62; <label>:20: ; preds = %19 63 br label %21 64 65; <label>:21: ; preds = %20 66 br label %22 67 68; <label>:22: ; preds = %21 69 br label %30 70 71; <label>:23: ; preds = %19 72 br label %24 73 74; <label>:24: ; preds = %23 75 br label %25 76 77; <label>:25: ; preds = %24 78 br label %26 79 80; <label>:26: ; preds = %25 81 br i1 undef, label %27, label %28 82 83; <label>:27: ; preds = %26 84 br label %30 85 86; <label>:28: ; preds = %26 87 br label %29 88 89; <label>:29: ; preds = %28 90 br label %30 91 92; <label>:30: ; preds = %29, %27, %22, %14 93 br i1 undef, label %14, label %31 94 95; <label>:31: ; preds = %30, %4 96 ret void 97} 98 99attributes #0 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 100attributes #1 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+popcnt,+sse,+sse2,+sse3,+sse4.1,+sse4.2,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 101 102!llvm.linker.options = !{} 103!llvm.module.flags = !{!0, !1, !3, !4, !5} 104 105!0 = !{i32 1, !"StrictVTablePointers", i32 1} 106!1 = !{i32 3, !"StrictVTablePointersRequirement", !2} 107!2 = !{!"StrictVTablePointers", i32 1} 108!3 = !{i32 1, !"wchar_size", i32 4} 109!4 = !{i32 7, !"PIC Level", i32 2} 110!5 = !{i32 7, !"PIE Level", i32 2} 111!6 = !{} 112