Files
llvm-project/llvm/lib/CodeGen/MachineFunctionAnalysis.cpp
Kyle Krüger 5d0294fcb6 [llvm] Support building with c++23 (#154372)
closes #154331 

This PR addresses all minimum changes needed to compile LLVM and MLIR
with the c++23 standard.
It is a work in progress and to be reviewed for better methods of
handling the parts of the build broken by c++23.
2025-08-29 12:52:07 +00:00

58 lines
2.1 KiB
C++

//===- MachineFunctionAnalysis.cpp ----------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
//
// This file contains the definitions of the MachineFunctionAnalysis
// members.
//
//===----------------------------------------------------------------------===//
#include "llvm/CodeGen/MachineFunctionAnalysis.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineModuleInfo.h"
#include "llvm/IR/Function.h"
#include "llvm/Target/TargetMachine.h"
using namespace llvm;
AnalysisKey MachineFunctionAnalysis::Key;
llvm::MachineFunctionAnalysis::Result::Result(
std::unique_ptr<MachineFunction> MF)
: MF(std::move(MF)) {}
bool MachineFunctionAnalysis::Result::invalidate(
Function &, const PreservedAnalyses &PA,
FunctionAnalysisManager::Invalidator &) {
// Unless it is invalidated explicitly, it should remain preserved.
auto PAC = PA.getChecker<MachineFunctionAnalysis>();
return !PAC.preservedWhenStateless();
}
MachineFunctionAnalysis::Result
MachineFunctionAnalysis::run(Function &F, FunctionAnalysisManager &FAM) {
auto &Context = F.getContext();
const TargetSubtargetInfo &STI = *TM->getSubtargetImpl(F);
auto &MMI = FAM.getResult<ModuleAnalysisManagerFunctionProxy>(F)
.getCachedResult<MachineModuleAnalysis>(*F.getParent())
->getMMI();
auto MF = std::make_unique<MachineFunction>(
F, *TM, STI, MMI.getContext(), Context.generateMachineFunctionNum(F));
MF->initTargetMachineFunctionInfo(STI);
// MRI callback for target specific initializations.
TM->registerMachineRegisterInfoCallback(*MF);
return Result(std::move(MF));
}
PreservedAnalyses FreeMachineFunctionPass::run(Function &F,
FunctionAnalysisManager &FAM) {
FAM.clearAnalysis<MachineFunctionAnalysis>(F);
return PreservedAnalyses::all();
}