Devang Patel | 8e450f0 | 2008-07-18 22:59:45 +0000 | [diff] [blame] | 1 | //===- LTOBugPoint.cpp - Top-Level LTO BugPoint class ---------------------===// |
| 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 | // This class contains all of the shared state and information that is used by |
| 11 | // the LTO BugPoint tool to track down bit code files that cause errors. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #include "LTOBugPoint.h" |
Devang Patel | 0597667 | 2008-07-18 23:46:41 +0000 | [diff] [blame^] | 16 | #include "llvm/Support/SystemUtils.h" |
| 17 | #include "llvm/System/Path.h" |
| 18 | #include <iostream> |
Devang Patel | 8e450f0 | 2008-07-18 22:59:45 +0000 | [diff] [blame] | 19 | |
Devang Patel | 0597667 | 2008-07-18 23:46:41 +0000 | [diff] [blame^] | 20 | /// LTOBugPoint -- Constructor. Popuate list of linker options and |
| 21 | /// list of linker input files. |
Devang Patel | 8e450f0 | 2008-07-18 22:59:45 +0000 | [diff] [blame] | 22 | LTOBugPoint::LTOBugPoint(std::istream &args, std::istream &ins) { |
| 23 | |
| 24 | // Read linker options. Order is important here. |
| 25 | std::string option; |
| 26 | while (getline(args, option)) |
| 27 | LinkerOptions.push_back(option); |
| 28 | |
| 29 | // Read linker input files. Order is important here. |
| 30 | std::string inFile; |
| 31 | while(getline(ins, inFile)) |
| 32 | LinkerInputFiles.push_back(inFile); |
| 33 | } |
Devang Patel | 0597667 | 2008-07-18 23:46:41 +0000 | [diff] [blame^] | 34 | |
| 35 | /// findTroubleMakers - Find minimum set of input files that causes error |
| 36 | /// identified by the script. |
| 37 | bool |
| 38 | LTOBugPoint::findTroubleMakers(llvm::SmallVector<std::string, 4> &TroubleMakers, |
| 39 | std::string &Script) { |
| 40 | |
| 41 | // First, build native object files set. |
| 42 | bool bitcodeFileSeen = false; |
| 43 | for(llvm::SmallVector<std::string, 16>::iterator I = LinkerInputFiles.begin(), |
| 44 | E = LinkerInputFiles.end(); I != E; ++I) { |
| 45 | std::string &path = *I; |
| 46 | if (llvm::sys::Path(path.c_str()).isBitcodeFile()) |
| 47 | bitcodeFileSeen = true; |
| 48 | } |
| 49 | |
| 50 | if (!bitcodeFileSeen) { |
| 51 | std::cerr << "lto-bugpoint: Error: Unable to help!"; |
| 52 | std::cerr << " Need at least one input file that contains llvm bitcode\n"; |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | return true; |
| 57 | } |