This is an archive of the discontinued LLVM Phabricator instance.

[mlir][LLVMIR] Add lifetime start and end marker instrinsics
ClosedPublic

Authored by Mogball on Sep 14 2022, 8:38 AM.

Details

Summary

This patch adds the llvm.intr.lifetime.start and llvm.intr.lifetime.end
intrinsics which are used to indicate to LLVM the lifetimes of allocated
memory.

These ops have the requirement that the first argument (the size) be an
"immediate argument". I added an OpTrait to check this, but it is
possible that an approach like GEPArg would work too.

Diff Detail

Event Timeline

Mogball created this revision.Sep 14 2022, 8:38 AM
Mogball requested review of this revision.Sep 14 2022, 8:38 AM
dcaballe accepted this revision.Sep 14 2022, 9:25 AM

Thanks, @Mogball! LGTM. Please wait for somebody else to chime in.

mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
126 ↗(On Diff #460118)

Nice! I wonder if we already have more LLVM ops with this requirement. Are we just not checking that invariant for them?

This revision is now accepted and ready to land.Sep 14 2022, 9:25 AM
rriddle requested changes to this revision.Sep 14 2022, 9:41 AM
rriddle added inline comments.
mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
105–126 ↗(On Diff #460118)

This doesn't seem like a good constraint for MLIR. There are plenty of things that could easily break this (e.g. block merging). Why not just have the size be an Attribute?

This revision now requires changes to proceed.Sep 14 2022, 9:41 AM
Mogball updated this revision to Diff 460187.Sep 14 2022, 12:44 PM

Switched to an attribute for imm arg instead of an op trait

PTAL :)

Mogball marked 2 inline comments as done.Sep 14 2022, 12:45 PM
Mogball added inline comments.
mlir/include/mlir/Dialect/LLVMIR/LLVMDialect.h
126 ↗(On Diff #460118)

It's possible. I've switch to an attribute like river suggested. PTAL @dcaballe

Mogball marked an inline comment as done.Sep 14 2022, 12:45 PM
Mogball updated this revision to Diff 460188.Sep 14 2022, 12:46 PM

remove extra newline

rriddle accepted this revision.Sep 14 2022, 1:11 PM

Nice!

This revision is now accepted and ready to land.Sep 14 2022, 1:11 PM