Coverage Report

Created: 2017-10-03 07:32

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/lib/MC/MCSection.cpp
Line
Count
Source (jump to first uncovered line)
1
//===- lib/MC/MCSection.cpp - Machine Code Section Representation ---------===//
2
//
3
//                     The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#include "llvm/MC/MCSection.h"
11
#include "llvm/ADT/SmallVector.h"
12
#include "llvm/MC/MCContext.h"
13
#include "llvm/MC/MCFragment.h"
14
#include "llvm/MC/MCSymbol.h"
15
#include "llvm/Support/Compiler.h"
16
#include "llvm/Support/ErrorHandling.h"
17
#include "llvm/Support/raw_ostream.h"
18
#include <algorithm>
19
#include <utility>
20
21
using namespace llvm;
22
23
MCSection::MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
24
    : Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false),
25
2.16M
      IsRegistered(false), DummyFragment(this), Variant(V), Kind(K) {}
26
27
949
MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) {
28
949
  if (!End)
29
871
    End = Ctx.createTempSymbol("sec_end", true);
30
949
  return End;
31
949
}
32
33
0
bool MCSection::hasEnded() const 
{ return End && 0
End->isInSection()0
; }
34
35
2.15M
MCSection::~MCSection() = default;
36
37
1.18k
void MCSection::setBundleLockState(BundleLockStateType NewState) {
38
1.18k
  if (
NewState == NotBundleLocked1.18k
) {
39
591
    if (
BundleLockNestingDepth == 0591
) {
40
0
      report_fatal_error("Mismatched bundle_lock/unlock directives");
41
0
    }
42
591
    
if (591
--BundleLockNestingDepth == 0591
) {
43
583
      BundleLockState = NotBundleLocked;
44
583
    }
45
591
    return;
46
591
  }
47
592
48
592
  // If any of the directives is an align_to_end directive, the whole nested
49
592
  // group is align_to_end. So don't downgrade from align_to_end to just locked.
50
592
  
if (592
BundleLockState != BundleLockedAlignToEnd592
) {
51
590
    BundleLockState = NewState;
52
590
  }
53
1.18k
  ++BundleLockNestingDepth;
54
1.18k
}
55
56
MCSection::iterator
57
530k
MCSection::getSubsectionInsertionPoint(unsigned Subsection) {
58
530k
  if (
Subsection == 0 && 530k
SubsectionFragmentMap.empty()530k
)
59
530k
    return end();
60
9
61
9
  SmallVectorImpl<std::pair<unsigned, MCFragment *>>::iterator MI =
62
9
      std::lower_bound(SubsectionFragmentMap.begin(),
63
9
                       SubsectionFragmentMap.end(),
64
9
                       std::make_pair(Subsection, (MCFragment *)nullptr));
65
9
  bool ExactMatch = false;
66
9
  if (
MI != SubsectionFragmentMap.end()9
) {
67
4
    ExactMatch = MI->first == Subsection;
68
4
    if (ExactMatch)
69
1
      ++MI;
70
4
  }
71
9
  iterator IP;
72
9
  if (MI == SubsectionFragmentMap.end())
73
4
    IP = end();
74
9
  else
75
5
    IP = MI->second->getIterator();
76
9
  if (
!ExactMatch && 9
Subsection != 07
) {
77
5
    // The GNU as documentation claims that subsections have an alignment of 4,
78
5
    // although this appears not to be the case.
79
5
    MCFragment *F = new MCDataFragment();
80
5
    SubsectionFragmentMap.insert(MI, std::make_pair(Subsection, F));
81
5
    getFragmentList().insert(IP, F);
82
5
    F->setParent(this);
83
5
  }
84
530k
85
530k
  return IP;
86
530k
}
87
88
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
89
LLVM_DUMP_METHOD void MCSection::dump() const {
90
  raw_ostream &OS = errs();
91
92
  OS << "<MCSection";
93
  OS << " Fragments:[\n      ";
94
  for (auto it = begin(), ie = end(); it != ie; ++it) {
95
    if (it != begin())
96
      OS << ",\n      ";
97
    it->dump();
98
  }
99
  OS << "]>";
100
}
101
#endif