This is an archive of the discontinued LLVM Phabricator instance.

[flang][CodeGen] Transform `fir.{store|load}` to `llvm.{store|load}`
ClosedPublic

Authored by awarzynski on Nov 3 2021, 1:49 AM.

Details

Summary

This patch extends the FIRToLLVMLowering pass in Flang by adding a
hook to transform fir.store/fir.load to llvm.store/fir.load,
respectively.

This is part of the upstreaming effort from the fir-dev branch in [1].

[1] https://github.com/flang-compiler/f18-llvm-project

Patch originally written by:
Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>
Co-authored-by: Jean Perier <jperier@nvidia.com>

Diff Detail

Event Timeline

awarzynski created this revision.Nov 3 2021, 1:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2021, 1:49 AM
Herald added a subscriber: mehdi_amini. · View Herald Transcript
awarzynski requested review of this revision.Nov 3 2021, 1:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 3 2021, 1:49 AM

I wanted to add a test for fir.ref<fir.box>, but that does not work yet (it works fine on fir-dev). I wasn't sure why, so my comment in "flang/test/Fir/convert-to-llvm.fir" is a bit generic. Any pointers? Thanks!

I wanted to add a test for fir.ref<fir.box>, but that does not work yet (it works fine on fir-dev). I wasn't sure why, so my comment in "flang/test/Fir/convert-to-llvm.fir" is a bit generic. Any pointers? Thanks!

Not all of the type conversions have been upstreamed. I usually upstream the one I need with the op conversion I'm upstreaming.

flang/lib/Optimizer/CodeGen/TypeConverter.h

Test is failing on the pre-check.

clementval added inline comments.Nov 3 2021, 2:00 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
326

Can you address this formatting issue?

I wanted to add a test for fir.ref<fir.box>, but that does not work yet (it works fine on fir-dev). I wasn't sure why, so my comment in "flang/test/Fir/convert-to-llvm.fir" is a bit generic. Any pointers? Thanks!

Not all of the type conversions have been upstreamed. I usually upstream the one I need with the op conversion I'm upstreaming.

flang/lib/Optimizer/CodeGen/TypeConverter.h

So does @awarzynski have to bring in the convertBoxType function?

flang/test/Fir/convert-to-llvm.fir
179

missed the parameters.
Would it be good to match the parameters and the store operands?

200

missed the parameters.
Would it be good to match the parameters and the load operands?

I wanted to add a test for fir.ref<fir.box>, but that does not work yet (it works fine on fir-dev). I wasn't sure why, so my comment in "flang/test/Fir/convert-to-llvm.fir" is a bit generic. Any pointers? Thanks!

Not all of the type conversions have been upstreamed. I usually upstream the one I need with the op conversion I'm upstreaming.

flang/lib/Optimizer/CodeGen/TypeConverter.h

So does @awarzynski have to bring in the convertBoxType function?

Or it will come with D112961 if anyone review it.

clementval added inline comments.Nov 3 2021, 9:06 AM
flang/test/Fir/convert-to-llvm.fir
179

+1

mehdi_amini added inline comments.Nov 3 2021, 10:43 AM
flang/test/Fir/convert-to-llvm.fir
182

In general: please use CHECK-LABEL for delimiting the test (that helps FileCheck, in particular the print in case of failure is much friendlier) and minimize the checks, while capturing what matters (here I suspect types and argument flowing in the right place it what you're checking (I think that's also what Kiran hinted at):

// CHECK-LABEL: llvm.func @test_store
// CHECK-SAME: %[[ARG0:.*]]: <type here>, %[[ARG1:.*]]: <type here>
// CHECK:    llvm.store %[[ARG0]], .....

So does @awarzynski have to bring in the convertBoxType function?

Or it will come with D112961 if anyone review it.

Tl;Dr Perhaps we should just add more tests later?

Longer version - I've tried applying D112961, but that didn't work. It depends on 2 other patches, so perhaps I wasn't applying it correctly? I've just tried my usual arc patch D112961. Regardless, if we prefer to have all tests added in one patch then I can set the dependencies accordingly and re-visit arc patch.

awarzynski added inline comments.Nov 3 2021, 10:49 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
326

Sorry about that :/

flang/test/Fir/convert-to-llvm.fir
182

haha, as I was in the process of changing that :-)

Address PR comments (refine tests, fix formatting)

awarzynski marked 4 inline comments as done.Nov 3 2021, 11:05 AM
clementval accepted this revision.Nov 8 2021, 6:40 AM
This revision is now accepted and ready to land.Nov 8 2021, 6:40 AM
awarzynski updated this revision to Diff 385537.Nov 8 2021, 9:43 AM

Rebased, addes tests for fir.box. This has already been accepted by @clementval, so I will merge this if there are no new comments.

clementval accepted this revision.Nov 8 2021, 9:46 AM

Still LGTM