Debian Codegraph @

clang/test/CodeGen/union-tbaa1.c

raw
1 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 5
2 // RUN: %clang_cc1 %s -triple hexagon-unknown-elf -O2 -emit-llvm -o - | FileCheck %s
3
4 typedef union __attribute__((aligned(4))) {
5 unsigned short uh[2];
6 unsigned uw;
7 } vect32;
8
9 void bar(vect32 p[][2]);
10
11 // CHECK-LABEL: define dso_local void @fred(
12 // CHECK-SAME: i32 noundef [[NUM:%.*]], ptr noundef writeonly captures(none) initializes((0, 8)) [[VEC:%.*]], ptr noundef readonly captures(none) [[INDEX:%.*]], ptr noundef readonly captures(none) [[ARR:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
13 // CHECK-NEXT: [[ENTRY:.*:]]
14 // CHECK-NEXT: [[TMP:%.*]] = alloca [4 x [2 x %union.vect32]], align 8
15 // CHECK-NEXT: call void @llvm.lifetime.start.p0(ptr nonnull [[TMP]]) #[[ATTR3:[0-9]+]]
16 // CHECK-NEXT: [[TMP0:%.*]] = load i32, ptr [[INDEX]], align 4, !tbaa [[TBAA2:![0-9]+]]
17 // CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds [2 x i32], ptr [[ARR]], i32 [[TMP0]]
18 // CHECK-NEXT: [[TMP1:%.*]] = load i32, ptr [[ARRAYIDX]], align 4, !tbaa [[TBAA2]]
19 // CHECK-NEXT: [[MUL:%.*]] = mul i32 [[TMP1]], [[NUM]]
20 // CHECK-NEXT: [[ARRAYIDX2:%.*]] = getelementptr inbounds [2 x %union.vect32], ptr [[TMP]], i32 [[TMP0]]
21 // CHECK-NEXT: store i32 [[MUL]], ptr [[ARRAYIDX2]], align 8, !tbaa [[TBAA6:![0-9]+]]
22 // CHECK-NEXT: [[ARRAYIDX5:%.*]] = getelementptr inbounds nuw i8, ptr [[ARRAYIDX]], i32 4
23 // CHECK-NEXT: [[TMP2:%.*]] = load i32, ptr [[ARRAYIDX5]], align 4, !tbaa [[TBAA2]]
24 // CHECK-NEXT: [[MUL6:%.*]] = mul i32 [[TMP2]], [[NUM]]
25 // CHECK-NEXT: [[ARRAYIDX8:%.*]] = getelementptr inbounds nuw i8, ptr [[ARRAYIDX2]], i32 4
26 // CHECK-NEXT: store i32 [[MUL6]], ptr [[ARRAYIDX8]], align 4, !tbaa [[TBAA6]]
27 // CHECK-NEXT: [[TMP3:%.*]] = lshr i32 [[MUL]], 16
28 // CHECK-NEXT: store i32 [[TMP3]], ptr [[VEC]], align 4, !tbaa [[TBAA2]]
29 // CHECK-NEXT: [[TMP4:%.*]] = load i32, ptr [[INDEX]], align 4, !tbaa [[TBAA2]]
30 // CHECK-NEXT: [[ARRAYIDX13:%.*]] = getelementptr inbounds [2 x %union.vect32], ptr [[TMP]], i32 [[TMP4]]
31 // CHECK-NEXT: [[ARRAYIDX15:%.*]] = getelementptr inbounds nuw i8, ptr [[ARRAYIDX13]], i32 6
32 // CHECK-NEXT: [[TMP5:%.*]] = load i16, ptr [[ARRAYIDX15]], align 2, !tbaa [[TBAA6]]
33 // CHECK-NEXT: [[CONV16:%.*]] = zext i16 [[TMP5]] to i32
34 // CHECK-NEXT: [[ARRAYIDX17:%.*]] = getelementptr inbounds nuw i8, ptr [[VEC]], i32 4
35 // CHECK-NEXT: store i32 [[CONV16]], ptr [[ARRAYIDX17]], align 4, !tbaa [[TBAA2]]
36 // CHECK-NEXT: call void @bar(ptr noundef nonnull [[TMP]]) #[[ATTR3]]
37 // CHECK-NEXT: call void @llvm.lifetime.end.p0(ptr nonnull [[TMP]]) #[[ATTR3]]
38 // CHECK-NEXT: ret void
39 //
40 void fred(unsigned Num, int Vec[2], int *Index, int Arr[4][2]) {
41 vect32 Tmp[4][2];
42 Tmp[*Index][0].uw = Arr[*Index][0] * Num;
43 Tmp[*Index][1].uw = Arr[*Index][1] * Num;
44 Vec[0] = Tmp[*Index][0].uh[1];
45 Vec[1] = Tmp[*Index][1].uh[1];
46 bar(Tmp);
47 }
48
49 //.
50 // CHECK: [[TBAA2]] = !{[[META3:![0-9]+]], [[META3]], i64 0}
51 // CHECK: [[META3]] = !{!"int", [[META4:![0-9]+]], i64 0}
52 // CHECK: [[META4]] = !{!"omnipotent char", [[META5:![0-9]+]], i64 0}
53 // CHECK: [[META5]] = !{!"Simple C/C++ TBAA"}
54 // CHECK: [[TBAA6]] = !{[[META4]], [[META4]], i64 0}
55 //.