This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Split alloc-like op LLVM lowerings into base and separate derived classes.
ClosedPublic

Authored by csigg on Oct 1 2020, 12:56 PM.

Details

Summary

The previous code did the lowering to alloca, malloc, and aligned_malloc
in a single class with different code paths that are somewhat difficult to
follow.

This change moves the common code to a base class and has a separte
derived class per lowering target that contains the specifics.

Diff Detail

Event Timeline

csigg created this revision.Oct 1 2020, 12:56 PM
Herald added a project: Restricted Project. · View Herald Transcript
csigg requested review of this revision.Oct 1 2020, 12:56 PM
ftynse accepted this revision.Oct 5 2020, 2:04 AM

Nice, thanks!

mlir/include/mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h
478

Nit: this assumes sizes are dynamic but strides are static, which isn't always the case (I'd actually expect all-static and all-dynamic). This deserves a comment indicating how to relax the staticity requirement in the future.

mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
1012

Nit: do we need explicit this here?

1780

Nit: missing closing quote after alignment.

1800

Nit: Value is a value-type, no need to have const references to it.

1933

Nit: the comment above says that we allocated (alignment - 1) more bytes, but we seem to forget the -1 here.

This revision is now accepted and ready to land.Oct 5 2020, 2:04 AM
csigg marked 3 inline comments as done.Oct 5 2020, 8:07 AM
csigg added inline comments.
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
1933

This was an existing discrepancy between the comment and the code. I fixed the comment and added a note that we could reduce the amount of over-allocation.

csigg retitled this revision from Split alloc-like op LLVM lowerings into base and separate derived classes. to [mlir] Split alloc-like op LLVM lowerings into base and separate derived classes..Oct 5 2020, 8:10 AM
csigg updated this revision to Diff 296188.Oct 5 2020, 8:15 AM

Comments, rebase.

This revision was landed with ongoing or failed builds.Oct 5 2020, 8:36 AM
This revision was automatically updated to reflect the committed changes.
jpienaar added inline comments.
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
2030
mehdi_amini added inline comments.Oct 5 2020, 10:33 AM
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
2030