Add command line option --gcc to bugpoint.

Remove sending duplicate of the --gcc-tool-args parameters to gcc.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103397 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Kalle Raiskila
2010-05-10 07:38:37 +00:00
parent ad017dcb3a
commit faa95763eb
3 changed files with 30 additions and 17 deletions

View File

@@ -118,6 +118,10 @@ namespace {
cl::desc("<safe-tool arguments>..."), cl::desc("<safe-tool arguments>..."),
cl::ZeroOrMore, cl::PositionalEatsArgs); cl::ZeroOrMore, cl::PositionalEatsArgs);
cl::opt<std::string>
GCCBinary("gcc", cl::init("gcc"),
cl::desc("The gcc binary to use. (default 'gcc')"));
cl::list<std::string> cl::list<std::string>
GCCToolArgv("gcc-tool-args", cl::Positional, GCCToolArgv("gcc-tool-args", cl::Positional,
cl::desc("<gcc-tool arguments>..."), cl::desc("<gcc-tool arguments>..."),
@@ -143,8 +147,8 @@ bool BugDriver::initializeExecutionEnvironment() {
case AutoPick: case AutoPick:
InterpreterSel = RunCBE; InterpreterSel = RunCBE;
Interpreter = Interpreter =
AbstractInterpreter::createCBE(getToolName(), Message, &ToolArgv, AbstractInterpreter::createCBE(getToolName(), Message, GCCBinary,
&GCCToolArgv); &ToolArgv, &GCCToolArgv);
if (!Interpreter) { if (!Interpreter) {
InterpreterSel = RunJIT; InterpreterSel = RunJIT;
Interpreter = AbstractInterpreter::createJIT(getToolName(), Message, Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
@@ -153,7 +157,8 @@ bool BugDriver::initializeExecutionEnvironment() {
if (!Interpreter) { if (!Interpreter) {
InterpreterSel = RunLLC; InterpreterSel = RunLLC;
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message, Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
&ToolArgv, &GCCToolArgv); GCCBinary, &ToolArgv,
&GCCToolArgv);
} }
if (!Interpreter) { if (!Interpreter) {
InterpreterSel = RunLLI; InterpreterSel = RunLLI;
@@ -173,7 +178,8 @@ bool BugDriver::initializeExecutionEnvironment() {
case RunLLCIA: case RunLLCIA:
case LLC_Safe: case LLC_Safe:
Interpreter = AbstractInterpreter::createLLC(getToolName(), Message, Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
&ToolArgv, &GCCToolArgv, GCCBinary, &ToolArgv,
&GCCToolArgv,
InterpreterSel == RunLLCIA); InterpreterSel == RunLLCIA);
break; break;
case RunJIT: case RunJIT:
@@ -183,7 +189,8 @@ bool BugDriver::initializeExecutionEnvironment() {
case RunCBE: case RunCBE:
case CBE_bug: case CBE_bug:
Interpreter = AbstractInterpreter::createCBE(getToolName(), Message, Interpreter = AbstractInterpreter::createCBE(getToolName(), Message,
&ToolArgv, &GCCToolArgv); GCCBinary, &ToolArgv,
&GCCToolArgv);
break; break;
case Custom: case Custom:
Interpreter = AbstractInterpreter::createCustom(Message, CustomExecCommand); Interpreter = AbstractInterpreter::createCustom(Message, CustomExecCommand);
@@ -209,6 +216,7 @@ bool BugDriver::initializeExecutionEnvironment() {
SafeInterpreterSel = RunLLC; SafeInterpreterSel = RunLLC;
SafeToolArgs.push_back("--relocation-model=pic"); SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
GCCBinary,
&SafeToolArgs, &SafeToolArgs,
&GCCToolArgv); &GCCToolArgv);
} }
@@ -219,6 +227,7 @@ bool BugDriver::initializeExecutionEnvironment() {
SafeInterpreterSel = RunLLC; SafeInterpreterSel = RunLLC;
SafeToolArgs.push_back("--relocation-model=pic"); SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
GCCBinary,
&SafeToolArgs, &SafeToolArgs,
&GCCToolArgv); &GCCToolArgv);
} }
@@ -230,6 +239,7 @@ bool BugDriver::initializeExecutionEnvironment() {
InterpreterSel != RunCBE) { InterpreterSel != RunCBE) {
SafeInterpreterSel = RunCBE; SafeInterpreterSel = RunCBE;
SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message, SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message,
GCCBinary,
&SafeToolArgs, &SafeToolArgs,
&GCCToolArgv); &GCCToolArgv);
} }
@@ -239,6 +249,7 @@ bool BugDriver::initializeExecutionEnvironment() {
SafeInterpreterSel = RunLLC; SafeInterpreterSel = RunLLC;
SafeToolArgs.push_back("--relocation-model=pic"); SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
GCCBinary,
&SafeToolArgs, &SafeToolArgs,
&GCCToolArgv); &GCCToolArgv);
} }
@@ -251,13 +262,13 @@ bool BugDriver::initializeExecutionEnvironment() {
case RunLLCIA: case RunLLCIA:
SafeToolArgs.push_back("--relocation-model=pic"); SafeToolArgs.push_back("--relocation-model=pic");
SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message, SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
&SafeToolArgs, GCCBinary, &SafeToolArgs,
&GCCToolArgv, &GCCToolArgv,
SafeInterpreterSel == RunLLCIA); SafeInterpreterSel == RunLLCIA);
break; break;
case RunCBE: case RunCBE:
SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message, SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message,
&SafeToolArgs, GCCBinary, &SafeToolArgs,
&GCCToolArgv); &GCCToolArgv);
break; break;
case Custom: case Custom:
@@ -271,7 +282,7 @@ bool BugDriver::initializeExecutionEnvironment() {
} }
if (!SafeInterpreter) { outs() << Message << "\nExiting.\n"; exit(1); } if (!SafeInterpreter) { outs() << Message << "\nExiting.\n"; exit(1); }
gcc = GCC::create(Message, &GCCToolArgv); gcc = GCC::create(Message, GCCBinary, &GCCToolArgv);
if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); } if (!gcc) { outs() << Message << "\nExiting.\n"; exit(1); }
// If there was an error creating the selected interpreter, quit with error. // If there was an error creating the selected interpreter, quit with error.

View File

@@ -413,7 +413,6 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
std::vector<std::string> GCCArgs(ArgsForGCC); std::vector<std::string> GCCArgs(ArgsForGCC);
GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end()); GCCArgs.insert(GCCArgs.end(), SharedLibs.begin(), SharedLibs.end());
GCCArgs.insert(GCCArgs.end(), gccArgs.begin(), gccArgs.end());
// Assuming LLC worked, compile the result with GCC and run it. // Assuming LLC worked, compile the result with GCC and run it.
return gcc->ExecuteProgram(OutputAsmFile.str(), Args, FileKind, return gcc->ExecuteProgram(OutputAsmFile.str(), Args, FileKind,
@@ -425,6 +424,7 @@ int LLC::ExecuteProgram(const std::string &Bitcode,
/// ///
LLC *AbstractInterpreter::createLLC(const char *Argv0, LLC *AbstractInterpreter::createLLC(const char *Argv0,
std::string &Message, std::string &Message,
const std::string &GCCBinary,
const std::vector<std::string> *Args, const std::vector<std::string> *Args,
const std::vector<std::string> *GCCArgs, const std::vector<std::string> *GCCArgs,
bool UseIntegratedAssembler) { bool UseIntegratedAssembler) {
@@ -436,12 +436,12 @@ LLC *AbstractInterpreter::createLLC(const char *Argv0,
} }
Message = "Found llc: " + LLCPath + "\n"; Message = "Found llc: " + LLCPath + "\n";
GCC *gcc = GCC::create(Message, GCCArgs); GCC *gcc = GCC::create(Message, GCCBinary, GCCArgs);
if (!gcc) { if (!gcc) {
errs() << Message << "\n"; errs() << Message << "\n";
exit(1); exit(1);
} }
return new LLC(LLCPath, gcc, Args, GCCArgs, UseIntegratedAssembler); return new LLC(LLCPath, gcc, Args, UseIntegratedAssembler);
} }
//===---------------------------------------------------------------------===// //===---------------------------------------------------------------------===//
@@ -593,6 +593,7 @@ int CBE::ExecuteProgram(const std::string &Bitcode,
/// ///
CBE *AbstractInterpreter::createCBE(const char *Argv0, CBE *AbstractInterpreter::createCBE(const char *Argv0,
std::string &Message, std::string &Message,
const std::string &GCCBinary,
const std::vector<std::string> *Args, const std::vector<std::string> *Args,
const std::vector<std::string> *GCCArgs) { const std::vector<std::string> *GCCArgs) {
sys::Path LLCPath = sys::Path LLCPath =
@@ -604,7 +605,7 @@ CBE *AbstractInterpreter::createCBE(const char *Argv0,
} }
Message = "Found llc: " + LLCPath.str() + "\n"; Message = "Found llc: " + LLCPath.str() + "\n";
GCC *gcc = GCC::create(Message, GCCArgs); GCC *gcc = GCC::create(Message, GCCBinary, GCCArgs);
if (!gcc) { if (!gcc) {
errs() << Message << "\n"; errs() << Message << "\n";
exit(1); exit(1);
@@ -852,10 +853,11 @@ int GCC::MakeSharedObject(const std::string &InputFile, FileType fileType,
/// create - Try to find the `gcc' executable /// create - Try to find the `gcc' executable
/// ///
GCC *GCC::create(std::string &Message, GCC *GCC::create(std::string &Message,
const std::string &GCCBinary,
const std::vector<std::string> *Args) { const std::vector<std::string> *Args) {
sys::Path GCCPath = sys::Program::FindProgramByName("gcc"); sys::Path GCCPath = sys::Program::FindProgramByName(GCCBinary);
if (GCCPath.isEmpty()) { if (GCCPath.isEmpty()) {
Message = "Cannot find `gcc' in executable directory or PATH!\n"; Message = "Cannot find `"+ GCCBinary +"' in executable directory or PATH!\n";
return 0; return 0;
} }

View File

@@ -49,6 +49,7 @@ public:
enum FileType { AsmFile, ObjectFile, CFile }; enum FileType { AsmFile, ObjectFile, CFile };
static GCC *create(std::string &Message, static GCC *create(std::string &Message,
const std::string &GCCBinary,
const std::vector<std::string> *Args); const std::vector<std::string> *Args);
/// ExecuteProgram - Execute the program specified by "ProgramFile" (which is /// ExecuteProgram - Execute the program specified by "ProgramFile" (which is
@@ -87,9 +88,11 @@ public:
class AbstractInterpreter { class AbstractInterpreter {
public: public:
static CBE *createCBE(const char *Argv0, std::string &Message, static CBE *createCBE(const char *Argv0, std::string &Message,
const std::string &GCCBinary,
const std::vector<std::string> *Args = 0, const std::vector<std::string> *Args = 0,
const std::vector<std::string> *GCCArgs = 0); const std::vector<std::string> *GCCArgs = 0);
static LLC *createLLC(const char *Argv0, std::string &Message, static LLC *createLLC(const char *Argv0, std::string &Message,
const std::string &GCCBinary,
const std::vector<std::string> *Args = 0, const std::vector<std::string> *Args = 0,
const std::vector<std::string> *GCCArgs = 0, const std::vector<std::string> *GCCArgs = 0,
bool UseIntegratedAssembler = false); bool UseIntegratedAssembler = false);
@@ -187,19 +190,16 @@ public:
class LLC : public AbstractInterpreter { class LLC : public AbstractInterpreter {
std::string LLCPath; // The path to the LLC executable. std::string LLCPath; // The path to the LLC executable.
std::vector<std::string> ToolArgs; // Extra args to pass to LLC. std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
std::vector<std::string> gccArgs; // Extra args to pass to GCC.
GCC *gcc; GCC *gcc;
bool UseIntegratedAssembler; bool UseIntegratedAssembler;
public: public:
LLC(const std::string &llcPath, GCC *Gcc, LLC(const std::string &llcPath, GCC *Gcc,
const std::vector<std::string> *Args, const std::vector<std::string> *Args,
const std::vector<std::string> *GCCArgs,
bool useIntegratedAssembler) bool useIntegratedAssembler)
: LLCPath(llcPath), gcc(Gcc), : LLCPath(llcPath), gcc(Gcc),
UseIntegratedAssembler(useIntegratedAssembler) { UseIntegratedAssembler(useIntegratedAssembler) {
ToolArgs.clear(); ToolArgs.clear();
if (Args) ToolArgs = *Args; if (Args) ToolArgs = *Args;
if (GCCArgs) gccArgs = *GCCArgs;
} }
~LLC() { delete gcc; } ~LLC() { delete gcc; }