LCOV - code coverage report
Current view: top level - lib/MC - MCSection.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 33 35 94.3 %
Date: 2017-09-14 15:23:50 Functions: 4 5 80.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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     1413292 : MCSection::MCSection(SectionVariant V, SectionKind K, MCSymbol *Begin)
      24             :     : Begin(Begin), BundleGroupBeforeFirstInst(false), HasInstructions(false),
      25     5653168 :       IsRegistered(false), DummyFragment(this), Variant(V), Kind(K) {}
      26             : 
      27        5542 : MCSymbol *MCSection::getEndSymbol(MCContext &Ctx) {
      28        5542 :   if (!End)
      29        5464 :     End = Ctx.createTempSymbol("sec_end", true);
      30        5542 :   return End;
      31             : }
      32             : 
      33           0 : bool MCSection::hasEnded() const { return End && End->isInSection(); }
      34             : 
      35             : MCSection::~MCSection() = default;
      36             : 
      37        1183 : void MCSection::setBundleLockState(BundleLockStateType NewState) {
      38        1183 :   if (NewState == NotBundleLocked) {
      39         591 :     if (BundleLockNestingDepth == 0) {
      40           0 :       report_fatal_error("Mismatched bundle_lock/unlock directives");
      41             :     }
      42         591 :     if (--BundleLockNestingDepth == 0) {
      43         583 :       BundleLockState = NotBundleLocked;
      44             :     }
      45             :     return;
      46             :   }
      47             : 
      48             :   // If any of the directives is an align_to_end directive, the whole nested
      49             :   // group is align_to_end. So don't downgrade from align_to_end to just locked.
      50         592 :   if (BundleLockState != BundleLockedAlignToEnd) {
      51         590 :     BundleLockState = NewState;
      52             :   }
      53         592 :   ++BundleLockNestingDepth;
      54             : }
      55             : 
      56             : MCSection::iterator
      57      396280 : MCSection::getSubsectionInsertionPoint(unsigned Subsection) {
      58      396280 :   if (Subsection == 0 && SubsectionFragmentMap.empty())
      59             :     return end();
      60             : 
      61             :   SmallVectorImpl<std::pair<unsigned, MCFragment *>>::iterator MI =
      62          24 :       std::lower_bound(SubsectionFragmentMap.begin(),
      63             :                        SubsectionFragmentMap.end(),
      64          16 :                        std::make_pair(Subsection, (MCFragment *)nullptr));
      65           8 :   bool ExactMatch = false;
      66           8 :   if (MI != SubsectionFragmentMap.end()) {
      67           4 :     ExactMatch = MI->first == Subsection;
      68           4 :     if (ExactMatch)
      69           1 :       ++MI;
      70             :   }
      71           8 :   iterator IP;
      72           8 :   if (MI == SubsectionFragmentMap.end())
      73           4 :     IP = end();
      74             :   else
      75           8 :     IP = MI->second->getIterator();
      76           8 :   if (!ExactMatch && Subsection != 0) {
      77             :     // The GNU as documentation claims that subsections have an alignment of 4,
      78             :     // although this appears not to be the case.
      79          10 :     MCFragment *F = new MCDataFragment();
      80          10 :     SubsectionFragmentMap.insert(MI, std::make_pair(Subsection, F));
      81          10 :     getFragmentList().insert(IP, F);
      82          10 :     F->setParent(this);
      83             :   }
      84             : 
      85           8 :   return IP;
      86             : }
      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

Generated by: LCOV version 1.13