CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
119 lines
5.3 KiB
C
119 lines
5.3 KiB
C
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o %t.cir
|
|
// RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o %t-cir.ll
|
|
// RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
|
|
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
|
|
// RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s
|
|
|
|
struct Point {
|
|
int x, y;
|
|
};
|
|
|
|
struct Line {
|
|
struct Point start;
|
|
struct Point end;
|
|
};
|
|
|
|
// AggExprEmitter::VisitMemberExpr
|
|
void test_member_in_array(void) {
|
|
struct Line line = {{1, 2}, {3, 4}};
|
|
struct Point arr[1] = {line.start};
|
|
}
|
|
|
|
// CIR-DAG: cir.global "private" constant cir_private @[[LINE_CONST:.*]] = #cir.const_record<{#cir.const_record<{#cir.int<1> : !s32i, #cir.int<2> : !s32i}> : !rec_Point, #cir.const_record<{#cir.int<3> : !s32i, #cir.int<4> : !s32i}> : !rec_Point}> : !rec_Line
|
|
// CIR-DAG: cir.global "private" constant cir_private @[[MATRIX_CONST:.*]] = #cir.const_array<[#cir.const_array<[#cir.int<104> : !s8i, #cir.int<101> : !s8i, #cir.int<108> : !s8i, #cir.int<108> : !s8i, #cir.int<111> : !s8i, #cir.int<0> : !s8i]> : !cir.array<!s8i x 6>, #cir.const_array<[#cir.int<119> : !s8i, #cir.int<111> : !s8i, #cir.int<114> : !s8i, #cir.int<108> : !s8i, #cir.int<100> : !s8i, #cir.int<0> : !s8i]> : !cir.array<!s8i x 6>]>
|
|
|
|
// LLVM-DAG: @[[LINE_CONST:.*]] = private constant %struct.Line { %struct.Point { i32 1, i32 2 }, %struct.Point { i32 3, i32 4 } }
|
|
// LLVM-DAG: @[[MATRIX_CONST:.*]] = private constant [2 x [6 x i8]] {{.*}}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @test_member_in_array
|
|
// CIR: %[[LINE:.*]] = cir.alloca !rec_Line{{.*}}, ["line", init]
|
|
// CIR: %[[ARR:.*]] = cir.alloca !cir.array<!rec_Point x 1>{{.*}}, ["arr", init]
|
|
// CIR: cir.get_global @[[LINE_CONST]]
|
|
// CIR: cir.copy
|
|
// CIR: %[[MEMBER:.*]] = cir.get_member %[[LINE]][0] {name = "start"}
|
|
// CIR: cir.copy
|
|
|
|
// LLVM-LABEL: define{{.*}} @test_member_in_array
|
|
// LLVM: %[[LINE:.*]] = alloca %struct.Line
|
|
// LLVM: %[[ARR:.*]] = alloca [1 x %struct.Point]
|
|
// LLVM: call void @llvm.memcpy{{.*}}(ptr %[[LINE]], ptr @[[LINE_CONST]]
|
|
// LLVM: %[[MEMBER:.*]] = getelementptr{{.*}}%struct.Line{{.*}}%[[LINE]]{{.*}}i32 0, i32 0
|
|
// LLVM: call void @llvm.memcpy
|
|
|
|
// OGCG-LABEL: define{{.*}} @test_member_in_array
|
|
// OGCG: %[[LINE:.*]] = alloca %struct.Line
|
|
// OGCG: %[[ARR:.*]] = alloca [1 x %struct.Point]
|
|
// OGCG: call void @llvm.memcpy{{.*}}(ptr{{.*}} %[[LINE]], ptr{{.*}} @__const.test_member_in_array.line
|
|
// OGCG: %[[MEMBER:.*]] = getelementptr{{.*}}%struct.Line{{.*}}%[[LINE]]{{.*}}i32 0, i32 0
|
|
// OGCG: call void @llvm.memcpy
|
|
|
|
// AggExprEmitter::VisitMemberExpr
|
|
void test_member_arrow_in_array(void) {
|
|
struct Line *line_ptr;
|
|
struct Point arr[1] = {line_ptr->start};
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @test_member_arrow_in_array
|
|
// CIR: %[[PTR:.*]] = cir.alloca !cir.ptr<!rec_Line>{{.*}}, ["line_ptr"]
|
|
// CIR: %[[ARR:.*]] = cir.alloca !cir.array<!rec_Point x 1>{{.*}}, ["arr", init]
|
|
// CIR: %[[LOADED:.*]] = cir.load{{.*}}%[[PTR]]
|
|
// CIR: %[[MEMBER:.*]] = cir.get_member %[[LOADED]][0] {name = "start"}
|
|
// CIR: cir.copy
|
|
|
|
// LLVM-LABEL: define{{.*}} @test_member_arrow_in_array
|
|
// LLVM: %[[PTR:.*]] = alloca ptr
|
|
// LLVM: %[[ARR:.*]] = alloca [1 x %struct.Point]
|
|
// LLVM: %[[LOADED:.*]] = load ptr{{.*}}%[[PTR]]
|
|
// LLVM: %[[MEMBER:.*]] = getelementptr{{.*}}%struct.Line{{.*}}%[[LOADED]]{{.*}}i32 0, i32 0
|
|
// LLVM: call void @llvm.memcpy
|
|
|
|
// OGCG-LABEL: define{{.*}} @test_member_arrow_in_array
|
|
// OGCG: %[[PTR:.*]] = alloca ptr
|
|
// OGCG: %[[ARR:.*]] = alloca [1 x %struct.Point]
|
|
// OGCG: %[[LOADED:.*]] = load ptr{{.*}}%[[PTR]]
|
|
// OGCG: %[[MEMBER:.*]] = getelementptr{{.*}}%struct.Line{{.*}}%[[LOADED]]{{.*}}i32 0, i32 0
|
|
// OGCG: call void @llvm.memcpy
|
|
|
|
// AggExprEmitter::VisitUnaryDeref
|
|
void test_deref_in_array(void) {
|
|
struct Point *ptr;
|
|
struct Point arr[1] = {*ptr};
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @test_deref_in_array
|
|
// CIR: %[[PTR:.*]] = cir.alloca !cir.ptr<!rec_Point>{{.*}}, ["ptr"]
|
|
// CIR: %[[ARR:.*]] = cir.alloca !cir.array<!rec_Point x 1>{{.*}}, ["arr", init]
|
|
// CIR: %[[LOADED:.*]] = cir.load{{.*}}%[[PTR]]
|
|
// CIR: cir.copy
|
|
|
|
// LLVM-LABEL: define{{.*}} @test_deref_in_array
|
|
// LLVM: %[[PTR:.*]] = alloca ptr
|
|
// LLVM: %[[ARR:.*]] = alloca [1 x %struct.Point]
|
|
// LLVM: %[[LOADED:.*]] = load ptr{{.*}}%[[PTR]]
|
|
// LLVM: call void @llvm.memcpy
|
|
|
|
// OGCG-LABEL: define{{.*}} @test_deref_in_array
|
|
// OGCG: %[[PTR:.*]] = alloca ptr
|
|
// OGCG: %[[ARR:.*]] = alloca [1 x %struct.Point]
|
|
// OGCG: %[[LOADED:.*]] = load ptr{{.*}}%[[PTR]]
|
|
// OGCG: call void @llvm.memcpy
|
|
|
|
// AggExprEmitter::VisitStringLiteral
|
|
void test_string_array_in_array(void) {
|
|
char matrix[2][6] = {"hello", "world"};
|
|
}
|
|
|
|
// CIR-LABEL: cir.func{{.*}} @test_string_array_in_array
|
|
// CIR: %[[MATRIX:.*]] = cir.alloca !cir.array<!cir.array<!s8i x 6> x 2>, {{.*}}, ["matrix", init]
|
|
// CIR: %[[CONST:.*]] = cir.get_global @[[MATRIX_CONST]] : !cir.ptr<!cir.array<!cir.array<!s8i x 6> x 2>>
|
|
// CIR: cir.copy %[[CONST]] to %[[MATRIX]]
|
|
|
|
// LLVM-LABEL: define{{.*}} @test_string_array_in_array
|
|
// LLVM: %[[MATRIX:.*]] = alloca [2 x [6 x i8]]
|
|
// LLVM: call void @llvm.memcpy{{.*}}(ptr %[[MATRIX]], ptr @[[MATRIX_CONST]]
|
|
|
|
// OGCG-LABEL: define{{.*}} @test_string_array_in_array
|
|
// OGCG: alloca [2 x [6 x i8]]
|
|
// OGCG: call void @llvm.memcpy{{.*}}@__const.test_string_array_in_array
|