From 6ea0c0a28343b2676baf480db490b5a27fa11d7c Mon Sep 17 00:00:00 2001 From: paperchalice Date: Tue, 30 Apr 2024 09:54:48 +0800 Subject: [NewPM][CodeGen] Add `MachineFunctionAnalysis` (#88610) In new pass system, `MachineFunction` could be an analysis result again, machine module pass can now fetch them from analysis manager. `MachineModuleInfo` no longer owns them. Remove `FreeMachineFunctionPass`, replaced by `InvalidateAnalysisPass`. Now `FreeMachineFunction` is replaced by `InvalidateAnalysisPass`, the workaround in `MachineFunctionPassManager` is no longer needed, there is no difference between `unittests/MIR/PassBuilderCallbacksTest.cpp` and `unittests/IR/PassBuilderCallbacksTest.cpp`. --- llvm/lib/IR/LLVMContext.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'llvm/lib/IR/LLVMContext.cpp') diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index 57077e7..8120ccc 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -118,6 +118,13 @@ void LLVMContext::addModule(Module *M) { void LLVMContext::removeModule(Module *M) { pImpl->OwnedModules.erase(M); + pImpl->MachineFunctionNums.erase(M); +} + +unsigned LLVMContext::generateMachineFunctionNum(Function &F) { + Module *M = F.getParent(); + assert(pImpl->OwnedModules.contains(M) && "Unexpected module!"); + return pImpl->MachineFunctionNums[M]++; } //===----------------------------------------------------------------------===// -- cgit v1.1