LLVM  8.0.1
DbgEntityHistoryCalculator.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/DbgEntityHistoryCalculator.h ----------------*- C++ -*-===//
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 #ifndef LLVM_CODEGEN_DBGVALUEHISTORYCALCULATOR_H
11 #define LLVM_CODEGEN_DBGVALUEHISTORYCALCULATOR_H
12 
13 #include "llvm/ADT/MapVector.h"
14 #include "llvm/ADT/SmallVector.h"
16 #include <utility>
17 
18 namespace llvm {
19 
20 class DILocalVariable;
21 class MachineFunction;
22 class MachineInstr;
23 class TargetRegisterInfo;
24 
25 // For each user variable, keep a list of instruction ranges where this variable
26 // is accessible. The variables are listed in order of appearance.
28  // Each instruction range starts with a DBG_VALUE instruction, specifying the
29  // location of a variable, which is assumed to be valid until the end of the
30  // range. If end is not specified, location is valid until the start
31  // instruction of the next instruction range, or until the end of the
32  // function.
33 public:
34  using InstrRange = std::pair<const MachineInstr *, const MachineInstr *>;
36  using InlinedEntity = std::pair<const DINode *, const DILocation *>;
38 
39 private:
40  InstrRangesMap VarInstrRanges;
41 
42 public:
43  void startInstrRange(InlinedEntity Var, const MachineInstr &MI);
44  void endInstrRange(InlinedEntity Var, const MachineInstr &MI);
45 
46  // Returns register currently describing @Var. If @Var is currently
47  // unaccessible or is not described by a register, returns 0.
48  unsigned getRegisterForVar(InlinedEntity Var) const;
49 
50  bool empty() const { return VarInstrRanges.empty(); }
51  void clear() { VarInstrRanges.clear(); }
52  InstrRangesMap::const_iterator begin() const { return VarInstrRanges.begin(); }
53  InstrRangesMap::const_iterator end() const { return VarInstrRanges.end(); }
54 
55 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
56  LLVM_DUMP_METHOD void dump() const;
57 #endif
58 };
59 
60 /// For each inlined instance of a source-level label, keep the corresponding
61 /// DBG_LABEL instruction. The DBG_LABEL instruction could be used to generate
62 /// a temporary (assembler) label before it.
64 public:
65  using InlinedEntity = std::pair<const DINode *, const DILocation *>;
67 
68 private:
69  InstrMap LabelInstr;
70 
71 public:
72  void addInstr(InlinedEntity Label, const MachineInstr &MI);
73 
74  bool empty() const { return LabelInstr.empty(); }
75  void clear() { LabelInstr.clear(); }
76  InstrMap::const_iterator begin() const { return LabelInstr.begin(); }
77  InstrMap::const_iterator end() const { return LabelInstr.end(); }
78 };
79 
81  const TargetRegisterInfo *TRI,
82  DbgValueHistoryMap &DbgValues,
83  DbgLabelInstrMap &DbgLabels);
84 
85 } // end namespace llvm
86 
87 #endif // LLVM_CODEGEN_DBGVALUEHISTORYCALCULATOR_H
For each inlined instance of a source-level label, keep the corresponding DBG_LABEL instruction...
void clear()
Definition: MapVector.h:89
This class represents lattice values for constants.
Definition: AllocatorList.h:24
unsigned const TargetRegisterInfo * TRI
unsigned getRegisterForVar(InlinedEntity Var) const
void calculateDbgEntityHistory(const MachineFunction *MF, const TargetRegisterInfo *TRI, DbgValueHistoryMap &DbgValues, DbgLabelInstrMap &DbgLabels)
std::pair< const DINode *, const DILocation * > InlinedEntity
bool empty() const
Definition: MapVector.h:80
#define LLVM_DUMP_METHOD
Definition: Compiler.h:74
InstrRangesMap::const_iterator begin() const
InstrMap::const_iterator begin() const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
InstrRangesMap::const_iterator end() const
std::pair< const DINode *, const DILocation * > InlinedEntity
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:847
InstrMap::const_iterator end() const
typename std::vector< std::pair< InlinedEntity, InstrRanges >> ::const_iterator const_iterator
Definition: MapVector.h:51
void startInstrRange(InlinedEntity Var, const MachineInstr &MI)
Representation of each machine instruction.
Definition: MachineInstr.h:64
void endInstrRange(InlinedEntity Var, const MachineInstr &MI)
std::pair< const MachineInstr *, const MachineInstr * > InstrRange
iterator begin()
Definition: MapVector.h:70
iterator end()
Definition: MapVector.h:72
IRTranslator LLVM IR MI
LLVM_DUMP_METHOD void dump() const