LLVM 20.0.0git
MachineSizeOpts.cpp
Go to the documentation of this file.
1//===- MachineSizeOpts.cpp - code size optimization related code ----------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains some shared machine IR code size optimization related
10// code.
11//
12//===----------------------------------------------------------------------===//
13
18
19using namespace llvm;
20
26
29 const MachineBlockFrequencyInfo *MBFI,
30 PGSOQueryType QueryType) {
31 if (MF->getFunction().hasOptSize())
32 return true;
33 return shouldFuncOptimizeForSizeImpl(MF, PSI, MBFI, QueryType);
34}
35
38 const MachineBlockFrequencyInfo *MBFI,
39 PGSOQueryType QueryType) {
40 assert(MBB);
42 return true;
43 return shouldOptimizeForSizeImpl(MBB, PSI, MBFI, QueryType);
44}
45
48 MBFIWrapper *MBFIW,
49 PGSOQueryType QueryType) {
50 assert(MBB);
52 return true;
53 if (!MBFIW)
54 return false;
55 BlockFrequency BlockFreq = MBFIW->getBlockFreq(MBB);
56 return shouldOptimizeForSizeImpl(BlockFreq, PSI, &MBFIW->getMBFI(),
57 QueryType);
58}
MachineBasicBlock & MBB
cl::opt< bool > PGSOLargeWorkingSetSizeOnly
cl::opt< bool > ForcePGSO
cl::opt< int > PgsoCutoffSampleProf
cl::opt< bool > EnablePGSO
cl::opt< int > PgsoCutoffInstrProf
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasOptSize() const
Optimize this function for size (-Os) or minimum size (-Oz).
Definition: Function.h:707
BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const
Definition: MBFIWrapper.cpp:20
const MachineBlockFrequencyInfo & getMBFI() const
Definition: MBFIWrapper.h:37
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
Function & getFunction()
Return the LLVM function that this machine code represents.
Analysis providing profile information.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
bool shouldOptimizeForSize(const MachineFunction *MF, ProfileSummaryInfo *PSI, const MachineBlockFrequencyInfo *BFI, PGSOQueryType QueryType=PGSOQueryType::Other)
Returns true if machine function MF is suggested to be size-optimized based on the profile.
bool shouldFuncOptimizeForSizeImpl(const FuncT *F, ProfileSummaryInfo *PSI, BFIT *BFI, PGSOQueryType QueryType)
Definition: SizeOpts.h:51
bool shouldOptimizeForSizeImpl(BlockTOrBlockFreq BBOrBlockFreq, ProfileSummaryInfo *PSI, BFIT *BFI, PGSOQueryType QueryType)
Definition: SizeOpts.h:72
PGSOQueryType
Definition: SizeOpts.h:34