This is an archive of the discontinued LLVM Phabricator instance.

[flang][CodeGen] Transform `IsPresentOpConversion` and `AbsentOpConversion`
ClosedPublic

Authored by awarzynski on Nov 8 2021, 5:28 AM.

Details

Summary

This patch extends the FIRToLLVMLowering pass in Flang by adding
hooks to transform fir.is_present and fir.absent to the LLVM dialect
of MLIR.

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

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

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

Diff Detail

Event Timeline

awarzynski created this revision.Nov 8 2021, 5:28 AM
awarzynski requested review of this revision.Nov 8 2021, 5:28 AM
clementval added inline comments.Nov 8 2021, 5:50 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
25

Why is this suddenly needed? We have been creating LLVM ops until now without this extra include. Also it feels weird to not use quotes here.

218

Fine if you want to update auto usage from fir-dev here. getLoc() is most of the time used with auto even in MLIR code base.

Don't forget to sync back in fir-dev.

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

Can you split the test here //----- and update the comment accordingly? They is clearly two different ops tested here.

awarzynski updated this revision to Diff 385522.Nov 8 2021, 9:04 AM
awarzynski marked an inline comment as done.

Rebased on top of main, added tests for fir.box, addressed comments from @clementval

flang/lib/Optimizer/CodeGen/CodeGen.cpp
25

It's not, sorry. Must have crept in when I was working on some other thing.

218

Don't forget to sync back in fir-dev.

I've made similar changes elsewhere as well. Let me send them to fie-dev as one bigger patch (to minimise the traffic). Shall I do it once all of the conversions in this file are complete?

This revision is now accepted and ready to land.Nov 8 2021, 9:05 AM
clementval added inline comments.Nov 8 2021, 9:07 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
218

If they are just typos/auto or stuff like that you can submit them later. If it's smth like rewriting a block of code or refactoring it's good if we don't loos track of the change.

schweitz added inline comments.Nov 9 2021, 7:05 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
210

Should we be writing doxygen comments?

1414

Different version of clang-format?

awarzynski marked an inline comment as done.Nov 10 2021, 12:04 AM
awarzynski added inline comments.
flang/lib/Optimizer/CodeGen/CodeGen.cpp
210

Let me fix that!

1414

Not necessarily. IIRC, clang-format has no hard rules for where to break lines. But I couldn't find a definitive answer.

I use clang-format-13. Pre-commit CI seems happy. Shall we leave it like this?

awarzynski marked an inline comment as done.

Rebase and make sure that comments are in Doxygen format

clementval accepted this revision.Nov 10 2021, 12:21 AM

LGTM

flang/lib/Optimizer/CodeGen/CodeGen.cpp
1414

Looks fine now.

schweitz added inline comments.Nov 11 2021, 8:36 AM
flang/lib/Optimizer/CodeGen/CodeGen.cpp
1414

Looks like the random whitespace changes disappeared. Good.

Andrzej, we've found that using even slightly different builds of clang-format cause mysterious whitespace changes. It's not about any rule. It just happens.

schweitz accepted this revision.Nov 11 2021, 8:37 AM

I use the version of clang-format from llvm release 12, which is the latest released version.

I use the version of clang-format from llvm release 12, which is the latest released version.

https://llvm.org/
"4 October 2021: LLVM 13.0.0 is now available for download! "

Time for an update :)

flang/lib/Optimizer/CodeGen/CodeGen.cpp
1414

different builds of clang-format cause mysterious whitespace changes.

I wish that my sight allowed me to spot such discrepancies! :)