This is an archive of the discontinued LLVM Phabricator instance.

[fir] Add IfBuilder and utility functions
ClosedPublic

Authored by clementval on Oct 14 2021, 5:20 AM.

Details

Summary

In order to reduct the size of D111337. The IfBuilder and the two
utility functions genIsNotNull and genIsNull have been extracted in
a separate patch with dedicated unittests.

This patch is part of the upstreaming effort from fir-dev branch.

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

Diff Detail

Event Timeline

clementval created this revision.Oct 14 2021, 5:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 5:20 AM
clementval requested review of this revision.Oct 14 2021, 5:20 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 14 2021, 5:20 AM
Leporacanthicus accepted this revision.Oct 14 2021, 6:52 AM
Leporacanthicus added a subscriber: Leporacanthicus.

Looks OK to me, but please don't merge until someone else also approves.

This revision is now accepted and ready to land.Oct 14 2021, 6:52 AM

Looks OK to me, but please don't merge until someone else also approves.

Sure. Thanks for the review.

Thank you @clementval , the tests make it so much easier to review!

flang/include/flang/Optimizer/Builder/FIRBuilder.h
43–47

IMO this is a bit fragile. I appreciate that we won't be able to use llvm::DataLayout for a while, but I fear that we will forget to update this once we can. Maybe we should leave something like static_assert(sizeof(void*) <= 8) here? For the sake of well-being of our future selves.

67

Perhaps I'm missing something here.

flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
17

Use override in C++11 to make sure you spelled it correctly.

https://github.com/google/googletest/blob/master/docs/primer.md

Not a blocker.

28

Does this have to be a pointer? If yes, then with e.g. unique_ptr you wouldn't have to call delete. Not a blocker for me.

mehdi_amini added inline comments.Oct 14 2021, 10:44 PM
flang/include/flang/Optimizer/Builder/FIRBuilder.h
43–47

What will this static assert caught? Building the compiler on a platform that has pointers larger than 8 bytes? The check should be about the target and not the host though.

Now there should be a solution for this in MLIR, I'm wondering why it isn't deployed here (and if this API is the right level for exposing this): https://mlir.llvm.org/docs/DataLayout/

I'd say that at least this API will make it easier to find the places to update in the codebase compared to use directly getI64Type everywhere...

flang/unittests/Optimizer/Builder/FIRBuilderTest.cpp
28

I'd rather see a unique_ptr as well here.

clementval marked 4 inline comments as done.

Address most of review comments

clementval added inline comments.Oct 15 2021, 12:45 AM
flang/include/flang/Optimizer/Builder/FIRBuilder.h
43–47

The code is probably older than the introduction of the API you mention. I'll check with other whether we can use this in replacement.
As a side note, there is a lot of code to be upstream and probably some of the code is not up to date with the latest MLIR advancement and best practices. We try to update that as we go.

This revision was automatically updated to reflect the committed changes.