2019-10-28 12:35:34 -07:00
|
|
|
//===- MachineSizeOpts.cpp - code size optimization related code ----------===//
|
|
|
|
//
|
|
|
|
// 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 some shared machine IR code size optimization related
|
|
|
|
// code.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/CodeGen/MachineSizeOpts.h"
|
2020-07-24 12:40:34 +01:00
|
|
|
#include "llvm/CodeGen/MBFIWrapper.h"
|
2020-07-24 13:02:33 +01:00
|
|
|
#include "llvm/Analysis/ProfileSummaryInfo.h"
|
2019-10-28 12:35:34 -07:00
|
|
|
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
extern cl::opt<bool> EnablePGSO;
|
|
|
|
extern cl::opt<bool> PGSOLargeWorkingSetSizeOnly;
|
|
|
|
extern cl::opt<bool> ForcePGSO;
|
|
|
|
extern cl::opt<int> PgsoCutoffInstrProf;
|
|
|
|
extern cl::opt<int> PgsoCutoffSampleProf;
|
|
|
|
|
|
|
|
bool llvm::shouldOptimizeForSize(const MachineFunction *MF,
|
|
|
|
ProfileSummaryInfo *PSI,
|
2019-11-20 13:08:07 -08:00
|
|
|
const MachineBlockFrequencyInfo *MBFI,
|
|
|
|
PGSOQueryType QueryType) {
|
2023-06-28 22:18:53 -07:00
|
|
|
return shouldFuncOptimizeForSizeImpl(MF, PSI, MBFI, QueryType);
|
2019-10-28 12:35:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
bool llvm::shouldOptimizeForSize(const MachineBasicBlock *MBB,
|
|
|
|
ProfileSummaryInfo *PSI,
|
2019-11-20 13:08:07 -08:00
|
|
|
const MachineBlockFrequencyInfo *MBFI,
|
|
|
|
PGSOQueryType QueryType) {
|
2020-01-29 09:36:31 -08:00
|
|
|
assert(MBB);
|
2023-06-28 22:18:53 -07:00
|
|
|
return shouldOptimizeForSizeImpl(MBB, PSI, MBFI, QueryType);
|
2019-10-28 12:35:34 -07:00
|
|
|
}
|
2020-01-29 09:36:31 -08:00
|
|
|
|
|
|
|
bool llvm::shouldOptimizeForSize(const MachineBasicBlock *MBB,
|
|
|
|
ProfileSummaryInfo *PSI,
|
|
|
|
MBFIWrapper *MBFIW,
|
|
|
|
PGSOQueryType QueryType) {
|
|
|
|
assert(MBB);
|
|
|
|
if (!PSI || !MBFIW)
|
|
|
|
return false;
|
|
|
|
BlockFrequency BlockFreq = MBFIW->getBlockFreq(MBB);
|
2023-06-28 22:18:53 -07:00
|
|
|
return shouldOptimizeForSizeImpl(BlockFreq, PSI, &MBFIW->getMBFI(),
|
|
|
|
QueryType);
|
2020-01-29 09:36:31 -08:00
|
|
|
}
|