14
14
#ifndef LLVM_IR_DEBUGLOC_H
15
15
#define LLVM_IR_DEBUGLOC_H
16
16
17
- #include " llvm/Config/config.h"
18
17
#include " llvm/IR/TrackingMDRef.h"
19
18
#include " llvm/Support/DataTypes.h"
20
19
@@ -23,73 +22,6 @@ namespace llvm {
23
22
class LLVMContext ;
24
23
class raw_ostream ;
25
24
class DILocation ;
26
- class Function ;
27
-
28
- #if ENABLE_DEBUGLOC_COVERAGE_TRACKING
29
- // Used to represent different "kinds" of DebugLoc, expressing that the
30
- // instruction it is part of is either normal and should contain a valid
31
- // DILocation, or otherwise describing the reason why the instruction does
32
- // not contain a valid DILocation.
33
- enum class DebugLocKind : uint8_t {
34
- // The instruction is expected to contain a valid DILocation.
35
- Normal,
36
- // The instruction is compiler-generated, i.e. it is not associated with any
37
- // line in the original source.
38
- CompilerGenerated,
39
- // The instruction has intentionally had its source location removed,
40
- // typically because it was moved outside of its original control-flow and
41
- // presenting the prior source location would be misleading for debuggers
42
- // or profilers.
43
- Dropped,
44
- // The instruction does not have a known or currently knowable source
45
- // location, e.g. the attribution is ambiguous in a way that can't be
46
- // represented, or determining the correct location is complicated and
47
- // requires future developer effort.
48
- Unknown,
49
- // DebugLoc is attached to an instruction that we don't expect to be
50
- // emitted, and so can omit a valid DILocation; we don't expect to ever try
51
- // and emit these into the line table, and trying to do so is a sign that
52
- // something has gone wrong (most likely a DebugLoc leaking from a transient
53
- // compiler-generated instruction).
54
- Temporary
55
- };
56
-
57
- // Extends TrackingMDNodeRef to also store a DebugLocKind, allowing Debugify
58
- // to ignore intentionally-empty DebugLocs.
59
- class DILocAndCoverageTracking : public TrackingMDNodeRef {
60
- public:
61
- DebugLocKind Kind;
62
- // Default constructor for empty DebugLocs.
63
- DILocAndCoverageTracking ()
64
- : TrackingMDNodeRef(nullptr ), Kind(DebugLocKind::Normal) {}
65
- // Valid or nullptr MDNode*, normal DebugLocKind.
66
- DILocAndCoverageTracking (const MDNode *Loc)
67
- : TrackingMDNodeRef(const_cast <MDNode *>(Loc)),
68
- Kind (DebugLocKind::Normal) {}
69
- DILocAndCoverageTracking (const DILocation *Loc);
70
- // Explicit DebugLocKind, which always means a nullptr MDNode*.
71
- DILocAndCoverageTracking (DebugLocKind Kind)
72
- : TrackingMDNodeRef(nullptr ), Kind(Kind) {}
73
- };
74
- template <> struct simplify_type <DILocAndCoverageTracking> {
75
- using SimpleType = MDNode *;
76
-
77
- static MDNode *getSimplifiedValue (DILocAndCoverageTracking &MD) {
78
- return MD.get ();
79
- }
80
- };
81
- template <> struct simplify_type <const DILocAndCoverageTracking> {
82
- using SimpleType = MDNode *;
83
-
84
- static MDNode *getSimplifiedValue (const DILocAndCoverageTracking &MD) {
85
- return MD.get ();
86
- }
87
- };
88
-
89
- using DebugLocTrackingRef = DILocAndCoverageTracking;
90
- #else
91
- using DebugLocTrackingRef = TrackingMDNodeRef;
92
- #endif // ENABLE_DEBUGLOC_COVERAGE_TRACKING
93
25
94
26
// / A debug info location.
95
27
// /
@@ -99,8 +31,7 @@ namespace llvm {
99
31
// / To avoid extra includes, \a DebugLoc doubles the \a DILocation API with a
100
32
// / one based on relatively opaque \a MDNode pointers.
101
33
class DebugLoc {
102
-
103
- DebugLocTrackingRef Loc;
34
+ TrackingMDNodeRef Loc;
104
35
105
36
public:
106
37
DebugLoc () = default ;
@@ -116,31 +47,6 @@ namespace llvm {
116
47
// / IR.
117
48
explicit DebugLoc (const MDNode *N);
118
49
119
- #if ENABLE_DEBUGLOC_COVERAGE_TRACKING
120
- DebugLoc (DebugLocKind Kind) : Loc(Kind) {}
121
- DebugLocKind getKind () const { return Loc.Kind ; }
122
- #endif
123
-
124
- #if ENABLE_DEBUGLOC_COVERAGE_TRACKING
125
- static inline DebugLoc getTemporary () {
126
- return DebugLoc (DebugLocKind::Temporary);
127
- }
128
- static inline DebugLoc getUnknown () {
129
- return DebugLoc (DebugLocKind::Unknown);
130
- }
131
- static inline DebugLoc getCompilerGenerated () {
132
- return DebugLoc (DebugLocKind::CompilerGenerated);
133
- }
134
- static inline DebugLoc getDropped () {
135
- return DebugLoc (DebugLocKind::Dropped);
136
- }
137
- #else
138
- static inline DebugLoc getTemporary () { return DebugLoc (); }
139
- static inline DebugLoc getUnknown () { return DebugLoc (); }
140
- static inline DebugLoc getCompilerGenerated () { return DebugLoc (); }
141
- static inline DebugLoc getDropped () { return DebugLoc (); }
142
- #endif // ENABLE_DEBUGLOC_COVERAGE_TRACKING
143
-
144
50
// / Get the underlying \a DILocation.
145
51
// /
146
52
// / \pre !*this or \c isa<DILocation>(getAsMDNode()).
0 commit comments