[llvm] [NewPM][CodeGen] Add `MachineFunctionAnalysis` (PR #88610)
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 15 10:03:14 PDT 2024
================
@@ -0,0 +1,46 @@
+//===- 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/Target/TargetMachine.h"
+
+using namespace llvm;
+
+AnalysisKey MachineFunctionAnalysis::Key;
+
+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) {
+ /// Next unique number available for a MachineFunction.
+ static unsigned NextFnNum = 0;
----------------
aeubanks wrote:
this seems problematic. I believe people use multiple LLVMContexts in a process and are able to parallelize optimization/codegen that way.
perhaps we should put this in LLVMContext? unsure
https://github.com/llvm/llvm-project/pull/88610
More information about the llvm-commits
mailing list