From e77fc0dd76ab2aade6fed2358dbc603c0c80d20c Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Thu, 23 Feb 2023 17:28:54 +0100 Subject: [PATCH] [flang] Relax the check for polymorphic pointer in storage_size intrinsic The runtime check was a too strong as the standard says. > If it is polymorphic it shall not be an undefined pointer. The check was checking if the pointer was associated. Remove the check as other compilers do. Depends on D144643 Reviewed By: PeteSteinfeld Differential Revision: https://reviews.llvm.org/D144644 --- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 3 --- flang/test/Lower/Intrinsics/storage_size.f90 | 8 -------- 2 files changed, 11 deletions(-) diff --git a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp index 926aea53e20f..5148938eca79 100644 --- a/flang/lib/Optimizer/Builder/IntrinsicCall.cpp +++ b/flang/lib/Optimizer/Builder/IntrinsicCall.cpp @@ -4899,9 +4899,6 @@ IntrinsicLibrary::genStorageSize(mlir::Type resultType, fir::isPointerType(boxTy) ? "unlimited polymorphic disassociated POINTER in STORAGE_SIZE" : "unlimited polymorphic unallocated ALLOCATABLE in STORAGE_SIZE"; - } else if (fir::isPolymorphicType(boxTy) && fir::isPointerType(boxTy)) { - needRuntimeCheck = true; - errorMsg = "polymorphic disassociated POINTER in STORAGE_SIZE"; } const fir::MutableBoxValue *mutBox = args[0].getBoxOf(); if (needRuntimeCheck && mutBox) { diff --git a/flang/test/Lower/Intrinsics/storage_size.f90 b/flang/test/Lower/Intrinsics/storage_size.f90 index 6cc883ebf4da..06bc8eec2e5d 100644 --- a/flang/test/Lower/Intrinsics/storage_size.f90 +++ b/flang/test/Lower/Intrinsics/storage_size.f90 @@ -72,14 +72,6 @@ contains ! CHECK-SAME: %[[P:.*]]: !fir.ref>>> {fir.bindc_name = "p"}) -> i32 { ! CHECK: %[[SIZE:.*]] = fir.alloca i32 {bindc_name = "size", uniq_name = "_QMstorage_size_testFpolymorphic_pointerEsize"} ! CHECK: %[[LOAD_P:.*]] = fir.load %[[P]] : !fir.ref>>> -! CHECK: %[[P_ADDR:.*]] = fir.box_addr %[[LOAD_P]] : (!fir.class>>) -> !fir.ptr> -! CHECK: %[[P_ADDR_I64:.*]] = fir.convert %[[P_ADDR]] : (!fir.ptr>) -> i64 -! CHECK: %[[C0:.*]] = arith.constant 0 : i64 -! CHECK: %[[IS_NULL_ADDR:.*]] = arith.cmpi eq, %[[P_ADDR_I64]], %[[C0]] : i64 -! CHECK: fir.if %[[IS_NULL_ADDR]] { -! CHECK: %{{.*}} = fir.call @_FortranAReportFatalUserError(%{{.*}}, %{{.*}}, %{{.*}}) {{.*}} : (!fir.ref, !fir.ref, i32) -> none -! CHECK: } -! CHECK: %[[LOAD_P:.*]] = fir.load %[[P]] : !fir.ref>>> ! CHECK: %[[ELE_SIZE:.*]] = fir.box_elesize %[[LOAD_P]] : (!fir.class>>) -> i32 ! CHECK: %[[C8:.*]] = arith.constant 8 : i32 ! CHECK: %[[BITS:.*]] = arith.muli %[[ELE_SIZE]], %[[C8]] : i32 -- 2.11.4.GIT