c_ptr arguments passed by value need special handling, which was missing
in HLFIR lowering. The lowering has to load the __address component
and pass the loaded value as the actual argument.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
Thanks for working on this TODO!
| flang/lib/Lower/ConvertCall.cpp | ||
|---|---|---|
| 1084 | You cannot assume you will get an hlfir.expr here. This is the case in the example because this a a function result, but I think that with this modified example, a fir.ref<fir.type<cptr....>> would reach this spot: subroutine test(cptr)
use iso_c_binding
interface
subroutine get_expected_f(src) bind(c)
use iso_c_binding
type(c_ptr), value :: src
end subroutine get_expected_f
end interface
type(c_ptr) :: cptr
call get_expected_f(cptr)
endDerived type are not part of the "trivial" definition of fir (fir::isa_trivial), so loadTrivialScalar did not turn it into an hlfir.expr. So you will have to skip the associate/end_associate when value.isValue() is false. | |
| flang/lib/Lower/ConvertCall.cpp | ||
|---|---|---|
| 1084 | Thank you for the example, Jean! I will upload the updated change shortly. | |
You cannot assume you will get an hlfir.expr here. This is the case in the example because this a a function result, but I think that with this modified example, a fir.ref<fir.type<cptr....>> would reach this spot:
subroutine test(cptr) use iso_c_binding interface subroutine get_expected_f(src) bind(c) use iso_c_binding type(c_ptr), value :: src end subroutine get_expected_f end interface type(c_ptr) :: cptr call get_expected_f(cptr) endDerived type are not part of the "trivial" definition of fir (fir::isa_trivial), so loadTrivialScalar did not turn it into an hlfir.expr.
So you will have to skip the associate/end_associate when value.isValue() is false.