xref: /llvm-project/llvm/test/Transforms/InstCombine/struct-assign-tbaa-2.ll (revision 462cb3cd6cecd0511ecaf0e3ebcaba455ece587d)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
2; RUN: opt -passes=instcombine -S < %s | FileCheck %s
3
4target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
5
6declare void @llvm.memcpy.p0.p0.i64(ptr nocapture, ptr nocapture, i64, i1) nounwind
7
8%struct.T = type { %struct.Wrapper, %struct.Wrapper }
9%struct.Wrapper = type { i16 }
10
11define void @test1(ptr %a1, ptr %a2) {
12; CHECK-LABEL: @test1(
13; CHECK-NEXT:  entry:
14; CHECK-NEXT:    [[B:%.*]] = getelementptr inbounds nuw i8, ptr [[A2:%.*]], i64 2
15; CHECK-NEXT:    [[TMP0:%.*]] = load i16, ptr [[A2]], align 2, !tbaa [[TBAA0:![0-9]+]]
16; CHECK-NEXT:    store i16 [[TMP0]], ptr [[A1:%.*]], align 2, !tbaa [[TBAA0]]
17; CHECK-NEXT:    [[B2:%.*]] = getelementptr inbounds nuw i8, ptr [[A1]], i64 2
18; CHECK-NEXT:    [[TMP1:%.*]] = load i16, ptr [[B]], align 2, !tbaa [[TBAA6:![0-9]+]]
19; CHECK-NEXT:    store i16 [[TMP1]], ptr [[B2]], align 2, !tbaa [[TBAA6]]
20; CHECK-NEXT:    ret void
21;
22entry:
23  %b = getelementptr inbounds i8, ptr %a2, i64 2
24  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %a1, ptr align 2 %a2, i64 2, i1 false), !tbaa !0, !tbaa.struct !6
25  %b2 = getelementptr inbounds %struct.T, ptr %a1, i32 0, i32 1
26  call void @llvm.memcpy.p0.p0.i64(ptr align 2 %b2, ptr align 2 %b, i64 2, i1 false), !tbaa !8, !tbaa.struct !6
27  ret void
28}
29
30!0 = !{!1, !4, i64 0, i64 2}
31!1 = !{!2, i64 4, !"_ZTS1T", !4, i64 0, i64 2, !4, i64 2, i64 2}
32!2 = !{!3, i64 1, !"omnipotent char"}
33!3 = !{!"Simple C++ TBAA"}
34!4 = !{!2, i64 2, !"_ZTS7Wrapper", !5, i64 0, i64 2}
35!5 = !{!2, i64 2, !"short"}
36!6 = !{i64 0, i64 2, !7}
37!7 = !{!5, !5, i64 0, i64 2}
38!8 = !{!1, !4, i64 2, i64 2}
39
40;.
41; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
42;.
43; CHECK: [[TBAA0]] = !{[[META1:![0-9]+]], [[META4:![0-9]+]], i64 0, i64 2}
44; CHECK: [[META1]] = !{[[META2:![0-9]+]], i64 4, !"_ZTS1T", [[META4]], i64 0, i64 2, [[META4]], i64 2, i64 2}
45; CHECK: [[META2]] = !{[[META3:![0-9]+]], i64 1, !"omnipotent char"}
46; CHECK: [[META3]] = !{!"Simple C++ TBAA"}
47; CHECK: [[META4]] = !{[[META2]], i64 2, !"_ZTS7Wrapper", [[META5:![0-9]+]], i64 0, i64 2}
48; CHECK: [[META5]] = !{[[META2]], i64 2, !"short"}
49; CHECK: [[TBAA6]] = !{[[META1]], [[META4]], i64 2, i64 2}
50;.
51