2002-11-20 22:28:10 +00:00
|
|
|
//===- BugDriver.h - Top-Level BugPoint class -------------------*- C++ -*-===//
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2003-10-20 17:47:21 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:44:31 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-22 00:00:37 +00:00
|
|
|
//
|
2003-10-20 17:47:21 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2002-11-20 22:28:10 +00:00
|
|
|
//
|
|
|
|
// This class contains all of the shared state and information that is used by
|
|
|
|
// the BugPoint tool to track down errors in optimizations. This class is the
|
|
|
|
// main driver class that invokes all sub-functionality.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2014-08-13 16:26:38 +00:00
|
|
|
#ifndef LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
|
|
|
|
#define LLVM_TOOLS_BUGPOINT_BUGDRIVER_H
|
2002-11-20 22:28:10 +00:00
|
|
|
|
2014-03-04 11:26:31 +00:00
|
|
|
#include "llvm/IR/ValueMap.h"
|
2010-10-13 01:36:30 +00:00
|
|
|
#include "llvm/Transforms/Utils/ValueMapper.h"
|
2014-08-26 17:19:03 +00:00
|
|
|
#include <memory>
|
2002-11-20 22:28:10 +00:00
|
|
|
#include <string>
|
2012-12-04 10:44:52 +00:00
|
|
|
#include <vector>
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2009-04-22 15:57:18 +00:00
|
|
|
class Value;
|
2010-07-20 08:26:15 +00:00
|
|
|
class PassInfo;
|
2002-11-20 22:28:10 +00:00
|
|
|
class Module;
|
2006-10-25 18:36:14 +00:00
|
|
|
class GlobalVariable;
|
2002-11-20 22:28:10 +00:00
|
|
|
class Function;
|
2004-05-11 21:54:13 +00:00
|
|
|
class BasicBlock;
|
2002-12-23 23:49:59 +00:00
|
|
|
class AbstractInterpreter;
|
2003-01-23 02:48:33 +00:00
|
|
|
class Instruction;
|
2009-08-11 17:45:13 +00:00
|
|
|
class LLVMContext;
|
2002-11-20 22:28:10 +00:00
|
|
|
|
2003-04-24 22:24:58 +00:00
|
|
|
class DebugCrashes;
|
2003-04-24 17:02:17 +00:00
|
|
|
|
2003-07-24 21:59:10 +00:00
|
|
|
class GCC;
|
|
|
|
|
2003-08-05 15:51:05 +00:00
|
|
|
extern bool DisableSimplifyCFG;
|
|
|
|
|
2005-08-02 02:16:17 +00:00
|
|
|
/// BugpointIsInterrupted - Set to true when the user presses ctrl-c.
|
|
|
|
///
|
|
|
|
extern bool BugpointIsInterrupted;
|
|
|
|
|
2002-11-20 22:28:10 +00:00
|
|
|
class BugDriver {
|
2009-07-01 23:13:44 +00:00
|
|
|
LLVMContext& Context;
|
2009-08-05 20:21:17 +00:00
|
|
|
const char *ToolName; // argv[0] of bugpoint
|
2003-07-24 21:59:10 +00:00
|
|
|
std::string ReferenceOutputFile; // Name of `good' output file
|
2002-11-20 22:28:10 +00:00
|
|
|
Module *Program; // The raw program, linked together
|
2010-08-08 03:55:08 +00:00
|
|
|
std::vector<std::string> PassesToRun;
|
2002-12-23 23:49:59 +00:00
|
|
|
AbstractInterpreter *Interpreter; // How to run the program
|
2008-12-08 04:02:47 +00:00
|
|
|
AbstractInterpreter *SafeInterpreter; // To generate reference output, etc.
|
2003-07-24 21:59:10 +00:00
|
|
|
GCC *gcc;
|
2006-08-15 16:40:49 +00:00
|
|
|
bool run_find_bugs;
|
2006-06-13 03:10:48 +00:00
|
|
|
unsigned Timeout;
|
2007-02-16 19:11:07 +00:00
|
|
|
unsigned MemoryLimit;
|
2010-03-19 00:09:28 +00:00
|
|
|
bool UseValgrind;
|
2003-04-24 17:02:17 +00:00
|
|
|
|
2003-04-24 22:24:58 +00:00
|
|
|
// FIXME: sort out public/private distinctions...
|
2004-02-18 21:24:48 +00:00
|
|
|
friend class ReducePassList;
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
friend class ReduceMisCodegenFunctions;
|
|
|
|
|
2002-11-20 22:28:10 +00:00
|
|
|
public:
|
2010-08-07 23:03:21 +00:00
|
|
|
BugDriver(const char *toolname, bool find_bugs,
|
2010-03-19 00:09:28 +00:00
|
|
|
unsigned timeout, unsigned memlimit, bool use_valgrind,
|
|
|
|
LLVMContext& ctxt);
|
2010-03-22 05:23:37 +00:00
|
|
|
~BugDriver();
|
2002-12-23 23:49:59 +00:00
|
|
|
|
2009-08-05 20:21:17 +00:00
|
|
|
const char *getToolName() const { return ToolName; }
|
2002-11-20 22:28:10 +00:00
|
|
|
|
2010-08-05 02:16:32 +00:00
|
|
|
LLVMContext& getContext() const { return Context; }
|
2009-07-01 16:58:40 +00:00
|
|
|
|
2002-11-20 22:28:10 +00:00
|
|
|
// Set up methods... these methods are used to copy information about the
|
|
|
|
// command line arguments into instance variables of BugDriver.
|
|
|
|
//
|
|
|
|
bool addSources(const std::vector<std::string> &FileNames);
|
2010-08-08 03:55:08 +00:00
|
|
|
void addPass(std::string p) { PassesToRun.push_back(p); }
|
|
|
|
void setPassesToRun(const std::vector<std::string> &PTR) {
|
2003-10-17 23:03:16 +00:00
|
|
|
PassesToRun = PTR;
|
|
|
|
}
|
2010-08-08 03:55:08 +00:00
|
|
|
const std::vector<std::string> &getPassesToRun() const {
|
2004-03-14 20:50:42 +00:00
|
|
|
return PassesToRun;
|
|
|
|
}
|
2002-11-20 22:28:10 +00:00
|
|
|
|
|
|
|
/// run - The top level method that is invoked after all of the instance
|
2005-12-22 20:02:55 +00:00
|
|
|
/// variables are set up from command line arguments. The \p as_child argument
|
|
|
|
/// indicates whether the driver is to run in parent mode or child mode.
|
2002-11-20 22:28:10 +00:00
|
|
|
///
|
2010-04-12 05:08:25 +00:00
|
|
|
bool run(std::string &ErrMsg);
|
2002-11-20 22:28:10 +00:00
|
|
|
|
2004-02-18 21:02:04 +00:00
|
|
|
/// debugOptimizerCrash - This method is called when some optimizer pass
|
|
|
|
/// crashes on input. It attempts to prune down the testcase to something
|
|
|
|
/// reasonable, and figure out exactly which pass is crashing.
|
2002-11-20 22:28:10 +00:00
|
|
|
///
|
2006-08-15 16:40:49 +00:00
|
|
|
bool debugOptimizerCrash(const std::string &ID = "passes");
|
2005-04-22 00:00:37 +00:00
|
|
|
|
2004-02-18 21:02:04 +00:00
|
|
|
/// debugCodeGeneratorCrash - This method is called when the code generator
|
|
|
|
/// crashes on an input. It attempts to reduce the input as much as possible
|
|
|
|
/// while still causing the code generator to crash.
|
2010-04-12 05:08:25 +00:00
|
|
|
bool debugCodeGeneratorCrash(std::string &Error);
|
2002-11-20 22:28:10 +00:00
|
|
|
|
|
|
|
/// debugMiscompilation - This method is used when the passes selected are not
|
|
|
|
/// crashing, but the generated output is semantically different from the
|
|
|
|
/// input.
|
2010-04-12 05:08:25 +00:00
|
|
|
void debugMiscompilation(std::string *Error);
|
2002-11-20 22:28:10 +00:00
|
|
|
|
2002-12-23 23:49:59 +00:00
|
|
|
/// debugPassMiscompilation - This method is called when the specified pass
|
|
|
|
/// miscompiles Program as input. It tries to reduce the testcase to
|
|
|
|
/// something that smaller that still miscompiles the program.
|
|
|
|
/// ReferenceOutput contains the filename of the file containing the output we
|
|
|
|
/// are to match.
|
|
|
|
///
|
2010-07-20 08:26:15 +00:00
|
|
|
bool debugPassMiscompilation(const PassInfo *ThePass,
|
2005-04-22 04:13:13 +00:00
|
|
|
const std::string &ReferenceOutput);
|
2002-12-23 23:49:59 +00:00
|
|
|
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
/// compileSharedObject - This method creates a SharedObject from a given
|
2007-07-04 21:55:50 +00:00
|
|
|
/// BitcodeFile for debugging a code generator.
|
2003-10-14 21:09:11 +00:00
|
|
|
///
|
2010-04-12 05:08:25 +00:00
|
|
|
std::string compileSharedObject(const std::string &BitcodeFile,
|
|
|
|
std::string &Error);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
|
|
|
|
/// debugCodeGenerator - This method narrows down a module to a function or
|
|
|
|
/// set of functions, using the CBE as a ``safe'' code generator for other
|
|
|
|
/// functions that are not under consideration.
|
2010-04-12 05:08:25 +00:00
|
|
|
bool debugCodeGenerator(std::string *Error);
|
Major addition to bugpoint: ability to debug code generators (LLC and LLI).
The C backend is assumed correct and is used to generate shared objects to be
loaded by the other two code generators.
LLC debugging should be functional now, LLI needs a few more additions to work,
the major one is renaming of external functions to call the JIT lazy function
resolver.
Bugpoint now has a command-line switch -mode with options 'compile' and
'codegen' to debug appropriate portions of tools.
ExecutionDriver.cpp: Added implementations of AbstractInterpreter for LLC and
GCC, broke out common code within other tools, and added ability to generate C
code with CBE individually, without executing the program, and the GCC tool can
generate executables shared objects or executables.
If no reference output is specified to Bugpoint, it will be generated with CBE,
because it is already assumed to be correct for the purposes of debugging using
this method. As a result, many functions now accept as an optional parameter a
shared object to be loaded in, if specified.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7293 91177308-0d34-0410-b5e6-96231b3b80d8
2003-07-24 18:17:43 +00:00
|
|
|
|
2003-07-28 20:59:16 +00:00
|
|
|
/// isExecutingJIT - Returns true if bugpoint is currently testing the JIT
|
|
|
|
///
|
2003-07-28 19:16:14 +00:00
|
|
|
bool isExecutingJIT();
|
|
|
|
|
2004-02-18 21:24:48 +00:00
|
|
|
/// runPasses - Run all of the passes in the "PassesToRun" list, discard the
|
|
|
|
/// output, and return true if any of the passes crashed.
|
2010-08-05 02:16:32 +00:00
|
|
|
bool runPasses(Module *M) const {
|
|
|
|
return runPasses(M, PassesToRun);
|
2004-02-18 21:24:48 +00:00
|
|
|
}
|
|
|
|
|
2004-03-14 20:50:42 +00:00
|
|
|
Module *getProgram() const { return Program; }
|
|
|
|
|
|
|
|
/// swapProgramIn - Set the current module to the specified module, returning
|
|
|
|
/// the old one.
|
|
|
|
Module *swapProgramIn(Module *M) {
|
|
|
|
Module *OldProgram = Program;
|
|
|
|
Program = M;
|
|
|
|
return OldProgram;
|
|
|
|
}
|
2004-02-18 21:24:48 +00:00
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
AbstractInterpreter *switchToSafeInterpreter() {
|
2004-04-05 22:58:16 +00:00
|
|
|
AbstractInterpreter *Old = Interpreter;
|
2008-12-08 04:02:47 +00:00
|
|
|
Interpreter = (AbstractInterpreter*)SafeInterpreter;
|
2004-04-05 22:58:16 +00:00
|
|
|
return Old;
|
|
|
|
}
|
|
|
|
|
|
|
|
void switchToInterpreter(AbstractInterpreter *AI) {
|
|
|
|
Interpreter = AI;
|
|
|
|
}
|
2005-04-22 00:00:37 +00:00
|
|
|
|
2004-02-18 21:24:48 +00:00
|
|
|
/// setNewProgram - If we reduce or update the program somehow, call this
|
|
|
|
/// method to update bugdriver with it. This deletes the old module and sets
|
|
|
|
/// the specified one as the current program.
|
|
|
|
void setNewProgram(Module *M);
|
|
|
|
|
2010-04-12 05:08:25 +00:00
|
|
|
/// compileProgram - Try to compile the specified module, returning false and
|
|
|
|
/// setting Error if an error occurs. This is used for code generation
|
|
|
|
/// crash testing.
|
2004-02-18 23:25:22 +00:00
|
|
|
///
|
2010-08-05 03:00:22 +00:00
|
|
|
void compileProgram(Module *M, std::string *Error) const;
|
2004-02-18 23:25:22 +00:00
|
|
|
|
2004-02-18 21:35:28 +00:00
|
|
|
/// executeProgram - This method runs "Program", capturing the output of the
|
2010-04-14 04:40:31 +00:00
|
|
|
/// program to a file. A recommended filename may be optionally specified.
|
2004-02-18 21:35:28 +00:00
|
|
|
///
|
2010-07-30 14:19:00 +00:00
|
|
|
std::string executeProgram(const Module *Program,
|
|
|
|
std::string OutputFilename,
|
2010-04-12 05:08:25 +00:00
|
|
|
std::string Bitcode,
|
|
|
|
const std::string &SharedObjects,
|
|
|
|
AbstractInterpreter *AI,
|
2010-07-31 14:34:49 +00:00
|
|
|
std::string *Error) const;
|
2004-02-18 21:35:28 +00:00
|
|
|
|
2008-12-08 04:02:47 +00:00
|
|
|
/// executeProgramSafely - Used to create reference output with the "safe"
|
2004-02-18 21:35:28 +00:00
|
|
|
/// backend, if reference output is not provided. If there is a problem with
|
2010-04-12 05:08:25 +00:00
|
|
|
/// the code generator (e.g., llc crashes), this will return false and set
|
|
|
|
/// Error.
|
2004-02-18 21:35:28 +00:00
|
|
|
///
|
2010-07-30 14:19:00 +00:00
|
|
|
std::string executeProgramSafely(const Module *Program,
|
2010-07-31 14:34:49 +00:00
|
|
|
std::string OutputFile,
|
|
|
|
std::string *Error) const;
|
2004-02-18 21:35:28 +00:00
|
|
|
|
2006-08-15 16:40:49 +00:00
|
|
|
/// createReferenceFile - calls compileProgram and then records the output
|
|
|
|
/// into ReferenceOutputFile. Returns true if reference file created, false
|
|
|
|
/// otherwise. Note: initializeExecutionEnvironment should be called BEFORE
|
|
|
|
/// this function.
|
|
|
|
///
|
2006-08-17 18:51:28 +00:00
|
|
|
bool createReferenceFile(Module *M, const std::string &Filename
|
2013-06-28 16:37:52 +00:00
|
|
|
= "bugpoint.reference.out-%%%%%%%");
|
2006-08-15 16:40:49 +00:00
|
|
|
|
2004-02-18 21:35:28 +00:00
|
|
|
/// diffProgram - This method executes the specified module and diffs the
|
|
|
|
/// output against the file specified by ReferenceOutputFile. If the output
|
2010-04-12 05:08:25 +00:00
|
|
|
/// is different, 1 is returned. If there is a problem with the code
|
|
|
|
/// generator (e.g., llc crashes), this will return -1 and set Error.
|
2004-02-18 21:35:28 +00:00
|
|
|
///
|
2010-07-30 14:19:00 +00:00
|
|
|
bool diffProgram(const Module *Program,
|
|
|
|
const std::string &BitcodeFile = "",
|
2004-02-18 21:35:28 +00:00
|
|
|
const std::string &SharedObj = "",
|
2010-04-12 05:08:25 +00:00
|
|
|
bool RemoveBitcode = false,
|
2014-04-28 04:05:08 +00:00
|
|
|
std::string *Error = nullptr) const;
|
2010-04-12 05:08:25 +00:00
|
|
|
|
2010-07-28 18:12:30 +00:00
|
|
|
/// EmitProgressBitcode - This function is used to output M to a file named
|
|
|
|
/// "bugpoint-ID.bc".
|
2004-02-18 21:50:26 +00:00
|
|
|
///
|
2010-07-28 18:12:30 +00:00
|
|
|
void EmitProgressBitcode(const Module *M, const std::string &ID,
|
2010-08-05 00:29:04 +00:00
|
|
|
bool NoFlyer = false) const;
|
2004-02-18 21:50:26 +00:00
|
|
|
|
2014-08-26 17:19:03 +00:00
|
|
|
/// This method clones the current Program and deletes the specified
|
|
|
|
/// instruction from the cloned module. It then runs a series of cleanup
|
|
|
|
/// passes (ADCE and SimplifyCFG) to eliminate any code which depends on the
|
|
|
|
/// value. The modified module is then returned.
|
2004-02-18 21:50:26 +00:00
|
|
|
///
|
2014-08-26 17:19:03 +00:00
|
|
|
std::unique_ptr<Module> deleteInstructionFromProgram(const Instruction *I,
|
|
|
|
unsigned Simp);
|
2004-02-18 21:50:26 +00:00
|
|
|
|
2014-08-26 17:19:03 +00:00
|
|
|
/// This method clones the current Program and performs a series of cleanups
|
|
|
|
/// intended to get rid of extra cruft on the module. If the
|
|
|
|
/// MayModifySemantics argument is true, then the cleanups is allowed to
|
2004-02-18 21:50:26 +00:00
|
|
|
/// modify how the code behaves.
|
|
|
|
///
|
2014-08-26 17:19:03 +00:00
|
|
|
std::unique_ptr<Module> performFinalCleanups(Module *M,
|
|
|
|
bool MayModifySemantics = false);
|
|
|
|
|
|
|
|
/// Given a module, extract up to one loop from it into a new function. This
|
|
|
|
/// returns null if there are no extractable loops in the program or if the
|
|
|
|
/// loop extractor crashes.
|
|
|
|
std::unique_ptr<Module> extractLoop(Module *M);
|
|
|
|
|
|
|
|
/// Extract all but the specified basic blocks into their own functions. The
|
|
|
|
/// only detail is that M is actually a module cloned from the one the BBs are
|
|
|
|
/// in, so some mapping needs to be performed. If this operation fails for
|
|
|
|
/// some reason (ie the implementation is buggy), this function should return
|
|
|
|
/// null, otherwise it returns a new Module.
|
|
|
|
std::unique_ptr<Module>
|
|
|
|
extractMappedBlocksFromModule(const std::vector<BasicBlock *> &BBs,
|
|
|
|
Module *M);
|
|
|
|
|
|
|
|
/// Carefully run the specified set of pass on the specified/ module,
|
|
|
|
/// returning the transformed module on success, or a null pointer on failure.
|
|
|
|
/// If AutoDebugCrashes is set to true, then bugpoint will automatically
|
|
|
|
/// attempt to track down a crashing pass if one exists, and this method will
|
|
|
|
/// never return null.
|
|
|
|
std::unique_ptr<Module> runPassesOn(Module *M,
|
|
|
|
const std::vector<std::string> &Passes,
|
|
|
|
bool AutoDebugCrashes = false,
|
|
|
|
unsigned NumExtraArgs = 0,
|
|
|
|
const char *const *ExtraArgs = nullptr);
|
2004-03-14 21:17:03 +00:00
|
|
|
|
2007-07-04 21:55:50 +00:00
|
|
|
/// runPasses - Run the specified passes on Program, outputting a bitcode
|
2002-11-20 22:28:10 +00:00
|
|
|
/// file and writting the filename into OutputFile if successful. If the
|
|
|
|
/// optimizations fail for some reason (optimizer crashes), return true,
|
2007-07-04 21:55:50 +00:00
|
|
|
/// otherwise return false. If DeleteOutput is set to true, the bitcode is
|
2002-11-20 22:28:10 +00:00
|
|
|
/// deleted on success, and the filename string is undefined. This prints to
|
2009-07-16 15:30:09 +00:00
|
|
|
/// outs() a single line message indicating whether compilation was successful
|
2007-11-14 06:47:06 +00:00
|
|
|
/// or failed, unless Quiet is set. ExtraArgs specifies additional arguments
|
|
|
|
/// to pass to the child bugpoint instance.
|
2002-11-20 22:28:10 +00:00
|
|
|
///
|
2010-08-05 00:29:04 +00:00
|
|
|
bool runPasses(Module *Program,
|
2010-08-08 03:55:08 +00:00
|
|
|
const std::vector<std::string> &PassesToRun,
|
2002-12-23 23:49:59 +00:00
|
|
|
std::string &OutputFilename, bool DeleteOutput = false,
|
2007-11-14 06:47:06 +00:00
|
|
|
bool Quiet = false, unsigned NumExtraArgs = 0,
|
2014-04-28 04:05:08 +00:00
|
|
|
const char * const *ExtraArgs = nullptr) const;
|
2006-08-15 16:40:49 +00:00
|
|
|
|
|
|
|
/// runManyPasses - Take the specified pass list and create different
|
|
|
|
/// combinations of passes to compile the program with. Compile the program with
|
|
|
|
/// each set and mark test to see if it compiled correctly. If the passes
|
|
|
|
/// compiled correctly output nothing and rearrange the passes into a new order.
|
|
|
|
/// If the passes did not compile correctly, output the command required to
|
|
|
|
/// recreate the failure. This returns true if a compiler error is found.
|
|
|
|
///
|
2010-08-08 03:55:08 +00:00
|
|
|
bool runManyPasses(const std::vector<std::string> &AllPasses,
|
2010-07-12 08:16:59 +00:00
|
|
|
std::string &ErrMsg);
|
2004-04-05 22:01:48 +00:00
|
|
|
|
2004-03-14 20:50:42 +00:00
|
|
|
/// writeProgramToFile - This writes the current "Program" to the named
|
2007-07-04 21:55:50 +00:00
|
|
|
/// bitcode file. If an error occurs, true is returned.
|
2004-03-14 20:50:42 +00:00
|
|
|
///
|
2010-07-28 18:12:30 +00:00
|
|
|
bool writeProgramToFile(const std::string &Filename, const Module *M) const;
|
2013-06-18 15:29:32 +00:00
|
|
|
bool writeProgramToFile(const std::string &Filename, int FD,
|
|
|
|
const Module *M) const;
|
2002-11-20 22:28:10 +00:00
|
|
|
|
2004-04-05 22:01:48 +00:00
|
|
|
private:
|
2002-11-20 22:28:10 +00:00
|
|
|
/// runPasses - Just like the method above, but this just returns true or
|
|
|
|
/// false indicating whether or not the optimizer crashed on the specified
|
|
|
|
/// input (true = crashed).
|
|
|
|
///
|
2010-08-05 02:16:32 +00:00
|
|
|
bool runPasses(Module *M,
|
2010-08-08 03:55:08 +00:00
|
|
|
const std::vector<std::string> &PassesToRun,
|
2002-11-20 22:28:10 +00:00
|
|
|
bool DeleteOutput = true) const {
|
|
|
|
std::string Filename;
|
2010-08-05 02:16:32 +00:00
|
|
|
return runPasses(M, PassesToRun, Filename, DeleteOutput);
|
2002-11-20 22:28:10 +00:00
|
|
|
}
|
|
|
|
|
2002-12-23 23:49:59 +00:00
|
|
|
/// initializeExecutionEnvironment - This method is used to set up the
|
|
|
|
/// environment for executing LLVM programs.
|
|
|
|
///
|
|
|
|
bool initializeExecutionEnvironment();
|
2002-11-20 22:28:10 +00:00
|
|
|
};
|
|
|
|
|
2014-08-26 17:19:03 +00:00
|
|
|
/// Given a bitcode or assembly input filename, parse and return it, or return
|
|
|
|
/// null if not possible.
|
2004-03-14 20:50:42 +00:00
|
|
|
///
|
2014-08-26 17:19:03 +00:00
|
|
|
std::unique_ptr<Module> parseInputFile(StringRef InputFilename,
|
|
|
|
LLVMContext &ctxt);
|
2004-03-14 20:50:42 +00:00
|
|
|
|
2003-04-24 17:02:17 +00:00
|
|
|
/// getPassesString - Turn a list of passes into a string which indicates the
|
|
|
|
/// command line options that must be passed to add the passes.
|
|
|
|
///
|
2010-08-08 03:55:08 +00:00
|
|
|
std::string getPassesString(const std::vector<std::string> &Passes);
|
2003-04-24 17:02:17 +00:00
|
|
|
|
2004-03-14 20:50:42 +00:00
|
|
|
/// PrintFunctionList - prints out list of problematic functions
|
|
|
|
///
|
|
|
|
void PrintFunctionList(const std::vector<Function*> &Funcs);
|
|
|
|
|
2006-10-25 18:36:14 +00:00
|
|
|
/// PrintGlobalVariableList - prints out list of problematic global variables
|
|
|
|
///
|
|
|
|
void PrintGlobalVariableList(const std::vector<GlobalVariable*> &GVs);
|
|
|
|
|
2003-04-24 22:24:58 +00:00
|
|
|
// DeleteFunctionBody - "Remove" the function by deleting all of it's basic
|
|
|
|
// blocks, making it external.
|
|
|
|
//
|
|
|
|
void DeleteFunctionBody(Function *F);
|
|
|
|
|
2004-03-14 19:27:19 +00:00
|
|
|
/// SplitFunctionsOutOfModule - Given a module and a list of functions in the
|
|
|
|
/// module, split the functions OUT of the specified module, and place them in
|
|
|
|
/// the new module.
|
2009-04-22 15:57:18 +00:00
|
|
|
Module *SplitFunctionsOutOfModule(Module *M, const std::vector<Function*> &F,
|
2010-10-13 01:36:30 +00:00
|
|
|
ValueToValueMapTy &VMap);
|
2004-03-14 19:27:19 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-11-20 22:28:10 +00:00
|
|
|
#endif
|