Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/TargetOptionsImpl.cpp
Line
Count
Source
1
//===-- TargetOptionsImpl.cpp - Options that apply to all targets ----------==//
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 implements the methods in the TargetOptions.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#include "llvm/CodeGen/MachineFrameInfo.h"
14
#include "llvm/CodeGen/MachineFunction.h"
15
#include "llvm/CodeGen/TargetFrameLowering.h"
16
#include "llvm/CodeGen/TargetSubtargetInfo.h"
17
#include "llvm/IR/Function.h"
18
#include "llvm/IR/Module.h"
19
#include "llvm/Target/TargetOptions.h"
20
using namespace llvm;
21
22
/// DisableFramePointerElim - This returns true if frame pointer elimination
23
/// optimization should be disabled for the given machine function.
24
17.9M
bool TargetOptions::DisableFramePointerElim(const MachineFunction &MF) const {
25
17.9M
  // Check to see if the target want to forcably keep frame pointer.
26
17.9M
  if (MF.getSubtarget().getFrameLowering()->keepFramePointer(MF))
27
35.7k
    return true;
28
17.9M
29
17.9M
  const Function &F = MF.getFunction();
30
17.9M
31
17.9M
  // TODO: Remove support for old `fp elim` function attributes after fully
32
17.9M
  //       migrate to use "frame-pointer"
33
17.9M
  if (!F.hasFnAttribute("frame-pointer")) {
34
13.1M
    // Check to see if we should eliminate all frame pointers.
35
13.1M
    if (F.getFnAttribute("no-frame-pointer-elim").getValueAsString() == "true")
36
9.70M
      return true;
37
3.41M
38
3.41M
    // Check to see if we should eliminate non-leaf frame pointers.
39
3.41M
    if (F.hasFnAttribute("no-frame-pointer-elim-non-leaf"))
40
1.77k
      return MF.getFrameInfo().hasCalls();
41
3.41M
42
3.41M
    return false;
43
3.41M
  }
44
4.77M
45
4.77M
  StringRef FP = F.getFnAttribute("frame-pointer").getValueAsString();
46
4.77M
  if (FP == "all")
47
4.70M
    return true;
48
75.7k
  if (FP == "non-leaf")
49
16
    return MF.getFrameInfo().hasCalls();
50
75.7k
  if (FP == "none")
51
75.7k
    return false;
52
18.4E
  llvm_unreachable("unknown frame pointer flag");
53
18.4E
}
54
55
/// HonorSignDependentRoundingFPMath - Return true if the codegen must assume
56
/// that the rounding mode of the FPU can change from its default.
57
7.46k
bool TargetOptions::HonorSignDependentRoundingFPMath() const {
58
7.46k
  return !UnsafeFPMath && 
HonorSignDependentRoundingFPMathOption7.32k
;
59
7.46k
}