[CodeGenPrepare] Implement releaseMemory

Release BlockFrequencyInfo and BranchProbabilityInfo results and other
per function information immediately afterwards, instead of holding
onto the memory until the next `CodeGenPrepare::runOnFunction` call.

Differential Revision: https://reviews.llvm.org/D152552

Co-authored-by: Erik Hogeman <erik.hogeman@arm.com>
This commit is contained in:
Sven van Haastregt 2023-06-28 11:33:27 +01:00
parent 98d6ab9d6a
commit 789f012d50

View File

@ -377,6 +377,15 @@ public:
bool runOnFunction(Function &F) override;
void releaseMemory() override {
// Clear per function information.
InsertedInsts.clear();
PromotedInsts.clear();
FreshBBs.clear();
BPI.reset();
BFI.reset();
}
StringRef getPassName() const override { return "CodeGen Prepare"; }
void getAnalysisUsage(AnalysisUsage &AU) const override {
@ -498,10 +507,6 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
DL = &F.getParent()->getDataLayout();
bool EverMadeChange = false;
// Clear per function information.
InsertedInsts.clear();
PromotedInsts.clear();
FreshBBs.clear();
TM = &getAnalysis<TargetPassConfig>().getTM<TargetMachine>();
SubtargetInfo = TM->getSubtargetImpl(F);