@@ -104,11 +104,23 @@ def AffinePipelineDataTransfer
104
104
105
105
def Canonicalizer : Pass<"canonicalize"> {
106
106
let summary = "Canonicalize operations";
107
+ let description = [{
108
+ This pass performs various types of canonicalizations over a set of
109
+ operations. See [Operation Canonicalization](Canonicalization.md) for more
110
+ details.
111
+ }];
107
112
let constructor = "mlir::createCanonicalizerPass()";
108
113
}
109
114
110
115
def CSE : Pass<"cse"> {
111
116
let summary = "Eliminate common sub-expressions";
117
+ let description = [{
118
+ This pass implements a generalized algorithm for common sub-expression
119
+ elimination. This pass relies on information provided by the
120
+ `Memory SideEffect` interface to identify when it is safe to eliminate
121
+ operations. See [Common subexpression elimination](https://en.wikipedia.org/wiki/Common_subexpression_elimination)
122
+ for more general details on this optimization.
123
+ }];
112
124
let constructor = "mlir::createCSEPass()";
113
125
let statistics = [
114
126
Statistic<"numCSE", "num-cse'd", "Number of operations CSE'd">,
@@ -131,6 +143,39 @@ def Inliner : Pass<"inline"> {
131
143
132
144
def LocationSnapshot : Pass<"snapshot-op-locations"> {
133
145
let summary = "Generate new locations from the current IR";
146
+ let description = [{
147
+ This pass allows for generating new locations from the IR during any stage
148
+ of compilation, by snapshotting the IR to a file and using that file to
149
+ generate new locations for the operations.
150
+
151
+ Depending on the value of the `tag` option, different resulting locations
152
+ may be generated:
153
+
154
+ * If unset, the original location of the operation is replaced.
155
+
156
+ Example:
157
+
158
+ ```mlir
159
+ // old:
160
+ ... loc("original_source.cpp":1:1)
161
+
162
+ // new:
163
+ ... loc("snapshot_source.mlir":10:10)
164
+ ```
165
+
166
+ * If set, the new location is fused with the original location in the form
167
+ of a [`Name Location`](Diagnostics.md#name-location) with the specified tag.
168
+
169
+ Example:
170
+
171
+ ```mlir
172
+ // old:
173
+ ... loc("original_source.cpp":1:1)
174
+
175
+ // new:
176
+ ... loc(fused["original_source.cpp":1:1, "snapshot"("snapshot_source.mlir":10:10)])
177
+ ```
178
+ }];
134
179
let constructor = "mlir::createLocationSnapshotPass()";
135
180
let options = [
136
181
Option<"fileName", "filename", "std::string", /*default=*/"",
@@ -230,11 +275,53 @@ def PrintOp : Pass<"print-op-graph", "ModuleOp"> {
230
275
231
276
def StripDebugInfo : Pass<"strip-debuginfo"> {
232
277
let summary = "Strip debug info from all operations";
278
+ let description = [{
279
+ This pass strips the IR of any location information, by replacing all
280
+ operation locations with [`unknown`](Diagnostics.md#unknown-location).
281
+ }];
233
282
let constructor = "mlir::createStripDebugInfoPass()";
234
283
}
235
284
236
285
def SymbolDCE : Pass<"symbol-dce"> {
237
286
let summary = "Eliminate dead symbols";
287
+ let description = [{
288
+ This pass deletes all symbols that are found to be unreachable. This is done
289
+ by computing the set of operations that are known to be live, propagating
290
+ that liveness to other symbols, and then deleting all symbols that are not
291
+ within this live set. Live symbols are those that have a
292
+ [visibility](SymbolsAndSymbolTables.md#symbol-visibility) that extends
293
+ beyond the IR, e.g. `public`, or those that are referenced by live symbols
294
+ or other non-Symbol operations.
295
+
296
+ For example, consider the following input:
297
+
298
+ ```mlir
299
+ func @dead_private_function() attributes { sym_visibility = "private" }
300
+ func @live_private_function() attributes { sym_visibility = "private" }
301
+
302
+ // Note: The `public` isn't necessary here, as this is the default.
303
+ func @public_function() attributes { sym_visibility = "public" } {
304
+ "foo.return"() {uses = [@live_private_function]} : () -> ()
305
+ }
306
+ ```
307
+
308
+ A known live function, `public_function`, contains a reference to an
309
+ otherwise non-live function `live_private_function`. After running
310
+ `symbol-dce`, only these two symbols should remain, as the final symbol
311
+ `dead_private_function` is not visible outside of the current IR and there
312
+ are no links to known-live operations. After running, we get the expected:
313
+
314
+ ```mlir
315
+ func @live_private_function() attributes { sym_visibility = "private" }
316
+
317
+ func @public_function() attributes { sym_visibility = "public" } {
318
+ "foo.return"() {uses = [@live_private_function]} : () -> ()
319
+ }
320
+ ```
321
+
322
+ See [Symbols and SymbolTables](SymbolsAndSymbolTables.md) for more
323
+ information on `Symbols`.
324
+ }];
238
325
let constructor = "mlir::createSymbolDCEPass()";
239
326
}
240
327
0 commit comments