blob: 925ab9e1acb7a2091620037ae1fcb5b915a1fafd [file] [log] [blame]
Devang Patel8e450f02008-07-18 22:59:45 +00001//===- 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 Patel05976672008-07-18 23:46:41 +000016#include "llvm/Support/SystemUtils.h"
17#include "llvm/System/Path.h"
18#include <iostream>
Devang Patel8e450f02008-07-18 22:59:45 +000019
Devang Patel05976672008-07-18 23:46:41 +000020/// LTOBugPoint -- Constructor. Popuate list of linker options and
21/// list of linker input files.
Devang Patel8e450f02008-07-18 22:59:45 +000022LTOBugPoint::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 Patel05976672008-07-18 23:46:41 +000034
35/// findTroubleMakers - Find minimum set of input files that causes error
36/// identified by the script.
37bool
38LTOBugPoint::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}