This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Simplify std.alloc lowering to LLVM.
ClosedPublic

Authored by csigg on Nov 16 2020, 8:32 AM.

Details

Summary

std.alloc only supports memrefs with identity layout, which means we can simplify the lowering to LLVM and compute strides only from (static and dynamic) sizes.

Diff Detail

Event Timeline

csigg created this revision.Nov 16 2020, 8:32 AM
csigg requested review of this revision.Nov 16 2020, 8:32 AM
ftynse accepted this revision.Nov 17 2020, 5:45 AM

Nice!

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

Nit: could we also document that it emits instructions necessary to compute the strides and the total size?

mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
1115

Cool trick!

1139–1140

This seems like it would properly support cases with vectors due to padding an alignment, e.g., memref<4 x vector<3 x f32>>, right?

This revision is now accepted and ready to land.Nov 17 2020, 5:45 AM
csigg updated this revision to Diff 305816.Nov 17 2020, 9:02 AM
csigg marked an inline comment as done.

Extend documentation.

csigg marked an inline comment as done.Nov 17 2020, 9:02 AM
csigg added inline comments.
mlir/lib/Conversion/StandardToLLVM/StandardToLLVM.cpp
1115

It's a shame that clang-tidy doesn't format the goes-to operator correctly.

1139–1140

Yes, see for example the %t4 example here: https://llvm.org/docs/LangRef.html#getelementptr-instruction

This revision was automatically updated to reflect the committed changes.