This makes it slightly easier to pass extra arguments to runPasses
and simplifies the code slightly.
Reviewers: efriedma, bogner, dblaikie, diegotf, hiraditya
Reviewed By: dblaikie, hiraditya
Differential Revision: https://reviews.llvm.org/D68228
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@373265
91177308-0d34-0410-b5e6-
96231b3b80d8
/// returning the transformed module on success, or a null pointer on failure.
std::unique_ptr<Module> runPassesOn(Module *M,
const std::vector<std::string> &Passes,
- unsigned NumExtraArgs = 0,
- const char *const *ExtraArgs = nullptr);
+ ArrayRef<std::string> ExtraArgs = {});
/// runPasses - Run the specified passes on Program, outputting a bitcode
/// file and writting the filename into OutputFile if successful. If the
///
bool runPasses(Module &Program, const std::vector<std::string> &PassesToRun,
std::string &OutputFilename, bool DeleteOutput = false,
- bool Quiet = false, unsigned NumExtraArgs = 0,
- const char *const *ExtraArgs = nullptr) const;
+ bool Quiet = false,
+ ArrayRef<std::string> ExtraArgs = {}) const;
/// runPasses - Just like the method above, but this just returns true or
/// false indicating whether or not the optimizer crashed on the specified
std::string uniqueFN = "--extract-blocks-file=";
uniqueFN += Temp->TmpName;
- const char *ExtraArg = uniqueFN.c_str();
std::vector<std::string> PI;
PI.push_back("extract-blocks");
- std::unique_ptr<Module> Ret = runPassesOn(M, PI, 1, &ExtraArg);
+ std::unique_ptr<Module> Ret = runPassesOn(M, PI, {uniqueFN});
if (!Ret) {
outs() << "*** Basic Block extraction failed, please report a bug!\n";
bool BugDriver::runPasses(Module &Program,
const std::vector<std::string> &Passes,
std::string &OutputFilename, bool DeleteOutput,
- bool Quiet, unsigned NumExtraArgs,
- const char *const *ExtraArgs) const {
+ bool Quiet, ArrayRef<std::string> ExtraArgs) const {
// setup the output file name
outs().flush();
SmallString<128> UniqueFilename;
I != E; ++I)
Args.push_back(I->c_str());
Args.push_back(Temp->TmpName.c_str());
- for (unsigned i = 0; i < NumExtraArgs; ++i)
- Args.push_back(*ExtraArgs);
+ Args.append(ExtraArgs.begin(), ExtraArgs.end());
LLVM_DEBUG(errs() << "\nAbout to run:\t";
for (unsigned i = 0, e = Args.size() - 1; i != e; ++i) errs()
std::unique_ptr<Module>
BugDriver::runPassesOn(Module *M, const std::vector<std::string> &Passes,
- unsigned NumExtraArgs, const char *const *ExtraArgs) {
+ ArrayRef<std::string> ExtraArgs) {
std::string BitcodeResult;
if (runPasses(*M, Passes, BitcodeResult, false /*delete*/, true /*quiet*/,
- NumExtraArgs, ExtraArgs)) {
+ ExtraArgs)) {
return nullptr;
}