//===- BugDriver.cpp - Top-Level BugPoint class implementation ------------===// // // 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 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. // //===----------------------------------------------------------------------===// #include "BugDriver.h" #include "ToolRunner.h" #include "llvm/IR/Module.h" #include "llvm/IR/Verifier.h" #include "llvm/IRReader/IRReader.h" #include "llvm/Linker/Linker.h" #include "llvm/Pass.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/FileUtilities.h" #include "llvm/Support/SourceMgr.h" #include "llvm/Support/raw_ostream.h" #include "llvm/TargetParser/Host.h" #include <memory> usingnamespacellvm; namespace llvm { Triple TargetTriple; } DiscardTemp::~DiscardTemp() { … } // Anonymous namespace to define command line options for debugging. // namespace { // Output - The user can specify a file containing the expected output of the // program. If this filename is set, it is used as the reference diff source, // otherwise the raw input run through an interpreter is used as the reference // source. // cl::opt<std::string> OutputFile("output", cl::desc("Specify a reference program output " "(for miscompilation detection)")); } /// 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 BugDriver::setNewProgram(std::unique_ptr<Module> M) { … } /// getPassesString - Turn a list of passes into a string which indicates the /// command line options that must be passed to add the passes. /// std::string llvm::getPassesString(const std::vector<std::string> &Passes) { … } BugDriver::BugDriver(const char *toolname, bool find_bugs, unsigned timeout, unsigned memlimit, bool use_valgrind, LLVMContext &ctxt) : … { … } BugDriver::~BugDriver() { … } std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename, LLVMContext &Ctxt) { … } std::unique_ptr<Module> BugDriver::swapProgramIn(std::unique_ptr<Module> M) { … } // This method takes the specified list of LLVM input files, attempts to load // them, either as assembly or bitcode, then link them together. It returns // true on failure (if, for example, an input bitcode file could not be // parsed), and false on success. // bool BugDriver::addSources(const std::vector<std::string> &Filenames) { … } /// run - The top level method that is invoked after all of the instance /// variables are set up from command line arguments. /// Error BugDriver::run() { … } void llvm::PrintFunctionList(const std::vector<Function *> &Funcs) { … } void llvm::PrintGlobalVariableList(const std::vector<GlobalVariable *> &GVs) { … }