@@ -8,7 +8,7 @@ Using -opt-bisect-limit to debug optimization errors
8
8
Introduction
9
9
============
10
10
11
- The -opt-bisect-limit option provides a way to disable all optimization passes
11
+ The `` -opt-bisect-limit `` option provides a way to disable all optimization passes
12
12
above a specified limit without modifying the way in which the Pass Managers
13
13
are populated. The intention of this option is to assist in tracking down
14
14
problems where incorrect transformations during optimization result in incorrect
@@ -19,10 +19,10 @@ skipped while still allowing correct code generation call a function to
19
19
check the opt-bisect limit before performing optimizations. Passes which
20
20
either must be run or do not modify the IR do not perform this check and are
21
21
therefore never skipped. Generally, this means analysis passes, passes
22
- that are run at CodeGenOptLevel::None and passes which are required for register
22
+ that are run at `` CodeGenOptLevel::None `` and passes which are required for register
23
23
allocation.
24
24
25
- The -opt-bisect-limit option can be used with any tool, including front ends
25
+ The `` -opt-bisect-limit `` option can be used with any tool, including front ends
26
26
such as clang, that uses the core LLVM library for optimization and code
27
27
generation. The exact syntax for invoking the option is discussed below.
28
28
@@ -36,7 +36,7 @@ transformations that is difficult to replicate with tools like opt and llc.
36
36
Getting Started
37
37
===============
38
38
39
- The -opt-bisect-limit command line option can be passed directly to tools such
39
+ The `` -opt-bisect-limit `` command- line option can be passed directly to tools such
40
40
as opt, llc and lli. The syntax is as follows:
41
41
42
42
::
@@ -49,17 +49,17 @@ indicating the index value that is associated with that optimization. To skip
49
49
optimizations, pass the value of the last optimization to be performed as the
50
50
opt-bisect-limit. All optimizations with a higher index value will be skipped.
51
51
52
- In order to use the -opt-bisect-limit option with a driver that provides a
52
+ In order to use the `` -opt-bisect-limit `` option with a driver that provides a
53
53
wrapper around the LLVM core library, an additional prefix option may be
54
54
required, as defined by the driver. For example, to use this option with
55
- clang, the " -mllvm" prefix must be used. A typical clang invocation would look
55
+ clang, the `` -mllvm `` prefix must be used. A typical clang invocation would look
56
56
like this:
57
57
58
58
::
59
59
60
60
clang -O2 -mllvm -opt-bisect-limit=256 my_file.c
61
61
62
- The -opt-bisect-limit option may also be applied to link-time optimizations by
62
+ The `` -opt-bisect-limit `` option may also be applied to link-time optimizations by
63
63
using a prefix to indicate that this is a plug-in option for the linker. The
64
64
following syntax will set a bisect limit for LTO transformations:
65
65
@@ -72,11 +72,11 @@ following syntax will set a bisect limit for LTO transformations:
72
72
73
73
LTO passes are run by a library instance invoked by the linker. Therefore any
74
74
passes run in the primary driver compilation phase are not affected by options
75
- passed via ' -Wl,-plugin-opt' and LTO passes are not affected by options
76
- passed to the driver-invoked LLVM invocation via ' -mllvm' .
75
+ passed via `` -Wl,-plugin-opt `` and LTO passes are not affected by options
76
+ passed to the driver-invoked LLVM invocation via `` -mllvm `` .
77
77
78
78
Passing ``-opt-bisect-print-ir-path=path/foo.ll `` will dump the IR to
79
- ``path/foo.ll `` when -opt-bisect-limit starts skipping passes.
79
+ ``path/foo.ll `` when `` -opt-bisect-limit `` starts skipping passes.
80
80
81
81
Bisection Index Values
82
82
======================
@@ -85,7 +85,7 @@ The granularity of the optimizations associated with a single index value is
85
85
variable. Depending on how the optimization pass has been instrumented the
86
86
value may be associated with as much as all transformations that would have
87
87
been performed by an optimization pass on an IR unit for which it is invoked
88
- (for instance, during a single call of runOnFunction for a FunctionPass) or as
88
+ (for instance, during a single call of `` runOnFunction `` for a `` FunctionPass `` ) or as
89
89
little as a single transformation. The index values may also be nested so that
90
90
if an invocation of the pass is not skipped individual transformations within
91
91
that invocation may still be skipped.
@@ -99,7 +99,7 @@ is not a problem.
99
99
When an opt-bisect index value refers to an entire invocation of the run
100
100
function for a pass, the pass will query whether or not it should be skipped
101
101
each time it is invoked and each invocation will be assigned a unique value.
102
- For example, if a FunctionPass is used with a module containing three functions
102
+ For example, if a `` FunctionPass `` is used with a module containing three functions
103
103
a different index value will be assigned to the pass for each of the functions
104
104
as the pass is run. The pass may be run on two functions but skipped for the
105
105
third.
@@ -144,13 +144,13 @@ Example Usage
144
144
Pass Skipping Implementation
145
145
============================
146
146
147
- The -opt-bisect-limit implementation depends on individual passes opting in to
148
- the opt-bisect process. The OptBisect object that manages the process is
147
+ The `` -opt-bisect-limit `` implementation depends on individual passes opting in to
148
+ the opt-bisect process. The `` OptBisect `` object that manages the process is
149
149
entirely passive and has no knowledge of how any pass is implemented. When a
150
- pass is run if the pass may be skipped, it should call the OptBisect object to
150
+ pass is run if the pass may be skipped, it should call the `` OptBisect `` object to
151
151
see if it should be skipped.
152
152
153
- The OptBisect object is intended to be accessed through LLVMContext and each
153
+ The `` OptBisect `` object is intended to be accessed through `` LLVMContext `` and each
154
154
Pass base class contains a helper function that abstracts the details in order
155
155
to make this check uniform across all passes. These helper functions are:
156
156
@@ -160,7 +160,7 @@ to make this check uniform across all passes. These helper functions are:
160
160
bool FunctionPass::skipFunction(const Function &F);
161
161
bool LoopPass::skipLoop(const Loop *L);
162
162
163
- A MachineFunctionPass should use FunctionPass::skipFunction() as such:
163
+ A `` MachineFunctionPass `` should use `` FunctionPass::skipFunction() `` as such:
164
164
165
165
.. code-block :: c++
166
166
@@ -170,11 +170,11 @@ A MachineFunctionPass should use FunctionPass::skipFunction() as such:
170
170
// Otherwise, run the pass normally.
171
171
}
172
172
173
- In addition to checking with the OptBisect class to see if the pass should be
174
- skipped, the skipFunction(), skipLoop() and skipBasicBlock() helper functions
175
- also look for the presence of the " optnone" function attribute. The calling
173
+ In addition to checking with the `` OptBisect `` class to see if the pass should be
174
+ skipped, the `` skipFunction() ``, `` skipLoop() `` and `` skipBasicBlock() `` helper functions
175
+ also look for the presence of the `` optnone `` function attribute. The calling
176
176
pass will be unable to determine whether it is being skipped because the
177
- " optnone" attribute is present or because the opt-bisect-limit has been
177
+ `` optnone `` attribute is present or because the `` opt-bisect-limit `` has been
178
178
reached. This is desirable because the behavior should be the same in either
179
179
case.
180
180
0 commit comments