This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][LLVM] Realign allocas to avoid dynamic realignment in inliner.
ClosedPublic

Authored by definelicht on Apr 17 2023, 11:44 AM.

Details

Summary

When the natural stack alignment is set and is larger than or equal to
the target alignment required by a read-only byval argument defined by
an alloca, avoid the copy by just realigning the alloca to the target
alignment.

This also includes a bugfix for passing a null DataLayoutInterface to
the DataLayout constructor when no parent op defines
DataLayoutInterface, and will now pass ModuleOp instead in this case.

Diff Detail

Event Timeline

definelicht created this revision.Apr 17 2023, 11:44 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
definelicht requested review of this revision.Apr 17 2023, 11:44 AM

Remove assert, since this seems to often not be satisfied.

Use existing closest function instead of reinventing it.

Add fix to accessing scope when it's null in DataLayout.

gysit accepted this revision.Apr 17 2023, 11:16 PM

LGTM

mlir/test/Dialect/LLVMIR/inlining.mlir
528

nit: maybe rename declared_func to use_ptr to make sure it is obvious we are not testing that declarations are not inlined here. Using a load may also be a good option to avoid DCE.

This revision is now accepted and ready to land.Apr 17 2023, 11:16 PM
definelicht marked an inline comment as done.

Implement review comment and extend documentation a bit.

Optimistically assume that natural stack alignment is not exceeded if it is not specified. Reorganize the code to avoid redundant casts.

gysit accepted this revision.Apr 18 2023, 11:34 AM

Still LGTM!