17
17
#define LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
18
18
19
19
#include " llvm/IR/ValueMap.h"
20
+ #include " llvm/Support/Error.h"
20
21
#include " llvm/Transforms/Utils/ValueMapper.h"
21
22
#include < memory>
22
23
#include < string>
@@ -85,23 +86,23 @@ class BugDriver {
85
86
// / variables are set up from command line arguments. The \p as_child argument
86
87
// / indicates whether the driver is to run in parent mode or child mode.
87
88
// /
88
- bool run (std::string &ErrMsg );
89
+ Error run ();
89
90
90
91
// / debugOptimizerCrash - This method is called when some optimizer pass
91
92
// / crashes on input. It attempts to prune down the testcase to something
92
93
// / reasonable, and figure out exactly which pass is crashing.
93
94
// /
94
- bool debugOptimizerCrash (const std::string &ID = " passes" );
95
+ Error debugOptimizerCrash (const std::string &ID = " passes" );
95
96
96
97
// / debugCodeGeneratorCrash - This method is called when the code generator
97
98
// / crashes on an input. It attempts to reduce the input as much as possible
98
99
// / while still causing the code generator to crash.
99
- bool debugCodeGeneratorCrash (std::string &Error );
100
+ Error debugCodeGeneratorCrash ();
100
101
101
102
// / debugMiscompilation - This method is used when the passes selected are not
102
103
// / crashing, but the generated output is semantically different from the
103
104
// / input.
104
- void debugMiscompilation (std::string *Error );
105
+ Error debugMiscompilation ();
105
106
106
107
// / debugPassMiscompilation - This method is called when the specified pass
107
108
// / miscompiles Program as input. It tries to reduce the testcase to
@@ -115,13 +116,12 @@ class BugDriver {
115
116
// / compileSharedObject - This method creates a SharedObject from a given
116
117
// / BitcodeFile for debugging a code generator.
117
118
// /
118
- std::string compileSharedObject (const std::string &BitcodeFile,
119
- std::string &Error);
119
+ Expected<std::string> compileSharedObject (const std::string &BitcodeFile);
120
120
121
121
// / debugCodeGenerator - This method narrows down a module to a function or
122
122
// / set of functions, using the CBE as a ``safe'' code generator for other
123
123
// / functions that are not under consideration.
124
- bool debugCodeGenerator (std::string *Error );
124
+ Error debugCodeGenerator ();
125
125
126
126
// / isExecutingJIT - Returns true if bugpoint is currently testing the JIT
127
127
// /
@@ -150,46 +150,45 @@ class BugDriver {
150
150
// / the specified one as the current program.
151
151
void setNewProgram (Module *M);
152
152
153
- // / compileProgram - Try to compile the specified module, returning false and
154
- // / setting Error if an error occurs. This is used for code generation
153
+ // / Try to compile the specified module. This is used for code generation
155
154
// / crash testing.
156
- // /
157
- void compileProgram (Module *M, std::string *Error) const ;
155
+ Error compileProgram (Module *M) const ;
158
156
159
157
// / executeProgram - This method runs "Program", capturing the output of the
160
158
// / program to a file. A recommended filename may be optionally specified.
161
159
// /
162
- std::string executeProgram (const Module *Program, std::string OutputFilename,
163
- std::string Bitcode,
164
- const std::string &SharedObjects,
165
- AbstractInterpreter *AI, std::string *Error) const ;
160
+ Expected<std::string> executeProgram (const Module *Program,
161
+ std::string OutputFilename,
162
+ std::string Bitcode,
163
+ const std::string &SharedObjects,
164
+ AbstractInterpreter *AI) const ;
166
165
167
166
// / executeProgramSafely - Used to create reference output with the "safe"
168
167
// / backend, if reference output is not provided. If there is a problem with
169
168
// / the code generator (e.g., llc crashes), this will return false and set
170
169
// / Error.
171
170
// /
172
- std::string executeProgramSafely ( const Module *Program,
173
- const std::string &OutputFile ,
174
- std::string *Error ) const ;
171
+ Expected< std::string>
172
+ executeProgramSafely ( const Module *Program ,
173
+ const std::string &OutputFile ) const ;
175
174
176
175
// / createReferenceFile - calls compileProgram and then records the output
177
176
// / into ReferenceOutputFile. Returns true if reference file created, false
178
177
// / otherwise. Note: initializeExecutionEnvironment should be called BEFORE
179
178
// / this function.
180
179
// /
181
- bool createReferenceFile (Module *M, const std::string &Filename =
182
- " bugpoint.reference.out-%%%%%%%" );
180
+ Error createReferenceFile (Module *M, const std::string &Filename =
181
+ " bugpoint.reference.out-%%%%%%%" );
183
182
184
183
// / diffProgram - This method executes the specified module and diffs the
185
184
// / output against the file specified by ReferenceOutputFile. If the output
186
185
// / is different, 1 is returned. If there is a problem with the code
187
186
// / generator (e.g., llc crashes), this will return -1 and set Error.
188
187
// /
189
- bool diffProgram (const Module *Program, const std::string &BitcodeFile = " " ,
190
- const std::string &SharedObj = " " ,
191
- bool RemoveBitcode = false ,
192
- std::string *Error = nullptr ) const ;
188
+ Expected< bool > diffProgram (const Module *Program,
189
+ const std::string &BitcodeFile = " " ,
190
+ const std::string &SharedObj = " " ,
191
+ bool RemoveBitcode = false ) const ;
193
192
194
193
// / EmitProgressBitcode - This function is used to output M to a file named
195
194
// / "bugpoint-ID.bc".
@@ -257,17 +256,13 @@ class BugDriver {
257
256
return runPasses (M, PassesToRun, Filename, true );
258
257
}
259
258
260
- // / runManyPasses - Take the specified pass list and create different
261
- // / combinations of passes to compile the program with. Compile the program
262
- // / with
263
- // / each set and mark test to see if it compiled correctly. If the passes
264
- // / compiled correctly output nothing and rearrange the passes into a new
265
- // / order.
266
- // / If the passes did not compile correctly, output the command required to
267
- // / recreate the failure. This returns true if a compiler error is found.
268
- // /
269
- bool runManyPasses (const std::vector<std::string> &AllPasses,
270
- std::string &ErrMsg);
259
+ // / Take the specified pass list and create different combinations of passes
260
+ // / to compile the program with. Compile the program with each set and mark
261
+ // / test to see if it compiled correctly. If the passes compiled correctly
262
+ // / output nothing and rearrange the passes into a new order. If the passes
263
+ // / did not compile correctly, output the command required to recreate the
264
+ // / failure.
265
+ Error runManyPasses (const std::vector<std::string> &AllPasses);
271
266
272
267
// / writeProgramToFile - This writes the current "Program" to the named
273
268
// / bitcode file. If an error occurs, true is returned.
@@ -280,7 +275,7 @@ class BugDriver {
280
275
// / initializeExecutionEnvironment - This method is used to set up the
281
276
// / environment for executing LLVM programs.
282
277
// /
283
- bool initializeExecutionEnvironment ();
278
+ Error initializeExecutionEnvironment ();
284
279
};
285
280
286
281
// / Given a bitcode or assembly input filename, parse and return it, or return
0 commit comments