#include "BugDriver.h"
#include "ToolRunner.h"
#include "llvm/Bitcode/BitcodeWriter.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/FileUtilities.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/ToolOutputFile.h"
#define DONT_GET_PLUGIN_LOADER_OPTION
#include "llvm/Support/PluginLoader.h"
usingnamespacellvm;
#define DEBUG_TYPE …
namespace llvm {
extern cl::opt<std::string> OutputPrefix;
}
static cl::opt<bool> PreserveBitcodeUseListOrder(
"preserve-bc-uselistorder",
cl::desc("Preserve use-list order when writing LLVM bitcode."),
cl::init(true), cl::Hidden);
static cl::opt<std::string>
OptCmd("opt-command", cl::init(""),
cl::desc("Path to opt. (default: search path "
"for 'opt'.)"));
static bool writeProgramToFileAux(ToolOutputFile &Out, const Module &M) { … }
bool BugDriver::writeProgramToFile(const std::string &Filename, int FD,
const Module &M) const { … }
bool BugDriver::writeProgramToFile(int FD, const Module &M) const { … }
bool BugDriver::writeProgramToFile(const std::string &Filename,
const Module &M) const { … }
void BugDriver::EmitProgressBitcode(const Module &M, const std::string &ID,
bool NoFlyer) const { … }
cl::opt<bool> SilencePasses(
"silence-passes",
cl::desc("Suppress output of running passes (both stdout and stderr)"));
static cl::list<std::string> OptArgs("opt-args", cl::Positional,
cl::desc("<opt arguments>..."),
cl::PositionalEatsArgs);
bool BugDriver::runPasses(Module &Program,
const std::vector<std::string> &Passes,
std::string &OutputFilename, bool DeleteOutput,
bool Quiet, ArrayRef<std::string> ExtraArgs) const { … }
std::unique_ptr<Module>
BugDriver::runPassesOn(Module *M, const std::vector<std::string> &Passes,
ArrayRef<std::string> ExtraArgs) { … }