This is an archive of the discontinued LLVM Phabricator instance.

[flang] optionally lower scalar and explicit shape with fir.declare
ClosedPublic

Authored by jeanPerier on Oct 19 2022, 5:36 AM.

Details

Summary

Lower scalar and explicit shape arrays to fir.declare under the -hlfir option.
Update the SymMap so that it can hold fir::FortranVariableInterface.

The plan is to go towards a SymMap that only contains fir::FortranVariableInterface
once current expression lowering can be replaced. This should make the SymMap lighter
than it is today (SymBox/ExtendedValue are above 256 bytes).

Assumed shape, allocatable and pointer are left TODOs for now. Anything with a
specification expression that is not a constant expression will only be able to
be lowered when the HLFIR expression lowering skeleton is added.

Diff Detail

Event Timeline

jeanPerier created this revision.Oct 19 2022, 5:36 AM
Herald added a project: Restricted Project. · View Herald Transcript
jeanPerier requested review of this revision.Oct 19 2022, 5:36 AM
This revision is now accepted and ready to land.Oct 19 2022, 5:43 AM

clang-format flang/include/flang/Lower/SymbolMap.h

PeteSteinfeld requested changes to this revision.Oct 19 2022, 7:46 AM

I have some questions ...

flang/include/flang/Lower/SymbolMap.h
351–352

This function is not used anywhere. Will future changes will make use of it?

flang/lib/Lower/ConvertVariable.cpp
1341–1364

It doesn't look like this code will ever be reached.

1342

Did you mean for this blank line to be here?

flang/lib/Lower/SymbolMap.cpp
103–106

Should these be returning llvm::None?

113–116

Why does one of these terminate in a newline and the other doesn't?

This revision now requires changes to proceed.Oct 19 2022, 7:46 AM
jeanPerier marked an inline comment as done.

Remove unused and unreachable code. Remove extra blank line.

flang/include/flang/Lower/SymbolMap.h
351–352

Soon, but you are right, I'll just remove it until it is used.

flang/lib/Lower/ConvertVariable.cpp
1341–1364

Indeed, removed.

flang/lib/Lower/SymbolMap.cpp
103–106

I think it is equivalent. I removed this code anyway for now. I'll try to remember adding it back with llvm::None :).

113–116

Why does one of these terminate in a newline and the other doesn't?

It is a bit confusing, but os << *symBox; calls Fortran::lower::operator<<(llvm::raw_ostream &os, const Fortran::lower::SymbolBox &symBox) define just above that adds new lines on its own. The SymBox part should anyway be removed when the transition is over. So in both cases a new line is added.

PeteSteinfeld accepted this revision.Oct 19 2022, 2:46 PM

Thanks for making these changes!

All builds and tests correctly and looks good.

This revision is now accepted and ready to land.Oct 19 2022, 2:46 PM