23 lines · plain
1// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s2 3// This test checks that we generate a select statement in cases where we're4// mapping a pointer, to select a size of 0 when the pointer is null and5// select the size of the mapped type when it is not null. Preventing a runtime6// mapping error in cases where we legally map null data to device.7 8module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-amd-amdhsa"]} {9 llvm.func @test_select_gen(%arg0: !llvm.ptr, %arg1: !llvm.ptr) {10 %0 = omp.map.info var_ptr(%arg0 : !llvm.ptr, i32) map_clauses(tofrom) capture(ByRef) var_ptr_ptr(%arg1 : !llvm.ptr) -> !llvm.ptr11 %1 = omp.map.info var_ptr(%arg0 : !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>) map_clauses(to) capture(ByRef) members(%0 : [0] : !llvm.ptr) -> !llvm.ptr12 omp.target map_entries(%0 -> %arg2, %1 -> %arg3 : !llvm.ptr, !llvm.ptr) {13 omp.terminator14 }15 llvm.return16 }17}18 19// CHECK: {{.*}}test_select_gen({{.*}}, ptr %[[ARG1:.*]]) {{.*}}20// CHECK: %[[LOAD_ARG1:.*]] = load ptr, ptr %[[ARG1]], align 821// CHECK: %[[ICMP_ARG1:.*]] = icmp eq ptr %[[LOAD_ARG1]], null22// CHECK: %[[SEL_ARG1:.*]] = select i1 %[[ICMP_ARG1]], i64 0, i64 423