Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===----- MIRFSDiscriminator.h: MIR FS Discriminator Support --0-- c++ -*-===//
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 the supporting functions for adding Machine level IR
10
// Flow Sensitive discriminators to the instruction debug information. With
11
// this, a cloned machine instruction in a different MachineBasicBlock will
12
// have its own discriminator value. This is done in a MIRAddFSDiscriminators
13
// pass.
14
//
15
//===----------------------------------------------------------------------===//
16
 
17
#ifndef LLVM_CODEGEN_MIRFSDISCRIMINATOR_H
18
#define LLVM_CODEGEN_MIRFSDISCRIMINATOR_H
19
 
20
#include "llvm/ADT/StringRef.h"
21
#include "llvm/CodeGen/MachineFunction.h"
22
#include "llvm/CodeGen/MachineFunctionPass.h"
23
#include "llvm/Support/Discriminator.h"
24
 
25
#include <cassert>
26
#include <cstdint>
27
 
28
namespace llvm {
29
class MachineFunction;
30
 
31
using namespace sampleprof;
32
class MIRAddFSDiscriminators : public MachineFunctionPass {
33
  MachineFunction *MF;
34
  unsigned LowBit;
35
  unsigned HighBit;
36
 
37
public:
38
  static char ID;
39
  /// PassNum is the sequence number this pass is called, start from 1.
40
  MIRAddFSDiscriminators(FSDiscriminatorPass P = FSDiscriminatorPass::Pass1)
41
      : MachineFunctionPass(ID) {
42
    LowBit = getFSPassBitBegin(P);
43
    HighBit = getFSPassBitEnd(P);
44
    assert(LowBit < HighBit && "HighBit needs to be greater than Lowbit");
45
  }
46
 
47
  StringRef getPassName() const override {
48
    return "Add FS discriminators in MIR";
49
  }
50
 
51
  /// getNumFSBBs() - Return the number of machine BBs that have FS samples.
52
  unsigned getNumFSBBs();
53
 
54
  /// getNumFSSamples() - Return the number of samples that have flow sensitive
55
  /// values.
56
  uint64_t getNumFSSamples();
57
 
58
  /// getMachineFunction - Return the current machine function.
59
  const MachineFunction *getMachineFunction() const { return MF; }
60
 
61
private:
62
  bool runOnMachineFunction(MachineFunction &) override;
63
};
64
 
65
} // namespace llvm
66
 
67
#endif // LLVM_CODEGEN_MIRFSDISCRIMINATOR_H