[PATCH] D124728: Allow pointer types for atomicrmw xchg

Takafumi Arakaki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 30 22:44:48 PDT 2022


tkf created this revision.
tkf added a reviewer: vtjnash.
Herald added subscribers: jdoerfert, kerbowa, pengfei, hiraditya, jvesely.
Herald added a project: All.
tkf requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This adds support for pointer types for atomic xchg and let us write instructions such as `atomicrmw xchg i64** %0, i64* %1 seq_cst`. This is similar to the patch for allowing atomicrmw xchg on floating point types https://reviews.llvm.org/D52416.

Motivation: In Julia, we keep GC-managed objects as pointer in LLVM IR so that our compiler pass can insert GC-related instructions to track these objects. Thus, we cannot easily use bitcast (like clang does) to use `atomicrmw xchg` for swapping a pointer value (https://github.com/JuliaLang/julia/issues/44932). Adding direct support for xchg of pointer in LLVM would let us use native instructions in a wider class of programs. I think it may be beneficial to other languages with GC using approaches similar to Julia.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124728

Files:
  llvm/docs/LangRef.rst
  llvm/lib/AsmParser/LLParser.cpp
  llvm/lib/CodeGen/AtomicExpandPass.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/test/Assembler/invalid-atomicrmw-xchg-must-be-integer-fp-or-pointer-type.ll
  llvm/test/Assembler/invalid-atomicrmw-xchg-must-be-integer-or-fp-type.ll
  llvm/test/Bitcode/compatibility.ll
  llvm/test/CodeGen/AArch64/atomicrmw-xchg-pointer.ll
  llvm/test/CodeGen/AMDGPU/flat_atomics_i64.ll
  llvm/test/CodeGen/AMDGPU/global_atomics_i64.ll
  llvm/test/CodeGen/AMDGPU/local-atomics64.ll
  llvm/test/CodeGen/X86/atomic64.ll
  llvm/test/Transforms/AtomicExpand/AArch64/expand-atomicrmw-xchg-pointer.ll
  llvm/test/Transforms/AtomicExpand/X86/expand-atomic-xchg-pointer.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124728.426266.patch
Type: text/x-patch
Size: 15742 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220501/19bcc7f6/attachment.bin>


More information about the llvm-commits mailing list