[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
https://github.com/Ris-Bali updated https://github.com/llvm/llvm-project/pull/71220 >From 0948e11b508e3f978f76a639f27101c8825250c7 Mon Sep 17 00:00:00 2001 From: Rishabh Bali Date: Sun, 14 Jan 2024 22:50:06 +0530 Subject: [PATCH 1/4] Port Atomicexpandpass to new PM --- llvm/include/llvm/CodeGen/AtomicExpandUtils.h | 4 +- llvm/include/llvm/CodeGen/ExpandAtomic.h | 30 .../llvm/CodeGen/MachinePassRegistry.def | 2 +- llvm/include/llvm/CodeGen/Passes.h| 8 +- .../llvm/CodeGen/TargetSubtargetInfo.h| 2 +- llvm/include/llvm/InitializePasses.h | 2 +- llvm/lib/CodeGen/CMakeLists.txt | 2 +- llvm/lib/CodeGen/CodeGen.cpp | 2 +- ...micExpandPass.cpp => ExpandAtomicPass.cpp} | 149 +++--- llvm/lib/CodeGen/TargetSubtargetInfo.cpp | 2 +- llvm/lib/Passes/PassBuilder.cpp | 1 + llvm/lib/Passes/PassRegistry.def | 1 + .../Target/AArch64/AArch64TargetMachine.cpp | 2 +- .../lib/Target/AMDGPU/AMDGPUTargetMachine.cpp | 2 +- llvm/lib/Target/ARC/ARCTargetMachine.cpp | 2 +- llvm/lib/Target/ARM/ARMTargetMachine.cpp | 2 +- llvm/lib/Target/BPF/BPFTargetMachine.cpp | 2 +- llvm/lib/Target/CSKY/CSKYTargetMachine.cpp| 2 +- .../Target/Hexagon/HexagonTargetMachine.cpp | 2 +- llvm/lib/Target/Lanai/LanaiTargetMachine.cpp | 2 +- .../LoongArch/LoongArchTargetMachine.cpp | 2 +- llvm/lib/Target/M68k/M68kTargetMachine.cpp| 2 +- .../lib/Target/MSP430/MSP430TargetMachine.cpp | 2 +- llvm/lib/Target/Mips/MipsTargetMachine.cpp| 2 +- llvm/lib/Target/NVPTX/NVPTXTargetMachine.cpp | 2 +- .../PowerPC/PPCExpandAtomicPseudoInsts.cpp| 2 +- llvm/lib/Target/PowerPC/PPCTargetMachine.cpp | 2 +- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp | 2 +- llvm/lib/Target/Sparc/SparcTargetMachine.cpp | 2 +- .../Target/SystemZ/SystemZTargetMachine.cpp | 2 +- llvm/lib/Target/VE/VETargetMachine.cpp| 2 +- .../WebAssembly/WebAssemblySubtarget.cpp | 2 +- .../Target/WebAssembly/WebAssemblySubtarget.h | 2 +- .../WebAssembly/WebAssemblyTargetMachine.cpp | 2 +- llvm/lib/Target/X86/X86TargetMachine.cpp | 2 +- llvm/lib/Target/XCore/XCoreTargetMachine.cpp | 2 +- .../test/CodeGen/AMDGPU/idemponent-atomics.ll | 2 +- .../CodeGen/AMDGPU/private-memory-atomics.ll | 2 +- .../AtomicExpand/AArch64/atomicrmw-fp.ll | 2 +- .../AArch64/expand-atomicrmw-xchg-fp.ll | 4 +- .../AtomicExpand/AArch64/pcsections.ll| 2 +- .../AMDGPU/expand-atomic-i16-system.ll| 2 +- .../AtomicExpand/AMDGPU/expand-atomic-i16.ll | 4 +- .../AMDGPU/expand-atomic-i8-system.ll | 2 +- .../AtomicExpand/AMDGPU/expand-atomic-i8.ll | 4 +- ...and-atomic-rmw-fadd-flat-specialization.ll | 8 +- .../AMDGPU/expand-atomic-rmw-fadd.ll | 12 +- .../AMDGPU/expand-atomic-rmw-fmax.ll | 4 +- .../AMDGPU/expand-atomic-rmw-fmin.ll | 4 +- .../AMDGPU/expand-atomic-rmw-fsub.ll | 4 +- .../AMDGPU/expand-atomic-rmw-nand.ll | 4 +- .../expand-atomic-simplify-cfg-CAS-block.ll | 2 +- .../AtomicExpand/AMDGPU/unaligned-atomic.ll | 2 +- .../AtomicExpand/ARM/atomic-expansion-v7.ll | 2 +- .../AtomicExpand/ARM/atomic-expansion-v8.ll | 2 +- .../AtomicExpand/ARM/atomicrmw-fp.ll | 2 +- .../AtomicExpand/ARM/cmpxchg-weak.ll | 2 +- .../AtomicExpand/Hexagon/atomicrmw-fp.ll | 2 +- .../AtomicExpand/LoongArch/atomicrmw-fp.ll| 2 +- .../LoongArch/load-store-atomic.ll| 4 +- .../AtomicExpand/Mips/atomicrmw-fp.ll | 2 +- .../AtomicExpand/PowerPC/atomicrmw-fp.ll | 2 +- .../AtomicExpand/PowerPC/cfence-double.ll | 4 +- .../AtomicExpand/PowerPC/cfence-float.ll | 4 +- .../AtomicExpand/PowerPC/cmpxchg.ll | 4 +- .../AtomicExpand/PowerPC/issue55983.ll| 4 +- .../AtomicExpand/RISCV/atomicrmw-fp.ll| 2 +- .../Transforms/AtomicExpand/SPARC/libcalls.ll | 2 +- .../Transforms/AtomicExpand/SPARC/partword.ll | 2 +- .../AtomicExpand/X86/expand-atomic-libcall.ll | 2 +- .../X86/expand-atomic-non-integer.ll | 2 +- .../AtomicExpand/X86/expand-atomic-rmw-fp.ll | 2 +- .../X86/expand-atomic-rmw-initial-load.ll | 2 +- .../AtomicExpand/X86/expand-atomic-xchg-fp.ll | 2 +- llvm/tools/opt/opt.cpp| 2 - .../gn/secondary/llvm/lib/CodeGen/BUILD.gn| 2 +- 76 files changed, 219 insertions(+), 154 deletions(-) create mode 100644 llvm/include/llvm/CodeGen/ExpandAtomic.h rename llvm/lib/CodeGen/{AtomicExpandPass.cpp => ExpandAtomicPass.cpp} (95%) diff --git a/llvm/include/llvm/CodeGen/AtomicExpandUtils.h b/llvm/include/llvm/CodeGen/AtomicExpandUtils.h index 1cb410a0c31c69..851492678aeba5 100644 --- a/llvm/include/llvm/CodeGen/AtomicExpandUtils.h +++ b/llvm/include/llvm/CodeGen/AtomicExpandUtils.h @@
[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
@@ -429,6 +429,7 @@ FUNCTION_PASS("strip-gc-relocates", StripGCRelocates()) FUNCTION_PASS("structurizecfg", StructurizeCFGPass()) FUNCTION_PASS("tailcallelim", TailCallElimPass()) FUNCTION_PASS("typepromotion", TypePromotionPass(TM)) +FUNCTION_PASS("atomicexpand", AtomicExpandPass(TM)) arsenm wrote: Renaming the pass shouldn't be done in the same change as the new PM support https://github.com/llvm/llvm-project/pull/71220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
@@ -429,6 +429,7 @@ FUNCTION_PASS("strip-gc-relocates", StripGCRelocates()) FUNCTION_PASS("structurizecfg", StructurizeCFGPass()) FUNCTION_PASS("tailcallelim", TailCallElimPass()) FUNCTION_PASS("typepromotion", TypePromotionPass(TM)) +FUNCTION_PASS("atomicexpand", AtomicExpandPass(TM)) Ris-Bali wrote: Reverted back to original name. https://github.com/llvm/llvm-project/pull/71220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
@@ -340,7 +342,33 @@ bool AtomicExpand::runOnFunction(Function &F) { return MadeChange; } -bool AtomicExpand::bracketInstWithFences(Instruction *I, AtomicOrdering Order) { +bool AtomicExpandLegacy::runOnFunction(Function &F) { + if (skipFunction(F)) +return false; arsenm wrote: This should not use skipFunction, it's a mandatory lowering pass. It's not part of the current code https://github.com/llvm/llvm-project/pull/71220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
@@ -457,7 +457,7 @@ TargetPassConfig *PPCTargetMachine::createPassConfig(PassManagerBase &PM) { void PPCPassConfig::addIRPasses() { if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createPPCBoolRetToIntPass()); - addPass(createAtomicExpandPass()); + addPass(createAtomicExpandLegacyPass()); arsenm wrote: We should probably just add this to the default pipeline (not in this change) https://github.com/llvm/llvm-project/pull/71220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
@@ -457,7 +457,7 @@ TargetPassConfig *PPCTargetMachine::createPassConfig(PassManagerBase &PM) { void PPCPassConfig::addIRPasses() { if (TM->getOptLevel() != CodeGenOptLevel::None) addPass(createPPCBoolRetToIntPass()); - addPass(createAtomicExpandPass()); + addPass(createAtomicExpandLegacyPass()); Ris-Bali wrote: Will create a patch for this one this gets merged https://github.com/llvm/llvm-project/pull/71220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[llvm] [clang] [CodeGen] Port AtomicExpand to new Pass Manager (PR #71220)
https://github.com/Ris-Bali edited https://github.com/llvm/llvm-project/pull/71220 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits