mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-17 00:36:34 +00:00
[flang] Use 0 for unknown function pointer result length. (#97035)
This commit is contained in:
parent
2da10959e0
commit
17bd3120ad
@ -89,9 +89,15 @@ fir::ExtendedValue Fortran::lower::convertProcedureDesignator(
|
||||
fir::factory::genMaxWithZero(builder, loc, rawLen);
|
||||
}
|
||||
}
|
||||
// The caller of the function pointer will have to allocate
|
||||
// the function result with the character length specified
|
||||
// by the boxed value. If the result length cannot be
|
||||
// computed statically, set it to zero (we used to use -1,
|
||||
// but this could cause assertions in LLVM after inlining
|
||||
// exposed alloca of size -1).
|
||||
if (!funcPtrResultLength)
|
||||
funcPtrResultLength = builder.createIntegerConstant(
|
||||
loc, builder.getCharacterLengthType(), -1);
|
||||
loc, builder.getCharacterLengthType(), 0);
|
||||
return fir::CharBoxValue{funcPtr, funcPtrResultLength};
|
||||
}
|
||||
return funcPtr;
|
||||
|
@ -128,7 +128,7 @@ use m
|
||||
! CHECK: fir.store %[[VAL_2]] to %[[VAL_0]] : !fir.ref<!fir.boxproc<(!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>>>
|
||||
! CHECK: %[[VAL_3:.*]]:2 = hlfir.declare %[[VAL_0]] {fortran_attrs = #fir.var_attrs<pointer>, uniq_name = "_QFsub4Ep2"} : (!fir.ref<!fir.boxproc<(!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>>>) -> (!fir.ref<!fir.boxproc<(!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>>>, !fir.ref<!fir.boxproc<(!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>>>)
|
||||
! CHECK: %[[VAL_4:.*]] = fir.address_of(@_QPchar_func) : (!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>
|
||||
! CHECK: %[[VAL_12:.*]] = arith.constant -1 : index
|
||||
! CHECK: %[[VAL_12:.*]] = arith.constant 0 : index
|
||||
! CHECK: %[[VAL_5:.*]] = fir.emboxproc %[[VAL_4]] : ((!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>) -> !fir.boxproc<() -> ()>
|
||||
! CHECK: %[[VAL_6:.*]] = fir.convert %[[VAL_12]] : (index) -> i64
|
||||
! CHECK: %[[VAL_7:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
|
||||
@ -375,7 +375,7 @@ end subroutine
|
||||
|
||||
! CHECK-LABEL: fir.global internal @_QFsub1Ep7 : !fir.boxproc<(!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>> {
|
||||
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QPchar_func) : (!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>
|
||||
! CHECK: %[[VAL_11:.*]] = arith.constant -1 : index
|
||||
! CHECK: %[[VAL_11:.*]] = arith.constant 0 : index
|
||||
! CHECK: %[[VAL_1:.*]] = fir.emboxproc %[[VAL_0]] : ((!fir.ref<i32>) -> !fir.box<!fir.ptr<!fir.char<1,?>>>) -> !fir.boxproc<() -> ()>
|
||||
! CHECK: %[[VAL_2:.*]] = fir.convert %[[VAL_11]] : (index) -> i64
|
||||
! CHECK: %[[VAL_3:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
|
||||
|
@ -82,7 +82,7 @@ subroutine cannot_compute_len_yet()
|
||||
end function
|
||||
end interface
|
||||
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QPbar4) : (!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>
|
||||
! CHECK: %[[VAL_1:.*]] = arith.constant -1 : index
|
||||
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : index
|
||||
! CHECK: %[[VAL_2:.*]] = fir.emboxproc %[[VAL_0]] : ((!fir.ref<!fir.char<1,?>>, index, !fir.ref<i32>) -> !fir.boxchar<1>) -> !fir.boxproc<() -> ()>
|
||||
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_1]] : (index) -> i64
|
||||
! CHECK: %[[VAL_4:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
|
||||
@ -97,7 +97,7 @@ subroutine cannot_compute_len_yet_2()
|
||||
character(*) :: bar5
|
||||
external :: bar5
|
||||
! CHECK: %[[VAL_0:.*]] = fir.address_of(@_QPbar5) : (!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>
|
||||
! CHECK: %[[VAL_1:.*]] = arith.constant -1 : index
|
||||
! CHECK: %[[VAL_1:.*]] = arith.constant 0 : index
|
||||
! CHECK: %[[VAL_2:.*]] = fir.emboxproc %[[VAL_0]] : ((!fir.ref<!fir.char<1,?>>, index) -> !fir.boxchar<1>) -> !fir.boxproc<() -> ()>
|
||||
! CHECK: %[[VAL_3:.*]] = fir.convert %[[VAL_1]] : (index) -> i64
|
||||
! CHECK: %[[VAL_4:.*]] = fir.undefined tuple<!fir.boxproc<() -> ()>, i64>
|
||||
|
Loading…
x
Reference in New Issue
Block a user