mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
[bugpoint] Update runPasses to take ArrayRef instead of a pointer (NFC)
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 llvm-svn: 373265
This commit is contained in:
parent
4e7048cdf0
commit
d088d0a729
@ -217,8 +217,7 @@ public:
|
|||||||
/// returning the transformed module on success, or a null pointer on failure.
|
/// returning the transformed module on success, or a null pointer on failure.
|
||||||
std::unique_ptr<Module> runPassesOn(Module *M,
|
std::unique_ptr<Module> runPassesOn(Module *M,
|
||||||
const std::vector<std::string> &Passes,
|
const std::vector<std::string> &Passes,
|
||||||
unsigned NumExtraArgs = 0,
|
ArrayRef<std::string> ExtraArgs = {});
|
||||||
const char *const *ExtraArgs = nullptr);
|
|
||||||
|
|
||||||
/// runPasses - Run the specified passes on Program, outputting a bitcode
|
/// runPasses - Run the specified passes on Program, outputting a bitcode
|
||||||
/// file and writting the filename into OutputFile if successful. If the
|
/// file and writting the filename into OutputFile if successful. If the
|
||||||
@ -231,8 +230,8 @@ public:
|
|||||||
///
|
///
|
||||||
bool runPasses(Module &Program, const std::vector<std::string> &PassesToRun,
|
bool runPasses(Module &Program, const std::vector<std::string> &PassesToRun,
|
||||||
std::string &OutputFilename, bool DeleteOutput = false,
|
std::string &OutputFilename, bool DeleteOutput = false,
|
||||||
bool Quiet = false, unsigned NumExtraArgs = 0,
|
bool Quiet = false,
|
||||||
const char *const *ExtraArgs = nullptr) const;
|
ArrayRef<std::string> ExtraArgs = {}) const;
|
||||||
|
|
||||||
/// runPasses - Just like the method above, but this just returns true or
|
/// runPasses - Just like the method above, but this just returns true or
|
||||||
/// false indicating whether or not the optimizer crashed on the specified
|
/// false indicating whether or not the optimizer crashed on the specified
|
||||||
|
@ -407,11 +407,10 @@ BugDriver::extractMappedBlocksFromModule(const std::vector<BasicBlock *> &BBs,
|
|||||||
|
|
||||||
std::string uniqueFN = "--extract-blocks-file=";
|
std::string uniqueFN = "--extract-blocks-file=";
|
||||||
uniqueFN += Temp->TmpName;
|
uniqueFN += Temp->TmpName;
|
||||||
const char *ExtraArg = uniqueFN.c_str();
|
|
||||||
|
|
||||||
std::vector<std::string> PI;
|
std::vector<std::string> PI;
|
||||||
PI.push_back("extract-blocks");
|
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) {
|
if (!Ret) {
|
||||||
outs() << "*** Basic Block extraction failed, please report a bug!\n";
|
outs() << "*** Basic Block extraction failed, please report a bug!\n";
|
||||||
|
@ -130,8 +130,7 @@ static cl::list<std::string> OptArgs("opt-args", cl::Positional,
|
|||||||
bool BugDriver::runPasses(Module &Program,
|
bool BugDriver::runPasses(Module &Program,
|
||||||
const std::vector<std::string> &Passes,
|
const std::vector<std::string> &Passes,
|
||||||
std::string &OutputFilename, bool DeleteOutput,
|
std::string &OutputFilename, bool DeleteOutput,
|
||||||
bool Quiet, unsigned NumExtraArgs,
|
bool Quiet, ArrayRef<std::string> ExtraArgs) const {
|
||||||
const char *const *ExtraArgs) const {
|
|
||||||
// setup the output file name
|
// setup the output file name
|
||||||
outs().flush();
|
outs().flush();
|
||||||
SmallString<128> UniqueFilename;
|
SmallString<128> UniqueFilename;
|
||||||
@ -223,8 +222,7 @@ bool BugDriver::runPasses(Module &Program,
|
|||||||
I != E; ++I)
|
I != E; ++I)
|
||||||
Args.push_back(I->c_str());
|
Args.push_back(I->c_str());
|
||||||
Args.push_back(Temp->TmpName.c_str());
|
Args.push_back(Temp->TmpName.c_str());
|
||||||
for (unsigned i = 0; i < NumExtraArgs; ++i)
|
Args.append(ExtraArgs.begin(), ExtraArgs.end());
|
||||||
Args.push_back(*ExtraArgs);
|
|
||||||
|
|
||||||
LLVM_DEBUG(errs() << "\nAbout to run:\t";
|
LLVM_DEBUG(errs() << "\nAbout to run:\t";
|
||||||
for (unsigned i = 0, e = Args.size() - 1; i != e; ++i) errs()
|
for (unsigned i = 0, e = Args.size() - 1; i != e; ++i) errs()
|
||||||
@ -268,10 +266,10 @@ bool BugDriver::runPasses(Module &Program,
|
|||||||
|
|
||||||
std::unique_ptr<Module>
|
std::unique_ptr<Module>
|
||||||
BugDriver::runPassesOn(Module *M, const std::vector<std::string> &Passes,
|
BugDriver::runPassesOn(Module *M, const std::vector<std::string> &Passes,
|
||||||
unsigned NumExtraArgs, const char *const *ExtraArgs) {
|
ArrayRef<std::string> ExtraArgs) {
|
||||||
std::string BitcodeResult;
|
std::string BitcodeResult;
|
||||||
if (runPasses(*M, Passes, BitcodeResult, false /*delete*/, true /*quiet*/,
|
if (runPasses(*M, Passes, BitcodeResult, false /*delete*/, true /*quiet*/,
|
||||||
NumExtraArgs, ExtraArgs)) {
|
ExtraArgs)) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user