@@ -34,24 +34,24 @@ namespace OptRemark {
34
34
// / Used in the streaming interface as the general argument type. It
35
35
// / internally converts everything into a key-value pair.
36
36
struct Argument {
37
- std::string Key ;
38
- std::string Val ;
37
+ std::string key ;
38
+ std::string val ;
39
39
// / If set, the debug location corresponding to the value.
40
- SourceLoc Loc ;
40
+ SourceLoc loc ;
41
41
42
- explicit Argument (StringRef Str = " " ) : Key (" String" ), Val (Str) {}
43
- Argument (StringRef Key , StringRef Val ) : Key(Key ), Val(Val ) {}
42
+ explicit Argument (StringRef Str = " " ) : key (" String" ), val (Str) {}
43
+ Argument (StringRef key , StringRef val ) : key(key ), val(val ) {}
44
44
45
- Argument (StringRef Key , int N );
46
- Argument (StringRef Key , long N );
47
- Argument (StringRef Key , long long N );
48
- Argument (StringRef Key , unsigned N );
49
- Argument (StringRef Key , unsigned long N );
50
- Argument (StringRef Key , unsigned long long N );
45
+ Argument (StringRef key , int n );
46
+ Argument (StringRef key , long n );
47
+ Argument (StringRef key , long long n );
48
+ Argument (StringRef key , unsigned n );
49
+ Argument (StringRef key , unsigned long n );
50
+ Argument (StringRef key , unsigned long long n );
51
51
52
- Argument (StringRef Key , SILFunction *F );
53
- Argument (StringRef Key , SILType Ty );
54
- Argument (StringRef Key , CanType Ty );
52
+ Argument (StringRef key , SILFunction *f );
53
+ Argument (StringRef key , SILType ty );
54
+ Argument (StringRef key , CanType ty );
55
55
};
56
56
57
57
// / Shorthand to insert named-value pairs.
@@ -60,132 +60,133 @@ using NV = Argument;
60
60
// / Inserting this into a Remark indents the text when printed as a debug
61
61
// / message.
62
62
struct IndentDebug {
63
- explicit IndentDebug (unsigned Width ) : Width(Width ) {}
64
- unsigned Width ;
63
+ explicit IndentDebug (unsigned width ) : width(width ) {}
64
+ unsigned width ;
65
65
};
66
66
67
67
// / The base class for remarks. This can be created by optimization passed to
68
68
// / report successful and unsuccessful optimizations. CRTP is used to preserve
69
69
// / the underlying type encoding the remark kind in the insertion operator.
70
70
template <typename DerivedT> class Remark {
71
71
// / Arguments collected via the streaming interface.
72
- SmallVector<Argument, 4 > Args ;
72
+ SmallVector<Argument, 4 > args ;
73
73
74
74
// / The name of the pass generating the remark.
75
- StringRef PassName ;
75
+ StringRef passName ;
76
76
77
77
// / Textual identifier for the remark (single-word, camel-case). Can be used
78
78
// / by external tools reading the YAML output file for optimization remarks to
79
79
// / identify the remark.
80
- StringRef Identifier ;
80
+ StringRef identifier ;
81
81
82
82
// / Source location for the diagnostics.
83
- SourceLoc Location ;
83
+ SourceLoc location ;
84
84
85
85
// / The function for the diagnostics.
86
- SILFunction *Function ;
86
+ SILFunction *function ;
87
87
88
88
// / Indentation used if this remarks is printed as a debug message.
89
- unsigned IndentDebugWidth = 0 ;
89
+ unsigned indentDebugWidth = 0 ;
90
90
91
91
protected:
92
- Remark (StringRef Identifier , SILInstruction &I )
93
- : Identifier(Identifier ), Location(I .getLoc().getSourceLoc()),
94
- Function (I .getParent()->getParent()) {}
92
+ Remark (StringRef identifier , SILInstruction &i )
93
+ : identifier(identifier ), location(i .getLoc().getSourceLoc()),
94
+ function (i .getParent()->getParent()) {}
95
95
96
96
public:
97
- DerivedT &operator <<(StringRef S ) {
98
- Args .emplace_back (S );
97
+ DerivedT &operator <<(StringRef s ) {
98
+ args .emplace_back (s );
99
99
return *static_cast <DerivedT *>(this );
100
100
}
101
101
102
- DerivedT &operator <<(Argument A ) {
103
- Args .push_back (std::move (A ));
102
+ DerivedT &operator <<(Argument a ) {
103
+ args .push_back (std::move (a ));
104
104
return *static_cast <DerivedT *>(this );
105
105
}
106
106
107
- DerivedT &operator <<(IndentDebug ID ) {
108
- IndentDebugWidth = ID. Width ;
107
+ DerivedT &operator <<(IndentDebug indent ) {
108
+ indentDebugWidth = indent. width ;
109
109
return *static_cast <DerivedT *>(this );
110
110
}
111
111
112
- StringRef getPassName () const { return PassName ; }
113
- StringRef getIdentifier () const { return Identifier ; }
114
- SILFunction *getFunction () const { return Function ; }
115
- SourceLoc getLocation () const { return Location ; }
112
+ StringRef getPassName () const { return passName ; }
113
+ StringRef getIdentifier () const { return identifier ; }
114
+ SILFunction *getFunction () const { return function ; }
115
+ SourceLoc getLocation () const { return location ; }
116
116
std::string getMsg () const ;
117
117
std::string getDebugMsg () const ;
118
118
Remark<DerivedT> &getRemark () { return *this ; }
119
- SmallVector<Argument, 4 > &getArgs () { return Args ; }
119
+ SmallVector<Argument, 4 > &getArgs () { return args ; }
120
120
121
- void setPassName (StringRef PN ) { PassName = PN ; }
121
+ void setPassName (StringRef name ) { passName = name ; }
122
122
};
123
123
124
124
// / Remark to report a successful optimization.
125
125
struct RemarkPassed : public Remark <RemarkPassed> {
126
- RemarkPassed (StringRef Id , SILInstruction &I ) : Remark(Id, I ) {}
126
+ RemarkPassed (StringRef id , SILInstruction &i ) : Remark(id, i ) {}
127
127
};
128
128
// / Remark to report a unsuccessful optimization.
129
129
struct RemarkMissed : public Remark <RemarkMissed> {
130
- RemarkMissed (StringRef Id , SILInstruction &I ) : Remark(Id, I ) {}
130
+ RemarkMissed (StringRef id , SILInstruction &i ) : Remark(id, i ) {}
131
131
};
132
132
133
133
// / Used to emit the remarks. Passes reporting remarks should create an
134
134
// / instance of this.
135
135
class Emitter {
136
- SILModule &Module ;
137
- std::string PassName ;
138
- bool PassedEnabled ;
139
- bool MissedEnabled ;
136
+ SILModule &module ;
137
+ std::string passName ;
138
+ bool passedEnabled ;
139
+ bool missedEnabled ;
140
140
141
141
// Making these non-generic allows out-of-line definition.
142
- void emit (const RemarkPassed &R );
143
- void emit (const RemarkMissed &R );
144
- static void emitDebug (const RemarkPassed &R );
145
- static void emitDebug (const RemarkMissed &R );
142
+ void emit (const RemarkPassed &remark );
143
+ void emit (const RemarkMissed &remark );
144
+ static void emitDebug (const RemarkPassed &remark );
145
+ static void emitDebug (const RemarkMissed &remark );
146
146
147
147
template <typename RemarkT> bool isEnabled ();
148
148
149
149
public:
150
- Emitter (StringRef PassName , SILModule &M );
150
+ Emitter (StringRef passName , SILModule &m );
151
151
152
152
// / Take a lambda that returns a remark which will be emitted. The
153
153
// / lambda is not evaluated unless remarks are enabled. Second argument is
154
154
// / only used to restrict this to functions.
155
155
template <typename T>
156
- void emit (T RemarkBuilder , decltype (RemarkBuilder ()) * = nullptr) {
157
- using RemarkT = decltype (RemarkBuilder ());
156
+ void emit (T remarkBuilder , decltype (remarkBuilder ()) * = nullptr) {
157
+ using RemarkT = decltype (remarkBuilder ());
158
158
// Avoid building the remark unless remarks are enabled.
159
- if (isEnabled<RemarkT>() || Module .getOptRecordStream ()) {
160
- auto rb = RemarkBuilder ();
161
- rb.setPassName (PassName );
159
+ if (isEnabled<RemarkT>() || module .getOptRecordStream ()) {
160
+ auto rb = remarkBuilder ();
161
+ rb.setPassName (passName );
162
162
emit (rb);
163
163
}
164
164
}
165
165
166
166
// / Emit an optimization remark or debug message.
167
167
template <typename T>
168
- static void emitOrDebug (const char *PassName, Emitter *ORE, T RemarkBuilder,
169
- decltype (RemarkBuilder()) * = nullptr) {
170
- using RemarkT = decltype (RemarkBuilder ());
168
+ static void emitOrDebug (const char *passName, Emitter *emitter,
169
+ T remarkBuilder,
170
+ decltype (remarkBuilder()) * = nullptr) {
171
+ using RemarkT = decltype (remarkBuilder ());
171
172
// Avoid building the remark unless remarks are enabled.
172
- bool EmitRemark =
173
- ORE && (ORE-> isEnabled <RemarkT>() || ORE-> Module .getOptRecordStream ());
173
+ bool emitRemark = emitter && (emitter-> isEnabled <RemarkT>() ||
174
+ emitter-> module .getOptRecordStream ());
174
175
// Same for DEBUG.
175
- bool EmitDebug = false ;
176
+ bool shouldEmitDebug = false ;
176
177
#ifndef NDEBUG
177
- EmitDebug |= llvm::DebugFlag && llvm::isCurrentDebugType (PassName );
178
+ shouldEmitDebug |= llvm::DebugFlag && llvm::isCurrentDebugType (passName );
178
179
#endif // NDEBUG
179
180
180
- if (EmitRemark || EmitDebug ) {
181
- auto R = RemarkBuilder ();
182
- if (EmitDebug )
183
- emitDebug (R );
184
- if (EmitRemark ) {
185
- // If we have ORE use the PassName that was set up with ORE . DEBUG_TYPE
181
+ if (emitRemark || shouldEmitDebug ) {
182
+ auto r = remarkBuilder ();
183
+ if (shouldEmitDebug )
184
+ emitDebug (r );
185
+ if (emitRemark ) {
186
+ // If we have an Emitter use the PassName that was set up. DEBUG_TYPE
186
187
// may be different if a pass is calling other modules.
187
- R .setPassName (ORE-> PassName );
188
- ORE ->emit (R );
188
+ r .setPassName (emitter-> passName );
189
+ emitter ->emit (r );
189
190
}
190
191
}
191
192
}
@@ -195,10 +196,10 @@ class Emitter {
195
196
OptRemark::Emitter::emitOrDebug (DEBUG_TYPE, __VA_ARGS__)
196
197
197
198
template <> inline bool Emitter::isEnabled<RemarkMissed>() {
198
- return MissedEnabled ;
199
+ return missedEnabled ;
199
200
}
200
201
template <> inline bool Emitter::isEnabled<RemarkPassed>() {
201
- return PassedEnabled ;
202
+ return passedEnabled ;
202
203
}
203
204
} // namespace OptRemark
204
205
} // namespace swift
0 commit comments