// RUN: fir-opt %s --split-input-file --pass-pipeline="builtin.module(func.func(test-acc-pointer-like-interface{test-mode=copy}))" 2>&1 | FileCheck %s // The tests here use a synthetic hlfir.declare in order to ensure that the hlfir dialect is // loaded. This is required because the pass used is part of OpenACC test passes outside of // flang and the APIs being test may generate hlfir even when it does not appear. func.func @test_copy_scalar() { %src = fir.alloca f32 {test.src_ptr} %dest = fir.alloca f32 {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca f32 {test.src_ptr} to destination: %{{.*}} = fir.alloca f32 {test.dest_ptr} // CHECK: Generated: %{{.*}} = fir.load %{{.*}} : !fir.ref // CHECK: Generated: fir.store %{{.*}} to %{{.*}} : !fir.ref return } // ----- func.func @test_copy_static_array() { %src = fir.alloca !fir.array<10x20xf32> {test.src_ptr} %dest = fir.alloca !fir.array<10x20xf32> {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca !fir.array<10x20xf32> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.array<10x20xf32> {test.dest_ptr} // CHECK: Generated: hlfir.assign %{{.*}} to %{{.*}} : !fir.ref>, !fir.ref> return } // ----- func.func @test_copy_derived_type() { %src = fir.alloca !fir.type<_QTt{i:i32}> {test.src_ptr} %dest = fir.alloca !fir.type<_QTt{i:i32}> {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca !fir.type<_QTt{i:i32}> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.type<_QTt{i:i32}> {test.dest_ptr} // CHECK: Generated: hlfir.assign %{{.*}} to %{{.*}} : !fir.ref>, !fir.ref> return } // ----- func.func @test_copy_heap_scalar() { %src = fir.allocmem f32 {test.src_ptr} %dest = fir.allocmem f32 {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Successfully generated copy from source: %{{.*}} = fir.allocmem f32 {test.src_ptr} to destination: %{{.*}} = fir.allocmem f32 {test.dest_ptr} // CHECK: Generated: %{{.*}} = fir.load %{{.*}} : !fir.heap // CHECK: Generated: fir.store %{{.*}} to %{{.*}} : !fir.heap return } // ----- func.func @test_copy_static_char() { %src = fir.alloca !fir.char<1,10> {test.src_ptr} %dest = fir.alloca !fir.char<1,10> {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Successfully generated copy from source: %{{.*}} = fir.alloca !fir.char<1,10> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.char<1,10> {test.dest_ptr} // CHECK: Generated: hlfir.assign %{{.*}} to %{{.*}} : !fir.ref>, !fir.ref> return } // ----- func.func @test_copy_mismatched_types_fails() { %src = fir.alloca f32 {test.src_ptr} %dest = fir.alloca f64 {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Failed to generate copy from source: %{{.*}} = fir.alloca f32 {test.src_ptr} to destination: %{{.*}} = fir.alloca f64 {test.dest_ptr} return } // ----- func.func @test_copy_mismatched_shapes_fails() { %src = fir.alloca !fir.array<10xf32> {test.src_ptr} %dest = fir.alloca !fir.array<20xf32> {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Failed to generate copy from source: %{{.*}} = fir.alloca !fir.array<10xf32> {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.array<20xf32> {test.dest_ptr} return } // ----- func.func @test_copy_dynamic_array_fails(%arg0: !fir.ref>, %arg1: !fir.ref>) { %src = fir.convert %arg0 {test.src_ptr} : (!fir.ref>) -> !fir.llvm_ptr> %dest = fir.convert %arg1 {test.dest_ptr} : (!fir.ref>) -> !fir.llvm_ptr> %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Failed to generate copy from source: %{{.*}} = fir.convert %{{.*}} {test.src_ptr} : (!fir.ref>) -> !fir.llvm_ptr> to destination: %{{.*}} = fir.convert %{{.*}} {test.dest_ptr} : (!fir.ref>) -> !fir.llvm_ptr> return } // ----- func.func @test_copy_unlimited_polymorphic_fails() { %src = fir.alloca !fir.class {test.src_ptr} %dest = fir.alloca !fir.class {test.dest_ptr} %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Failed to generate copy from source: %{{.*}} = fir.alloca !fir.class {test.src_ptr} to destination: %{{.*}} = fir.alloca !fir.class {test.dest_ptr} return } // ----- func.func @test_copy_dynamic_char_fails(%arg0: !fir.ref>, %arg1: !fir.ref>) { %src = fir.convert %arg0 {test.src_ptr} : (!fir.ref>) -> !fir.llvm_ptr> %dest = fir.convert %arg1 {test.dest_ptr} : (!fir.ref>) -> !fir.llvm_ptr> %var = fir.alloca f32 %0:2 = hlfir.declare %var {uniq_name = "load_hlfir"} : (!fir.ref) -> (!fir.ref, !fir.ref) // CHECK: Failed to generate copy from source: %{{.*}} = fir.convert %{{.*}} {test.src_ptr} : (!fir.ref>) -> !fir.llvm_ptr> to destination: %{{.*}} = fir.convert %{{.*}} {test.dest_ptr} : (!fir.ref>) -> !fir.llvm_ptr> return }