This is an archive of the discontinued LLVM Phabricator instance.

[flang] Update intrinsic types to unlimited polymorphic form
ClosedPublic

Authored by clementval on Feb 14 2023, 2:36 AM.

Details

Summary

This patch updates the code added in D143888 to avoid
overwriting some part of the types when updating it
for unlimited polymorphic types.

Diff Detail

Event Timeline

clementval created this revision.Feb 14 2023, 2:36 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 14 2023, 2:37 AM
clementval requested review of this revision.Feb 14 2023, 2:37 AM
jeanPerier added inline comments.Feb 14 2023, 5:27 AM
flang/unittests/Optimizer/FIRTypesTest.cpp
150

The unit test seems to fail somewhere in a dyn_cast.

clementval added inline comments.Feb 14 2023, 5:47 AM
flang/unittests/Optimizer/FIRTypesTest.cpp
150

I'll try to reproduce this on my machine.

Switch from TypeRange to SmallVector<mlir::Type>

All builds and tests correctly for me using GCC 9.3.0. But you should fix Jean's problem before updating.

flang/include/flang/Optimizer/Dialect/FIRType.h
347

"intrinsic type" should read "intrinsic types"

353

This function seems to call itself recursively. Given that, what's the effect of the "inline" declaration?

All builds and tests correctly for me using GCC 9.3.0. But you should fix Jean's problem before updating.

Test is passing now.

PeteSteinfeld accepted this revision.Feb 14 2023, 11:40 AM

In that case, ship it!

This revision is now accepted and ready to land.Feb 14 2023, 11:40 AM
jeanPerier accepted this revision.Feb 15 2023, 1:12 AM

LGTM

flang/include/flang/Optimizer/Dialect/FIRType.h
353

In C++, 'the meaning of the keyword inline for functions came to mean "multiple definitions are permitted" rather than "inlining is preferred"' (quote from [1]).

The keyword "inline" allows one to define a (non-member) function in a header that may be included in several compilation unit (it would otherwise be an error since there would be multiple definition). Hence it is required here.

It is actually not a guarantee that the compiler will inline the function at the call sites, but only a strong hint to try. So there is no issue using it on recursive functions: the C++ compiler won't blindly inline it again and again until it blows.

See [1] for a better explanation.

[1] https://en.cppreference.com/w/cpp/language/inline

clementval marked 4 inline comments as done.Feb 15 2023, 1:21 AM