LLVM  9.0.0svn
SizeOpts.cpp
Go to the documentation of this file.
1 //===-- SizeOpts.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 code size optimization related code.
10 //
11 //===----------------------------------------------------------------------===//
12 
17 using namespace llvm;
18 
20  "pgso", cl::Hidden, cl::init(true),
21  cl::desc("Enable the profile guided size optimization. "));
22 
25  assert(F);
26  if (!PSI || !BFI || !PSI->hasProfileSummary())
27  return false;
28  return ProfileGuidedSizeOpt && PSI->isFunctionColdInCallGraph(F, *BFI);
29 }
30 
33  assert(BB);
34  if (!PSI || !BFI || !PSI->hasProfileSummary())
35  return false;
36  return ProfileGuidedSizeOpt && PSI->isColdBlock(BB, BFI);
37 }
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Analysis providing profile information.
F(f)
bool shouldOptimizeForSize(Function *F, ProfileSummaryInfo *PSI, BlockFrequencyInfo *BFI)
Returns true if function F is suggested to be size-optimized base on the profile. ...
Definition: SizeOpts.cpp:23
bool isColdBlock(const BasicBlock *BB, BlockFrequencyInfo *BFI)
Returns true if BasicBlock BB is considered cold.
bool hasProfileSummary()
Returns true if profile summary is available.
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
LLVM Basic Block Representation.
Definition: BasicBlock.h:57
static cl::opt< bool > ProfileGuidedSizeOpt("pgso", cl::Hidden, cl::init(true), cl::desc("Enable the profile guided size optimization. "))
bool isFunctionColdInCallGraph(const Function *F, BlockFrequencyInfo &BFI)
Returns true if F contains only cold code.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())