Coverage Report

Created: 2019-07-24 05:18

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/CodeGen/AllocationOrder.cpp
Line
Count
Source
1
//===-- llvm/CodeGen/AllocationOrder.cpp - Allocation Order ---------------===//
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 an allocation order for virtual registers.
10
//
11
// The preferred allocation order for a virtual register depends on allocation
12
// hints and target hooks. The AllocationOrder class encapsulates all of that.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#include "AllocationOrder.h"
17
#include "llvm/CodeGen/MachineFunction.h"
18
#include "llvm/CodeGen/MachineRegisterInfo.h"
19
#include "llvm/CodeGen/RegisterClassInfo.h"
20
#include "llvm/CodeGen/VirtRegMap.h"
21
#include "llvm/Support/Debug.h"
22
#include "llvm/Support/raw_ostream.h"
23
24
using namespace llvm;
25
26
#define DEBUG_TYPE "regalloc"
27
28
// Compare VirtRegMap::getRegAllocPref().
29
AllocationOrder::AllocationOrder(unsigned VirtReg,
30
                                 const VirtRegMap &VRM,
31
                                 const RegisterClassInfo &RegClassInfo,
32
                                 const LiveRegMatrix *Matrix)
33
12.1M
  : Pos(0), HardHints(false) {
34
12.1M
  const MachineFunction &MF = VRM.getMachineFunction();
35
12.1M
  const TargetRegisterInfo *TRI = &VRM.getTargetRegInfo();
36
12.1M
  Order = RegClassInfo.getOrder(MF.getRegInfo().getRegClass(VirtReg));
37
12.1M
  if (TRI->getRegAllocationHints(VirtReg, Order, Hints, MF, &VRM, Matrix))
38
18
    HardHints = true;
39
12.1M
  rewind();
40
12.1M
41
12.1M
  LLVM_DEBUG({
42
12.1M
    if (!Hints.empty()) {
43
12.1M
      dbgs() << "hints:";
44
12.1M
      for (unsigned I = 0, E = Hints.size(); I != E; ++I)
45
12.1M
        dbgs() << ' ' << printReg(Hints[I], TRI);
46
12.1M
      dbgs() << '\n';
47
12.1M
    }
48
12.1M
  });
49
#ifndef NDEBUG
50
  for (unsigned I = 0, E = Hints.size(); I != E; ++I)
51
    assert(is_contained(Order, Hints[I]) &&
52
           "Target hint is outside allocation order.");
53
#endif
54
}