Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Transforms/Utils/SizeOpts.cpp
Line
Count
Source
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
13
#include "llvm/Analysis/BlockFrequencyInfo.h"
14
#include "llvm/Analysis/ProfileSummaryInfo.h"
15
#include "llvm/Support/CommandLine.h"
16
#include "llvm/Transforms/Utils/SizeOpts.h"
17
using namespace llvm;
18
19
static cl::opt<bool> ProfileGuidedSizeOpt(
20
    "pgso", cl::Hidden, cl::init(true),
21
    cl::desc("Enable the profile guided size optimization. "));
22
23
bool llvm::shouldOptimizeForSize(Function *F, ProfileSummaryInfo *PSI,
24
20.3k
                                 BlockFrequencyInfo *BFI) {
25
20.3k
  assert(F);
26
20.3k
  if (!PSI || 
!BFI20.3k
||
!PSI->hasProfileSummary()20.3k
)
27
20.3k
    return false;
28
12
  return ProfileGuidedSizeOpt && 
PSI->isFunctionColdInCallGraph(F, *BFI)8
;
29
12
}
30
31
bool llvm::shouldOptimizeForSize(BasicBlock *BB, ProfileSummaryInfo *PSI,
32
411k
                                 BlockFrequencyInfo *BFI) {
33
411k
  assert(BB);
34
411k
  if (!PSI || 
!BFI21.2k
||
!PSI->hasProfileSummary()19.9k
)
35
411k
    return false;
36
17
  return ProfileGuidedSizeOpt && 
PSI->isColdBlock(BB, BFI)11
;
37
17
}