This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Fixed length-one assignment.
ClosedPublic

Authored by vzakhari on Apr 27 2023, 2:27 PM.

Details

Summary

Assignment from a character dummy argument to a length-one character
variable resulted in illegal fir.convert:

%0 = fir.load %unboxed_dummy : !fir.ref<!fir.char<1,?>>
%1 = fir.convert %0 : (!fir.char<1,?>) -> !fir.char<1>
fir.store %1 to %local : !fir.ref<!fir.char<1>>

This change fixes the length-one assignment code to use proper casts.

For character dummy arguments with constant length we will now also
type cast the unboxed reference to the character type with constant length
during the lowering:

fir.convert %x : (!fir.ref<!fir.char<1,?>>) -> !fir.ref<!fir.char<1,8>>

I also adjusted the length-one assignment recognition so that in case
of same-length assignment we recognize length-one from either LHS or RHS
data types.

Diff Detail

Event Timeline

vzakhari created this revision.Apr 27 2023, 2:27 PM
vzakhari requested review of this revision.Apr 27 2023, 2:27 PM

Thanks a lot for this double fix, and the lit test fallout! Looks great.

jeanPerier accepted this revision.Apr 28 2023, 6:55 AM
This revision is now accepted and ready to land.Apr 28 2023, 6:55 AM
This revision was landed with ongoing or failed builds.Apr 28 2023, 9:06 AM
This revision was automatically updated to reflect the committed changes.