This is an archive of the discontinued LLVM Phabricator instance.

[MLIR][LLVM] Copy byval attributes during inlining.
ClosedPublic

Authored by definelicht on Mar 22 2023, 2:59 AM.

Details

Summary

Support inlining of function calls with the byval attribute on function
arguments by copying the pointee into a newly alloca'ed pointer at the
callsite before inlining.

The alignment attribute is not yet taken into account.

Diff Detail

Event Timeline

definelicht created this revision.Mar 22 2023, 2:59 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 22 2023, 2:59 AM
ftynse accepted this revision.Mar 22 2023, 3:21 AM
ftynse added inline comments.
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
2961–2963

Please expand auto unless the type is obvious from context (e.g., there's a cast on the RHS) or impossible to spell (e.g., lambdas).

2968

Nit: consider early return here.

This revision is now accepted and ready to land.Mar 22 2023, 3:21 AM
gysit added inline comments.Mar 22 2023, 3:34 AM
mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp
2967

Should this also be a check for write-only accesses?

memoryEffects &&
memoryEffects.getArgMem() != ModRefInfo::ModRef &&
memoryEffects.getArgMem() != ModRefInfo::Mod

Or does ModRef also match pure write accesses?

Addressed comments by moving byval handling into a separate function so we can do early returns without breaking the control flow of other potential function argument attribute handling.

Add missing check for write-only.

gysit accepted this revision.Mar 22 2023, 5:11 AM

Thanks LGTM!

Get data layout from callable, omit call argument, and remove auto.

This revision was landed with ongoing or failed builds.Mar 22 2023, 7:39 AM
This revision was automatically updated to reflect the committed changes.