diff options
author | paperchalice <liujunchang97@outlook.com> | 2024-04-30 09:54:48 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-30 09:54:48 +0800 |
commit | 6ea0c0a28343b2676baf480db490b5a27fa11d7c (patch) | |
tree | f00243ace9e105d4acf60987f9a218b0809ac8af /llvm/lib/IR | |
parent | b1867e18c346e9621e14270bea2d1acb7d2a9ce0 (diff) | |
download | llvm-6ea0c0a28343b2676baf480db490b5a27fa11d7c.zip llvm-6ea0c0a28343b2676baf480db490b5a27fa11d7c.tar.gz llvm-6ea0c0a28343b2676baf480db490b5a27fa11d7c.tar.bz2 |
[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<MachineFunctionAnalysis>`.
Now `FreeMachineFunction` is replaced by
`InvalidateAnalysisPass<MachineFunctionAnalysis>`, the workaround in
`MachineFunctionPassManager` is no longer needed, there is no difference
between `unittests/MIR/PassBuilderCallbacksTest.cpp` and
`unittests/IR/PassBuilderCallbacksTest.cpp`.
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r-- | llvm/lib/IR/LLVMContext.cpp | 7 | ||||
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.h | 4 |
2 files changed, 11 insertions, 0 deletions
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]++; } //===----------------------------------------------------------------------===// diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h index 7c67e19..2713015 100644 --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -1450,6 +1450,10 @@ public: /// will be automatically deleted if this context is deleted. SmallPtrSet<Module *, 4> OwnedModules; + /// MachineFunctionNums - Keep the next available unique number available for + /// a MachineFunction in given module. Module must in OwnedModules. + DenseMap<Module *, unsigned> MachineFunctionNums; + /// The main remark streamer used by all the other streamers (e.g. IR, MIR, /// frontends, etc.). This should only be used by the specific streamers, and /// never directly. |