5f1b5cce2badafb9afc8c14d33e1784c157fa490
[oota-llvm.git] / tools / lto-bugpoint / LTOBugPoint.h
1 //===- LTOBugPoint.h - Top-Level LTO BugPoint class -------------*- C++ -*-===//
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 "llvm/ADT/SmallVector.h"
16 #include "llvm/Module.h"
17 #include "llvm/System/Path.h"
18 #include <string>
19 #include <fstream>
20
21 class LTOBugPoint {
22  public:
23
24   LTOBugPoint(std::istream &args, std::istream &ins);
25   ~LTOBugPoint();
26
27   /// findTroubleMakers - Find minimum set of input files that causes error
28   /// identified by the script.
29   bool findTroubleMakers(llvm::SmallVector<std::string, 4> &TroubleMakers,
30                         std::string &Script);
31
32   /// getNativeObjectFile - Generate native object file based from llvm
33   /// bitcode file. Return false in case of an error.
34   bool getNativeObjectFile(std::string &FileName);
35
36   std::string &getErrMsg() { return ErrMsg; }
37
38  private:
39   /// LinkerInputFiles - This is a list of linker input files. Once populated
40   /// this list is not modified.
41   llvm::SmallVector<std::string, 16> LinkerInputFiles;
42
43   /// LinkerOptions - List of linker command line options.
44   llvm::SmallVector<std::string, 16> LinkerOptions;
45
46   /// NativeInputFiles - This is a list of input files that are not llvm
47   /// bitcode files. The order in this list is important. The a file
48   /// in LinkerInputFiles at index 4 is a llvm bitcode file then the file
49   /// at index 4 in NativeInputFiles is corresponding native object file.
50   llvm::SmallVector<std::string, 16> NativeInputFiles;
51
52   std::string getFeatureString(const char *TargetTriple);
53   std::string ErrMsg;
54
55   llvm::sys::Path TempDir;
56 private:
57   /// assembleBitcode - Generate assembly code from the module. Return false
58   /// in case of an error.
59   bool assembleBitcode(llvm::Module *M, const char *AsmFileName);
60
61   /// relinkProgram - Relink program. Return false if linking fails.
62   bool relinkProgram(llvm::SmallVector<std::string, 16> &InputFiles);
63
64   /// reproduceProgramError - Validate program using user provided script.
65   bool reproduceProgramError(std::string &Script);
66 };