diff options
Diffstat (limited to 'contrib/llvm/tools/bugpoint/ExecutionDriver.cpp')
-rw-r--r-- | contrib/llvm/tools/bugpoint/ExecutionDriver.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/contrib/llvm/tools/bugpoint/ExecutionDriver.cpp b/contrib/llvm/tools/bugpoint/ExecutionDriver.cpp index 25813b3..41b8ccc 100644 --- a/contrib/llvm/tools/bugpoint/ExecutionDriver.cpp +++ b/contrib/llvm/tools/bugpoint/ExecutionDriver.cpp @@ -17,6 +17,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/FileUtilities.h" +#include "llvm/Support/Program.h" #include "llvm/Support/SystemUtils.h" #include "llvm/Support/raw_ostream.h" #include <fstream> @@ -124,11 +125,10 @@ namespace { cl::ZeroOrMore, cl::PositionalEatsArgs); cl::opt<std::string> - GCCBinary("gcc", cl::init("gcc"), - cl::desc("The gcc binary to use. (default 'gcc')")); + CCBinary("gcc", cl::init(""), cl::desc("The gcc binary to use.")); cl::list<std::string> - GCCToolArgv("gcc-tool-args", cl::Positional, + CCToolArgv("gcc-tool-args", cl::Positional, cl::desc("<gcc-tool arguments>..."), cl::ZeroOrMore, cl::PositionalEatsArgs); } @@ -148,6 +148,13 @@ bool BugDriver::initializeExecutionEnvironment() { SafeInterpreter = nullptr; std::string Message; + if (CCBinary.empty()) { + if (sys::findProgramByName("clang")) + CCBinary = "clang"; + else + CCBinary = "gcc"; + } + switch (InterpreterSel) { case AutoPick: if (!Interpreter) { @@ -158,8 +165,8 @@ bool BugDriver::initializeExecutionEnvironment() { if (!Interpreter) { InterpreterSel = RunLLC; Interpreter = AbstractInterpreter::createLLC(getToolName(), Message, - GCCBinary, &ToolArgv, - &GCCToolArgv); + CCBinary, &ToolArgv, + &CCToolArgv); } if (!Interpreter) { InterpreterSel = RunLLI; @@ -179,8 +186,8 @@ bool BugDriver::initializeExecutionEnvironment() { case RunLLCIA: case LLC_Safe: Interpreter = AbstractInterpreter::createLLC(getToolName(), Message, - GCCBinary, &ToolArgv, - &GCCToolArgv, + CCBinary, &ToolArgv, + &CCToolArgv, InterpreterSel == RunLLCIA); break; case RunJIT: @@ -213,9 +220,9 @@ bool BugDriver::initializeExecutionEnvironment() { SafeInterpreterSel = RunLLC; SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, - GCCBinary, + CCBinary, &SafeToolArgs, - &GCCToolArgv); + &CCToolArgv); } if (!SafeInterpreter && @@ -224,9 +231,9 @@ bool BugDriver::initializeExecutionEnvironment() { SafeInterpreterSel = RunLLC; SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, - GCCBinary, + CCBinary, &SafeToolArgs, - &GCCToolArgv); + &CCToolArgv); } if (!SafeInterpreter) { SafeInterpreterSel = AutoPick; @@ -237,8 +244,8 @@ bool BugDriver::initializeExecutionEnvironment() { case RunLLCIA: SafeToolArgs.push_back("--relocation-model=pic"); SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, - GCCBinary, &SafeToolArgs, - &GCCToolArgv, + CCBinary, &SafeToolArgs, + &CCToolArgv, SafeInterpreterSel == RunLLCIA); break; case Custom: @@ -252,8 +259,8 @@ bool BugDriver::initializeExecutionEnvironment() { } if (!SafeInterpreter) { outs() << Message << "\nExiting.\n"; exit(1); } - gcc = GCC::create(Message, GCCBinary, &GCCToolArgv); - if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); } + cc = CC::create(Message, CCBinary, &CCToolArgv); + if (!cc) { outs() << Message << "\nExiting.\n"; exit(1); } // If there was an error creating the selected interpreter, quit with error. return Interpreter == nullptr; @@ -388,13 +395,13 @@ std::string BugDriver::compileSharedObject(const std::string &BitcodeFile, std::string OutputFile; // Using the known-good backend. - GCC::FileType FT = SafeInterpreter->OutputCode(BitcodeFile, OutputFile, + CC::FileType FT = SafeInterpreter->OutputCode(BitcodeFile, OutputFile, Error); if (!Error.empty()) return ""; std::string SharedObjectFile; - bool Failure = gcc->MakeSharedObject(OutputFile, FT, SharedObjectFile, + bool Failure = cc->MakeSharedObject(OutputFile, FT, SharedObjectFile, AdditionalLinkerArgs, Error); if (!Error.empty()) return ""; |