llvm/llvm/tools/bugpoint/OptimizerDriver.cpp

//===- OptimizerDriver.cpp - Allow BugPoint to run passes safely ----------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
//
// This file defines an interface that allows bugpoint to run various passes
// without the threat of a buggy pass corrupting bugpoint (of course, bugpoint
// may have its own bugs, but that's another story...).  It achieves this by
// forking a copy of itself and having the child process do the optimizations.
// If this client dies, we can always fork a new one.  :)
//
//===----------------------------------------------------------------------===//

#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'.)"));

/// This writes the current "Program" to the named bitcode file.  If an error
/// occurs, true is returned.
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 {}

/// This function is used to output the current Program to a file named
/// "bugpoint-ID.bc".
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);

/// runPasses - Run the specified passes on Program, outputting a bitcode file
/// and writing the filename into OutputFile if successful.  If the
/// optimizations fail for some reason (optimizer crashes), return true,
/// otherwise return false.  If DeleteOutput is set to true, the bitcode is
/// deleted on success, and the filename string is undefined.  This prints to
/// outs() a single line message indicating whether compilation was successful
/// or failed.
///
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) {}