This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Add thread-local address intrinsic
ClosedPublic

Authored by LukasSommerTu on May 26 2023, 6:58 AM.

Details

Summary

Add the llvm.threadlocal.address intrinsic to the LLVM dialect.

Signed-off-by: Lukas Sommer <lukas.sommer@codeplay.com>

Diff Detail

Event Timeline

LukasSommerTu created this revision.May 26 2023, 6:58 AM
Herald added a reviewer: dcaballe. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
LukasSommerTu requested review of this revision.May 26 2023, 6:58 AM
zero9178 added inline comments.May 26 2023, 7:18 AM
mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
316

What's the behaviour of the op if the pointer operand is null or not a thread local? The reference sadly does not state anything https://llvm.org/docs/LangRef.html#llvm-threadlocal-address-intrinsic but guessing by your use of nonnull below it is undefined for null?

If undefined, it should be marked NoMemoryEffects rather than Pure since it can't always be speculatively executed for all inputs.

@zero9178 Thanks for your review! I addressed your comment inline.

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
316

The LLVM definition of the intrinsic has the property IntrSpeculatable, which is described as:

// This property indicates that the intrinsic is safe to speculate.

Given that, I assume it can be executed speculatively and it is OK to mark this as Pure. In LLVM itself, there's test-cases with and without nonnull.

zero9178 accepted this revision.May 29 2023, 8:55 AM

LGTM

mlir/include/mlir/Dialect/LLVMIR/LLVMIntrinsicOps.td
315

Tiny nit

316

I see, thank you for double checking!

This revision is now accepted and ready to land.May 29 2023, 8:55 AM

Add "Op" suffix to intrinsic.

LukasSommerTu marked 3 inline comments as done.May 29 2023, 10:18 AM

@zero9178 Thanks for the review, I addressed the last nit. If you're happy with the update, could you please commit this for me, I don't have commit access.

gysit accepted this revision.May 29 2023, 11:13 PM

LGTM!

This revision was automatically updated to reflect the committed changes.