[PATCH] IR support for "cmpxchg weak"

Tim Northover t.p.northover at gmail.com
Fri Jun 13 06:09:33 PDT 2014


Hi all,

Given the size & scope of this change, it's definitely worth getting the details checked over as much as possible. The patch here is substantially the same as the one in the RFC thread, but tidied up and with a bit more testing.

This patch is minimal, in the sense that it exposes some interfaces to make "cmpxchg weak" usable, but doesn't actually do anything with them. It comes with a similarly minimal Clang patch that just makes it correctly use the strong cmpxchg again.

I'm expecting 3 following patches, though they'll all be fairly trivial and obvious once this is in place:
+ Use the "weak" in AtomicExpandLoadLinked. This gives us actual benefit from the construct.
+ Use the i1 in X86ISelLowering.cpp. This lets us skip some redundant comparisons.
+ Make clang emit "cmpxchg weak" when appropriate. It's almost all wired up already; just a few extra lines and a bunch of tests.

OK to commit?

Tim.

http://reviews.llvm.org/D4134

Files:
  docs/Atomics.rst
  docs/LangRef.rst
  include/llvm/CodeGen/ISDOpcodes.h
  include/llvm/CodeGen/SelectionDAG.h
  include/llvm/CodeGen/SelectionDAGNodes.h
  include/llvm/IR/Instructions.h
  lib/AsmParser/LLParser.cpp
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/CodeGen/AtomicExpandLoadLinkedPass.cpp
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp
  lib/CodeGen/SelectionDAG/LegalizeTypes.h
  lib/CodeGen/SelectionDAG/SelectionDAG.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  lib/CodeGen/SelectionDAG/SelectionDAGDumper.cpp
  lib/CodeGen/TargetLoweringBase.cpp
  lib/IR/AsmWriter.cpp
  lib/IR/Instruction.cpp
  lib/IR/Instructions.cpp
  lib/Target/CppBackend/CPPBackend.cpp
  lib/Target/X86/X86ISelLowering.cpp
  lib/Transforms/IPO/MergeFunctions.cpp
  lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  lib/Transforms/Scalar/LowerAtomic.cpp
  test/Assembler/atomic.ll
  test/Bitcode/atomic.ll
  test/Bitcode/memInstructions.3.2.ll
  test/Bitcode/weak-cmpxchg-upgrade.ll
  test/Bitcode/weak-cmpxchg-upgrade.ll.bc
  test/CodeGen/AArch64/arm64-atomic-128.ll
  test/CodeGen/AArch64/arm64-atomic.ll
  test/CodeGen/AArch64/atomic-ops.ll
  test/CodeGen/AArch64/cmpxchg-idioms.ll
  test/CodeGen/ARM/atomic-64bit.ll
  test/CodeGen/ARM/atomic-cmp.ll
  test/CodeGen/ARM/atomic-op.ll
  test/CodeGen/ARM/atomic-ops-v8.ll
  test/CodeGen/ARM/cmpxchg-idioms.ll
  test/CodeGen/CPP/atomic.ll
  test/CodeGen/Mips/atomic.ll
  test/CodeGen/Mips/atomicops.ll
  test/CodeGen/PowerPC/Atomics-32.ll
  test/CodeGen/PowerPC/atomic-1.ll
  test/CodeGen/PowerPC/atomic-2.ll
  test/CodeGen/R600/atomic_cmp_swap_local.ll
  test/CodeGen/SPARC/atomics.ll
  test/CodeGen/SystemZ/cmpxchg-01.ll
  test/CodeGen/SystemZ/cmpxchg-02.ll
  test/CodeGen/SystemZ/cmpxchg-03.ll
  test/CodeGen/SystemZ/cmpxchg-04.ll
  test/CodeGen/X86/2010-10-08-cmpxchg8b.ll
  test/CodeGen/X86/Atomics-64.ll
  test/CodeGen/X86/atomic_op.ll
  test/CodeGen/X86/coalescer-remat.ll
  test/Instrumentation/MemorySanitizer/atomics.ll
  test/Transforms/AtomicExpandLoadLinked/ARM/atomic-expansion-v7.ll
  test/Transforms/AtomicExpandLoadLinked/ARM/atomic-expansion-v8.ll
  test/Transforms/LowerAtomic/atomic-swap.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4134.10385.patch
Type: text/x-patch
Size: 98011 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140613/eb9febac/attachment.bin>


More information about the llvm-commits mailing list