Check Attribute::NoInline.
[oota-llvm.git] / tools / lto-bugpoint / lto-bugpoint.cpp
1 //===- lto-bugpoing.cpp - The lto-bugpoint driver -------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
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.
13 //
14 //===----------------------------------------------------------------------===//
15
16 #include "LTOBugPoint.h"
17 #include <iostream>
18 #include <fstream>
19
20 int main(int argc, char **argv) {
21   try {
22
23     if (argc !=  4) {
24       std::cerr << "Invalid number of lto-bugpoint arguments!\n";
25       return 1;
26     }
27     
28     std::ios::openmode input_mode = std::ios::in;
29
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";
36       return 1;
37     }
38
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;
45       return 1;
46     }
47
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);
52
53     llvm::SmallVector<std::string, 4> TroubleMakers;
54     if (!bugFinder.findTroubleMakers(TroubleMakers, ValidationScript)) {
55       std::cerr << "lto-bugpoint:" << bugFinder.getErrMsg() << "\n";
56       return 1;
57     }
58
59     return 0;
60   } catch (const std::string& msg) {
61     std::cerr << argv[0] << ": " << msg << "\n";
62   } catch (...) {
63     std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
64   }
65   return 1;
66 }