This is an archive of the discontinued LLVM Phabricator instance.

[flang][hlfir] Codegen for hlfir.get_length.
ClosedPublic

Authored by vzakhari on Jul 5 2023, 8:00 PM.

Details

Summary

Lower hlfir.get_length into the char length inquiry of the bufferized
entity. In some cases the codegen will fail with
hlfir.associate of hlfir.expr with more than one use - this will be fixed
separately (after D154521).

Depends on D154560

Diff Detail

Event Timeline

vzakhari created this revision.Jul 5 2023, 8:00 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 5 2023, 8:00 PM
vzakhari updated this revision to Diff 537576.Jul 5 2023, 9:10 PM

clang-format

jeanPerier accepted this revision.Jul 6 2023, 12:03 AM

Thanks

flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
336–337

I think using hlfir::genCharLength(loc, builder, base) may give "better" results in the sense that it will not look inside the fir.boxchar/fir.box to get the length if it can find it on the bufferized base hlfir.declare.

Given base was placed in a buffer and is not an hlfir.expr, this helper cannot generate an hlfir.get_length again.

This revision is now accepted and ready to land.Jul 6 2023, 12:03 AM
tblah accepted this revision.Jul 6 2023, 2:35 AM

LGTM with Jean's comment

vzakhari added inline comments.Jul 6 2023, 8:12 AM
flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
336–337

Thanks! I will change it.

vzakhari updated this revision to Diff 537791.Jul 6 2023, 10:51 AM

Made use of hlfir::genCharLength.

This revision was automatically updated to reflect the committed changes.