This is an archive of the discontinued LLVM Phabricator instance.

[flang] Add the Mangler module to flang lowering
ClosedPublic

Authored by schweitz on Jun 12 2020, 1:59 PM.

Details

Summary

This module converts symbols from the front-end into unique names used in by the optimizer.

This diff is the latest in a series of diffs to upstream the middle part of flang to llvm-project.

Diff Detail

Event Timeline

schweitz created this revision.Jun 12 2020, 1:59 PM
Herald added a project: Restricted Project. · View Herald Transcript

Will it make sense to add LIT tests(program-units-fir-mangling.f90 in fir-dev) for InternalNames.h with this patch also if any for Mangler.h?
Looks like it was missed in https://reviews.llvm.org/D78838

Agree with @sameeranjoshi. But it would probably require some Bridge code. If @sameeranjoshi can land the unit test patch, maybe we can have some unit tests.

>> But it would probably require some Bridge code. If @sameeranjoshi can land the unit test patch, maybe we can have some unit tests.

@isuruf had a comment[1], if he's ok with it I am ready to merge it.
Or the other way round if it's a blocker I can merge the code and later fix @isuruf issue in separate PR.

[1]https://reviews.llvm.org/D80377#2091308

Right, it will take a functional bridge and test driver to run end-to-end tests. Neither has been upstreamed at this point, so it is a bit premature to start adding end-to-end tests.

Unit tests on internal naming don't have that dependency. But they do have a dependency on the fixes included in this patch.

If @sameeranjoshi can land the unit test patch, maybe we can have some unit tests.

It's merged now.

Unit tests on internal naming don't have that dependency. But they do have a dependency on the fixes included in this patch.

I don't think they have dependency, the tests are updated.

IIRC, first the bugs were found using tests and later changes were made to code in fir-dev.
Here's one[1] such I recall

[1]https://github.com/flang-compiler/f18-llvm-project/pull/98/commits/0d0a47020f233f5ea7c10ffb6cd24fb6b9da7b46

schweitz added a comment.EditedJun 16 2020, 7:35 AM

Unit tests on internal naming don't have that dependency. But they do have a dependency on the fixes included in this patch.

I don't think they have dependency, the tests are updated.

IIRC, first the bugs were found using tests and later changes were made to code in fir-dev.
Here's one[1] such I recall

[1]https://github.com/flang-compiler/f18-llvm-project/pull/98/commits/0d0a47020f233f5ea7c10ffb6cd24fb6b9da7b46

If the unit test does NOT depend on the correct behavior of the code it is testing, then the unit test needs more work by definition.

The point of this diff is to upstream code from fir-dev.

jeanPerier accepted this revision.Jun 16 2020, 7:45 AM

LGTM, unit test can always be added later when the framework is ready.

This revision is now accepted and ready to land.Jun 16 2020, 7:45 AM
schweitz updated this revision to Diff 271108.EditedJun 16 2020, 8:35 AM

Rebase and update with the functional unittest.

sameeranjoshi accepted this revision.Jun 16 2020, 12:58 PM

Rebase and update with the functional unittest.

LGTM.
Thanks for adding test.

flang/lib/Lower/Mangler.cpp
58

nit s/proc/procedure/

flang/include/flang/Lower/Mangler.h
2

Nit: generally is like include/flang/Lower/Manger.h

flang/lib/Lower/Mangler.cpp
2

Nit: Usually the path is also there. lib/Lower/Mangler.cpp

67

Is the uniquer modified inside this function?

schweitz marked 2 inline comments as done.Jun 16 2020, 3:19 PM
schweitz added inline comments.
flang/lib/Lower/Mangler.cpp
2

Lower uses a lot of the MLIR/LLVM conventions since it is "close to" MLIR.

67

It's passed around a bit like an MLIRContext. The reference just means it can't be a null pointer. Again, lower follows the MLIR conventions, here with respect to const.

https://mlir.llvm.org/docs/Rationale/UsageOfConst/

This revision was automatically updated to reflect the committed changes.