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