[CodeGen][ARM] Implement atomicrmw as pseudo operations at -O0
authorTomas Matheson <tomas.matheson@arm.com>
Wed, 31 Mar 2021 16:45:45 +0000 (17:45 +0100)
committerTomas Matheson <tomas.matheson@arm.com>
Mon, 3 May 2021 19:25:15 +0000 (20:25 +0100)
commit753185031d939711f8733639a77a6fdc3bdbad22
tree56c3fae758a9059bed6e38782659bfe937df3744
parent9621c1ef56c568ffe2db903af2f61137a4453430
[CodeGen][ARM] Implement atomicrmw as pseudo operations at -O0

atomicrmw instructions are expanded by AtomicExpandPass before register allocation
into cmpxchg loops. Register allocation can insert spills between the exclusive loads
and stores, which invalidates the exclusive monitor and can lead to infinite loops.

To avoid this, reimplement atomicrmw operations as pseudo-instructions and expand them
after register allocation.

Floating point legalisation:
f16 ATOMIC_LOAD_FADD(*f16, f16) is legalised to
f32 ATOMIC_LOAD_FADD(*i16, f32) and then eventually
f32 ATOMIC_LOAD_FADD_16(*i16, f32)

Differential Revision: https://reviews.llvm.org/D101164

Originally submitted as 3338290c187b254ad071f4b9cbf2ddb2623cefc0.
Reverted in c7df6b1223d88dfd15248fbf7b7b83dacad22ae3.
llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h
llvm/lib/Target/ARM/ARMBaseInstrInfo.cpp
llvm/lib/Target/ARM/ARMExpandPseudoInsts.cpp
llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/ARM/ARMInstrInfo.td
llvm/test/CodeGen/ARM/atomicrmw_exclusive_monitor_all.ll [new file with mode: 0644]
llvm/test/Transforms/AtomicExpand/ARM/atomicrmw-fp.ll