This is an archive of the discontinued LLVM Phabricator instance.

[flang] fix optional pointer TARGET argument lowering in ASSOCIATED
ClosedPublic

Authored by jeanPerier on Sep 19 2022, 3:59 AM.

Details

Summary

The TARGET argument of ASSOCIATED has a special lowering to deal with
POINTER and ALLOCATABLE optional actual arguments because they may be
dynamically absent. The previous code was doing a ternary
(mlir::SelectOp) to deal with this case, but generated invalid
code for the unused argument (loading a nullptr fir.ref<fir.box>). This
was not detected until D133779 was merged and modified how fir.load are
lowered to LLVM for fir.box types.

Replace the select by a proper if to prevent the fir.load from being
reachable in context where it should not.

Diff Detail

Event Timeline

jeanPerier created this revision.Sep 19 2022, 3:59 AM
jeanPerier requested review of this revision.Sep 19 2022, 3:59 AM
This revision is now accepted and ready to land.Sep 19 2022, 6:50 AM
PeteSteinfeld accepted this revision.Sep 19 2022, 7:26 AM

All builds and tests correctly and looks good.

Thanks for fixing this so quickly!