1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt -aa-pipeline=basic-aa -passes=gvn -S < %s | FileCheck %s 3 4; This test catches an issue in MemoryDependenceAnalysis caching mechanism in presense of TBAA. 5define i64 @foo(i64 addrspace(1)** %arg, i1 %arg1, i1 %arg2, i1 %arg3, i32 %arg4) { 6; CHECK-LABEL: @foo( 7; CHECK-NEXT: bb: 8; CHECK-NEXT: [[TMP:%.*]] = load atomic i64 addrspace(1)*, i64 addrspace(1)** [[ARG:%.*]] unordered, align 8 9; CHECK-NEXT: [[TMP5:%.*]] = getelementptr inbounds i64, i64 addrspace(1)* [[TMP]], i64 8 10; CHECK-NEXT: store atomic i64 0, i64 addrspace(1)* [[TMP5]] unordered, align 8 11; CHECK-NEXT: br label [[BB6:%.*]] 12; CHECK: bb6: 13; CHECK-NEXT: [[TMP7:%.*]] = phi i64 [ 0, [[BB:%.*]] ], [ [[TMP22:%.*]], [[BB19:%.*]] ] 14; CHECK-NEXT: br i1 [[ARG1:%.*]], label [[BB19]], label [[BB8:%.*]] 15; CHECK: bb8: 16; CHECK-NEXT: [[TMP9:%.*]] = load atomic i64 addrspace(1)*, i64 addrspace(1)** [[ARG]] unordered, align 8 17; CHECK-NEXT: br i1 [[ARG2:%.*]], label [[BB11:%.*]], label [[BB10:%.*]] 18; CHECK: bb10: 19; CHECK-NEXT: br label [[BB15:%.*]] 20; CHECK: bb11: 21; CHECK-NEXT: br i1 [[ARG3:%.*]], label [[BB12:%.*]], label [[BB18:%.*]] 22; CHECK: bb12: 23; CHECK-NEXT: [[TMP14:%.*]] = getelementptr inbounds i64, i64 addrspace(1)* [[TMP9]], i64 8 24; CHECK-NEXT: store atomic i64 1, i64 addrspace(1)* [[TMP14]] unordered, align 8 25; CHECK-NEXT: ret i64 0 26; CHECK: bb15: 27; CHECK-NEXT: [[TMP16:%.*]] = phi i64 addrspace(1)* [ [[TMP9]], [[BB10]] ], [ [[TMP27:%.*]], [[BB26:%.*]] ] 28; CHECK-NEXT: [[TMP17:%.*]] = phi i64 [ [[TMP7]], [[BB10]] ], [ 0, [[BB26]] ] 29; CHECK-NEXT: switch i32 [[ARG4:%.*]], label [[BB19]] [ 30; CHECK-NEXT: i32 0, label [[BB26]] 31; CHECK-NEXT: i32 1, label [[BB23:%.*]] 32; CHECK-NEXT: ] 33; CHECK: bb18: 34; CHECK-NEXT: br label [[BB19]] 35; CHECK: bb19: 36; CHECK-NEXT: [[TMP20:%.*]] = phi i64 addrspace(1)* [ [[TMP16]], [[BB15]] ], [ inttoptr (i64 1 to i64 addrspace(1)*), [[BB6]] ], [ [[TMP9]], [[BB18]] ] 37; CHECK-NEXT: [[TMP21:%.*]] = getelementptr inbounds i64, i64 addrspace(1)* [[TMP20]], i64 8 38; CHECK-NEXT: [[TMP22]] = load atomic i64, i64 addrspace(1)* [[TMP21]] unordered, align 8, !tbaa !0 39; CHECK-NEXT: br label [[BB6]] 40; CHECK: bb23: 41; CHECK-NEXT: [[TMP24:%.*]] = getelementptr inbounds i64, i64 addrspace(1)* [[TMP16]], i64 8 42; CHECK-NEXT: [[TMP25:%.*]] = load atomic i64, i64 addrspace(1)* [[TMP24]] unordered, align 8 43; CHECK-NEXT: call void @baz(i64 [[TMP25]]) #0 44; CHECK-NEXT: ret i64 0 45; CHECK: bb26: 46; CHECK-NEXT: call void @bar() 47; CHECK-NEXT: [[TMP27]] = load atomic i64 addrspace(1)*, i64 addrspace(1)** [[ARG]] unordered, align 8 48; CHECK-NEXT: [[TMP28:%.*]] = getelementptr inbounds i64, i64 addrspace(1)* [[TMP27]], i64 8 49; CHECK-NEXT: [[TMP29:%.*]] = load atomic i64, i64 addrspace(1)* [[TMP28]] unordered, align 8 50; CHECK-NEXT: [[TMP30:%.*]] = getelementptr inbounds i64, i64 addrspace(1)* [[TMP27]], i64 40 51; CHECK-NEXT: store atomic i64 [[TMP29]], i64 addrspace(1)* [[TMP30]] unordered, align 4 52; CHECK-NEXT: br label [[BB15]] 53; 54bb: 55 %tmp = load atomic i64 addrspace(1)*, i64 addrspace(1)** %arg unordered, align 8 56 %tmp5 = getelementptr inbounds i64, i64 addrspace(1)* %tmp, i64 8 57 store atomic i64 0, i64 addrspace(1)* %tmp5 unordered, align 8 58 br label %bb6 59 60bb6: ; preds = %bb19, %bb 61 %tmp7 = phi i64 [ 0, %bb ], [ %tmp22, %bb19 ] 62 %tmp111 = inttoptr i64 1 to i64 addrspace(1)* 63 br i1 %arg1, label %bb19, label %bb8 64 65bb8: ; preds = %bb6 66 %tmp9 = load atomic i64 addrspace(1)*, i64 addrspace(1)** %arg unordered, align 8 67 br i1 %arg2, label %bb11, label %bb10 68 69bb10: ; preds = %bb8 70 br label %bb15 71 72bb11: ; preds = %bb8 73 br i1 %arg3, label %bb12, label %bb18 74 75bb12: ; preds = %bb11 76 %tmp13 = phi i64 addrspace(1)* [ %tmp9, %bb11 ] 77 %tmp14 = getelementptr inbounds i64, i64 addrspace(1)* %tmp13, i64 8 78 store atomic i64 1, i64 addrspace(1)* %tmp14 unordered, align 8 79 ret i64 0 80 81bb15: ; preds = %bb26, %bb10 82 %tmp16 = phi i64 addrspace(1)* [ %tmp9, %bb10 ], [ %tmp27, %bb26 ] 83 %tmp17 = phi i64 [ %tmp7, %bb10 ], [ 0, %bb26 ] 84 switch i32 %arg4, label %bb19 [ 85 i32 0, label %bb26 86 i32 1, label %bb23 87 ] 88 89bb18: ; preds = %bb11 90 br label %bb19 91 92bb19: ; preds = %bb18, %bb15, %bb6 93 %tmp20 = phi i64 addrspace(1)* [ %tmp16, %bb15 ], [ %tmp111, %bb6 ], [ %tmp9, %bb18 ] 94 %tmp21 = getelementptr inbounds i64, i64 addrspace(1)* %tmp20, i64 8 95 %tmp22 = load atomic i64, i64 addrspace(1)* %tmp21 unordered, align 8, !tbaa !0 96 br label %bb6 97 98bb23: ; preds = %bb15 99 %tmp24 = getelementptr inbounds i64, i64 addrspace(1)* %tmp16, i64 8 100 %tmp25 = load atomic i64, i64 addrspace(1)* %tmp24 unordered, align 8 101 call void @baz(i64 %tmp25) #0 102 ret i64 0 103 104bb26: ; preds = %bb15 105 call void @bar() 106 %tmp27 = load atomic i64 addrspace(1)*, i64 addrspace(1)** %arg unordered, align 8 107 %tmp28 = getelementptr inbounds i64, i64 addrspace(1)* %tmp27, i64 8 108 %tmp29 = load atomic i64, i64 addrspace(1)* %tmp28 unordered, align 8 109 %tmp30 = getelementptr inbounds i64, i64 addrspace(1)* %tmp27, i64 40 110 store atomic i64 %tmp29, i64 addrspace(1)* %tmp30 unordered, align 4 111 br label %bb15 112} 113 114declare void @bar() 115 116; Function Attrs: inaccessiblememonly readonly 117declare void @baz(i64) #0 118 119attributes #0 = { inaccessiblememonly readonly } 120 121!0 = !{!1, !2, i64 8} 122!1 = !{!"Name", !2, i64 8} 123!2 = !{!"tbaa_local_fields", !3, i64 0} 124!3 = !{!"tbaa-access-type"} 125 126