diff options
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h | 25 | ||||
-rw-r--r-- | llvm/include/llvm/InitializePasses.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/Passes/CodeGenPassBuilder.h | 2 | ||||
-rw-r--r-- | llvm/include/llvm/Passes/MachinePassRegistry.def | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/CodeGen.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp | 46 | ||||
-rw-r--r-- | llvm/lib/Passes/PassBuilder.cpp | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-call.mir | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-copy-prop.mir | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-undef-def.mir | 1 | ||||
-rw-r--r-- | llvm/test/CodeGen/X86/statepoint-fixup-undef.mir | 1 |
14 files changed, 72 insertions, 15 deletions
diff --git a/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h b/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h new file mode 100644 index 0000000..43c4034 --- /dev/null +++ b/llvm/include/llvm/CodeGen/FixupStatepointCallerSaved.h @@ -0,0 +1,25 @@ +//===- llvm/CodeGen/FixupStatepointCallerSaved.h ----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CODEGEN_FIXUPSTATEPOINTCALLERSAVED_H +#define LLVM_CODEGEN_FIXUPSTATEPOINTCALLERSAVED_H + +#include "llvm/CodeGen/MachinePassManager.h" + +namespace llvm { + +class FixupStatepointCallerSavedPass + : public PassInfoMixin<FixupStatepointCallerSavedPass> { +public: + PreservedAnalyses run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM); +}; + +} // namespace llvm + +#endif // LLVM_CODEGEN_FIXUPSTATEPOINTCALLERSAVED_H diff --git a/llvm/include/llvm/InitializePasses.h b/llvm/include/llvm/InitializePasses.h index 9afca6c..c2cb4cb 100644 --- a/llvm/include/llvm/InitializePasses.h +++ b/llvm/include/llvm/InitializePasses.h @@ -116,7 +116,7 @@ void initializeFEntryInserterPass(PassRegistry &); void initializeFinalizeISelPass(PassRegistry &); void initializeFinalizeMachineBundlesPass(PassRegistry &); void initializeFixIrreduciblePass(PassRegistry &); -void initializeFixupStatepointCallerSavedPass(PassRegistry &); +void initializeFixupStatepointCallerSavedLegacyPass(PassRegistry &); void initializeFlattenCFGLegacyPassPass(PassRegistry &); void initializeFuncletLayoutPass(PassRegistry &); void initializeGCEmptyBasicBlocksPass(PassRegistry &); diff --git a/llvm/include/llvm/Passes/CodeGenPassBuilder.h b/llvm/include/llvm/Passes/CodeGenPassBuilder.h index 9ec9836..25899d0 100644 --- a/llvm/include/llvm/Passes/CodeGenPassBuilder.h +++ b/llvm/include/llvm/Passes/CodeGenPassBuilder.h @@ -34,6 +34,7 @@ #include "llvm/CodeGen/ExpandPostRAPseudos.h" #include "llvm/CodeGen/ExpandReductions.h" #include "llvm/CodeGen/FinalizeISel.h" +#include "llvm/CodeGen/FixupStatepointCallerSaved.h" #include "llvm/CodeGen/GCMetadata.h" #include "llvm/CodeGen/GlobalMerge.h" #include "llvm/CodeGen/GlobalMergeFunctions.h" @@ -939,6 +940,7 @@ Error CodeGenPassBuilder<Derived, TargetMachineT>::addMachinePasses( derived().addPostRegAlloc(addPass); addPass(RemoveRedundantDebugValuesPass()); + addPass(FixupStatepointCallerSavedPass()); // Insert prolog/epilog code. Eliminate abstract frame index references... if (getOptLevel() != CodeGenOptLevel::None) { diff --git a/llvm/include/llvm/Passes/MachinePassRegistry.def b/llvm/include/llvm/Passes/MachinePassRegistry.def index 87253eb..f99a5f2 100644 --- a/llvm/include/llvm/Passes/MachinePassRegistry.def +++ b/llvm/include/llvm/Passes/MachinePassRegistry.def @@ -142,6 +142,7 @@ MACHINE_FUNCTION_PASS("early-ifcvt", EarlyIfConverterPass()) MACHINE_FUNCTION_PASS("early-machinelicm", EarlyMachineLICMPass()) MACHINE_FUNCTION_PASS("early-tailduplication", EarlyTailDuplicatePass()) MACHINE_FUNCTION_PASS("finalize-isel", FinalizeISelPass()) +MACHINE_FUNCTION_PASS("fixup-statepoint-caller-saved", FixupStatepointCallerSavedPass()) MACHINE_FUNCTION_PASS("localstackalloc", LocalStackSlotAllocationPass()) MACHINE_FUNCTION_PASS("machine-cp", MachineCopyPropagationPass()) MACHINE_FUNCTION_PASS("machine-cse", MachineCSEPass()) @@ -251,7 +252,6 @@ DUMMY_MACHINE_FUNCTION_PASS("cfi-instr-inserter", CFIInstrInserterPass) DUMMY_MACHINE_FUNCTION_PASS("detect-dead-lanes", DetectDeadLanesPass) DUMMY_MACHINE_FUNCTION_PASS("dot-machine-cfg", MachineCFGPrinter) DUMMY_MACHINE_FUNCTION_PASS("fentry-insert", FEntryInserterPass) -DUMMY_MACHINE_FUNCTION_PASS("fixup-statepoint-caller-saved", FixupStatepointCallerSavedPass) DUMMY_MACHINE_FUNCTION_PASS("fs-profile-loader", MIRProfileLoaderNewPass) DUMMY_MACHINE_FUNCTION_PASS("funclet-layout", FuncletLayoutPass) DUMMY_MACHINE_FUNCTION_PASS("gc-empty-basic-blocks", GCEmptyBasicBlocksPass) diff --git a/llvm/lib/CodeGen/CodeGen.cpp b/llvm/lib/CodeGen/CodeGen.cpp index 3169a10..beb7fb2 100644 --- a/llvm/lib/CodeGen/CodeGen.cpp +++ b/llvm/lib/CodeGen/CodeGen.cpp @@ -46,7 +46,7 @@ void llvm::initializeCodeGen(PassRegistry &Registry) { initializeFEntryInserterPass(Registry); initializeFinalizeISelPass(Registry); initializeFinalizeMachineBundlesPass(Registry); - initializeFixupStatepointCallerSavedPass(Registry); + initializeFixupStatepointCallerSavedLegacyPass(Registry); initializeFuncletLayoutPass(Registry); initializeGCMachineCodeAnalysisPass(Registry); initializeGCModuleInfoPass(Registry); diff --git a/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp b/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp index 36903fd..8f7dded 100644 --- a/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp +++ b/llvm/lib/CodeGen/FixupStatepointCallerSaved.cpp @@ -20,6 +20,7 @@ /// //===----------------------------------------------------------------------===// +#include "llvm/CodeGen/FixupStatepointCallerSaved.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" #include "llvm/CodeGen/MachineFrameInfo.h" @@ -58,14 +59,18 @@ static cl::opt<unsigned> MaxStatepointsWithRegs( namespace { -class FixupStatepointCallerSaved : public MachineFunctionPass { +struct FixupStatepointCallerSavedImpl { + bool run(MachineFunction &MF); +}; + +class FixupStatepointCallerSavedLegacy : public MachineFunctionPass { public: static char ID; - FixupStatepointCallerSaved() : MachineFunctionPass(ID) { - initializeFixupStatepointCallerSavedPass(*PassRegistry::getPassRegistry()); + FixupStatepointCallerSavedLegacy() : MachineFunctionPass(ID) { + initializeFixupStatepointCallerSavedLegacyPass( + *PassRegistry::getPassRegistry()); } - void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); MachineFunctionPass::getAnalysisUsage(AU); @@ -80,12 +85,12 @@ public: } // End anonymous namespace. -char FixupStatepointCallerSaved::ID = 0; -char &llvm::FixupStatepointCallerSavedID = FixupStatepointCallerSaved::ID; +char FixupStatepointCallerSavedLegacy::ID = 0; +char &llvm::FixupStatepointCallerSavedID = FixupStatepointCallerSavedLegacy::ID; -INITIALIZE_PASS_BEGIN(FixupStatepointCallerSaved, DEBUG_TYPE, +INITIALIZE_PASS_BEGIN(FixupStatepointCallerSavedLegacy, DEBUG_TYPE, "Fixup Statepoint Caller Saved", false, false) -INITIALIZE_PASS_END(FixupStatepointCallerSaved, DEBUG_TYPE, +INITIALIZE_PASS_END(FixupStatepointCallerSavedLegacy, DEBUG_TYPE, "Fixup Statepoint Caller Saved", false, false) // Utility function to get size of the register. @@ -590,10 +595,7 @@ public: }; } // namespace -bool FixupStatepointCallerSaved::runOnMachineFunction(MachineFunction &MF) { - if (skipFunction(MF.getFunction())) - return false; - +bool FixupStatepointCallerSavedImpl::run(MachineFunction &MF) { const Function &F = MF.getFunction(); if (!F.hasGC()) return false; @@ -620,3 +622,23 @@ bool FixupStatepointCallerSaved::runOnMachineFunction(MachineFunction &MF) { } return Changed; } + +bool FixupStatepointCallerSavedLegacy::runOnMachineFunction( + MachineFunction &MF) { + if (skipFunction(MF.getFunction())) + return false; + + return FixupStatepointCallerSavedImpl().run(MF); +} + +PreservedAnalyses +FixupStatepointCallerSavedPass::run(MachineFunction &MF, + MachineFunctionAnalysisManager &MFAM) { + + if (!FixupStatepointCallerSavedImpl().run(MF)) + return PreservedAnalyses::all(); + + auto PA = getMachineFunctionPassPreservedAnalyses(); + PA.preserveSet<CFGAnalyses>(); + return PA; +} diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp index 191bed1..8080059 100644 --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -92,6 +92,7 @@ #include "llvm/CodeGen/ExpandMemCmp.h" #include "llvm/CodeGen/ExpandPostRAPseudos.h" #include "llvm/CodeGen/FinalizeISel.h" +#include "llvm/CodeGen/FixupStatepointCallerSaved.h" #include "llvm/CodeGen/GCMetadata.h" #include "llvm/CodeGen/GlobalMerge.h" #include "llvm/CodeGen/GlobalMergeFunctions.h" diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-call.mir b/llvm/test/CodeGen/X86/statepoint-fixup-call.mir index 6ab95c2..2e0efa9 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-call.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-call.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -run-pass fixup-statepoint-caller-saved | FileCheck %s +# RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -passes='fixup-statepoint-caller-saved' | FileCheck %s --- | ; ModuleID = 'test/CodeGen/X86/statepoint-fixup-call.ll' source_filename = "test/CodeGen/X86/statepoint-fixup-call.ll" diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir b/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir index c87b287..e87e4d7 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop-neg.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved -verify-machineinstrs | FileCheck %s +# RUN: llc -o - %s -passes='fixup-statepoint-caller-saved' | FileCheck %s # Check that COPY is not eliminated if dest register is used in # non-meta arguments of statepoint. diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop.mir b/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop.mir index 6b3d3db..0d8d4dc 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-copy-prop.mir @@ -1,4 +1,5 @@ # RUN: llc -o - %s -run-pass fixup-statepoint-caller-saved -verify-machineinstrs | FileCheck %s +# RUN: llc -o - %s -passes='fixup-statepoint-caller-saved' | FileCheck %s --- | target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir b/llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir index f29dbfa..a44b625 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-invoke.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -run-pass fixup-statepoint-caller-saved | FileCheck %s +# RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -passes='fixup-statepoint-caller-saved' | FileCheck %s --- | ; ModuleID = 'test/CodeGen/X86/statepoint-fixup-invoke.mir' diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir b/llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir index d16c3d9..a2a194b 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-shared-ehpad.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -run-pass fixup-statepoint-caller-saved | FileCheck %s +# RUN: llc -o - %s -fixup-allow-gcptr-in-csr=false -passes='fixup-statepoint-caller-saved' | FileCheck %s # NOTE: MIR in this test was hand edited to have two statepoints share single landing pad. # This is forbidden in IR, but is allowed in MIR. I just was unable to reproduce conditions diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-undef-def.mir b/llvm/test/CodeGen/X86/statepoint-fixup-undef-def.mir index 7c48625..1a88a17 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-undef-def.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-undef-def.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -x mir -run-pass fixup-statepoint-caller-saved -verify-machineinstrs < %s | FileCheck %s +# RUN: llc -x mir -passes='fixup-statepoint-caller-saved' < %s | FileCheck %s --- | ; ModuleID = 'undef.ll' diff --git a/llvm/test/CodeGen/X86/statepoint-fixup-undef.mir b/llvm/test/CodeGen/X86/statepoint-fixup-undef.mir index edb0d51..05d04f5 100644 --- a/llvm/test/CodeGen/X86/statepoint-fixup-undef.mir +++ b/llvm/test/CodeGen/X86/statepoint-fixup-undef.mir @@ -1,5 +1,6 @@ # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py # RUN: llc -x mir -run-pass fixup-statepoint-caller-saved -verify-machineinstrs < %s | FileCheck %s +# RUN: llc -x mir -passes='fixup-statepoint-caller-saved' < %s | FileCheck %s # RUN: llc -x mir -start-before fixup-statepoint-caller-saved -verify-machineinstrs < %s | FileCheck %s -check-prefix=STACKMAP --- | |