Debian Codegraph @

clang/test/CIR/CodeGen/pack-indexing.cpp

raw
1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++2c -fclangir -emit-cir %s -o %t.cir
2 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
3 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++2c -fclangir -emit-llvm %s -o %t.ll
4 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
5 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++2c -emit-llvm %s -o %t.ll
6 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
7
8 int pack_indexing(auto... p) { return p...[0]; }
9
10 // CIR: %[[P_0:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["p", init]
11 // CIR: %[[P_1:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["p", init]
12 // CIR: %[[P_2:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["p", init]
13 // CIR: %[[RET_VAL:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
14 // CIR: %[[RESULT:.*]] = cir.load{{.*}} %[[P_0]] : !cir.ptr<!s32i>, !s32i
15 // CIR: cir.store %[[RESULT]], %[[RET_VAL]] : !s32i, !cir.ptr<!s32i>
16 // CIR: %[[TMP:.*]] = cir.load %[[RET_VAL]] : !cir.ptr<!s32i>, !s32i
17 // CIR: cir.return %[[TMP]] : !s32i
18
19 // LLVM: %[[P_0:.*]] = alloca i32, i64 1, align 4
20 // LLVM: %[[P_1:.*]] = alloca i32, i64 1, align 4
21 // LLVM: %[[P_2:.*]] = alloca i32, i64 1, align 4
22 // LLVM: %[[RET_VAL:.*]] = alloca i32, i64 1, align 4
23 // LLVM: %[[RESULT:.*]] = load i32, ptr %[[P_0]], align 4
24 // LLVM: store i32 %[[RESULT]], ptr %[[RET_VAL]], align 4
25 // LLVM: %[[TMP:.*]] = load i32, ptr %[[RET_VAL]], align 4
26 // LLVM: ret i32 %[[TMP]]
27
28 // OGCG-DAG: %[[P_0:.*]] = alloca i32, align 4
29 // OGCG-DAG: %[[P_1:.*]] = alloca i32, align 4
30 // OGCG-DAG: %[[P_2:.*]] = alloca i32, align 4
31 // OGCG-DAG: %[[RESULT:.*]] = load i32, ptr %[[P_0]], align 4
32 // OGCG-DAG-NEXT: ret i32 %[[RESULT]]
33
34 int foo() { return pack_indexing(1, 2, 3); }
35
36 // CIR: %[[RET_VAL:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
37 // CIR: %[[RESULT:.*]] = cir.call @_Z13pack_indexingIJiiiEEiDpT_({{.*}}, {{.*}}, {{.*}}) : (!s32i, !s32i, !s32i) -> !s32i
38 // CIR: cir.store %[[RESULT]], %[[RET_VAL]] : !s32i, !cir.ptr<!s32i>
39 // CIR: %[[TMP:.*]] = cir.load %[[RET_VAL]] : !cir.ptr<!s32i>, !s32i
40 // CIR: cir.return %[[TMP]] : !s32i
41
42 // LLVM: %[[RET_VAL:.*]] = alloca i32, i64 1, align 4
43 // LLVM: %[[RESULT:.*]] = call i32 @_Z13pack_indexingIJiiiEEiDpT_(i32 1, i32 2, i32 3)
44 // LLVM: store i32 %[[RESULT]], ptr %[[RET_VAL]], align 4
45 // LLVM: %[[TMP:.*]] = load i32, ptr %[[RET_VAL]], align 4
46 // LLVM: ret i32 %[[TMP]]
47
48 // OGCG-DAG: %[[CALL:.*]] = call noundef i32 @_Z13pack_indexingIJiiiEEiDpT_(i32 noundef 1, i32 noundef 2, i32 noundef 3)
49 // OGCG-DAG-NEXT: ret i32 %[[RESULT]]