1 //===- lto-bugpoing.cpp - The lto-bugpoint driver -------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // lto-bugpoint tool identifies minmal set of bitcode files that is causing
11 // failure when Link Time Optimization is enabled. The failure is identified
12 // using developer provided validation script.
14 //===----------------------------------------------------------------------===//
16 #include "LTOBugPoint.h"
20 int main(int argc, char **argv) {
24 std::cerr << "Invalid number of lto-bugpoint arguments!\n";
28 std::ios::openmode input_mode = std::ios::in;
30 // First argument is linker command line options file. This text file
31 // is a list of linker command line options, one option per line.
32 // First line always list the absolute path to invoke the linker.
33 std::istream *LinkerArgsFile = new std::ifstream(argv[1], input_mode);
34 if (!LinkerArgsFile->good()) {
35 std::cerr << argv[0] << ": error opening " << argv[1] << "!\n";
39 // Second argment is a text file that includes the linker input
40 // file paths, one input file path per line.
41 std::istream *LinkerInputsFile = new std::ifstream(argv[2], input_mode);
42 if (!LinkerInputsFile->good()) {
43 std::cerr << argv[0] << ": error opening " << argv[2] << "!\n";
44 delete LinkerArgsFile;
48 // Third argument is absolute path to the validation script. This
49 // script is used to validate LTO error under investigation.
50 std::string ValidationScript = argv[3];
51 LTOBugPoint bugFinder(*LinkerArgsFile, *LinkerInputsFile);
53 llvm::SmallVector<std::string, 4> TroubleMakers;
54 if (!bugFinder.findTroubleMakers(TroubleMakers, ValidationScript)) {
55 std::cerr << "lto-bugpoint:" << bugFinder.getErrMsg() << "\n";
60 } catch (const std::string& msg) {
61 std::cerr << argv[0] << ": " << msg << "\n";
63 std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";