This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][LLVM] Take the alignment attribute into account during inlining.
ClosedPublic

Authored by definelicht on Mar 28 2023, 6:55 AM.

Details

Summary

This is a subset of the full LLVM functionality to detect whether
realignment is necessary, conservatively copying byval arguments
whenever we cannot prove that the alignment requirement is met.

Diff Detail

Event Timeline

definelicht created this revision.Mar 28 2023, 6:55 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
definelicht requested review of this revision.Mar 28 2023, 6:55 AM
gysit added inline comments.Mar 28 2023, 7:39 AM
mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
121

nit: drop braces.

166–167

Can we factor this logic in a function and then call it twice. Once right after computing isReadOnly if the code actually writes and we anyways need to copy, and once after checking the alignment?

Factored out the initialization of the byval argument.

definelicht marked 2 inline comments as done.Mar 28 2023, 8:37 AM
gysit accepted this revision.Mar 28 2023, 9:25 AM

LGTM modulo nit comments.

mlir/lib/Dialect/LLVMIR/IR/LLVMInlining.cpp
110

We can use a cast since we already know the value is not defined by an operation. That may also make the control flow a bit easier.

333

nit: Should the type be spelled out here and blow?

This revision is now accepted and ready to land.Mar 28 2023, 9:25 AM

Address review comments, and early return in getAlignmentOf.

definelicht marked 2 inline comments as done.Mar 29 2023, 12:59 AM
This revision was landed with ongoing or failed builds.Mar 29 2023, 3:23 AM
This revision was automatically updated to reflect the committed changes.