Add some comments explaining the meaning of a boolean
[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/ADT/BitVector.h"
17 #include "llvm/Module.h"
18 #include "llvm/System/Path.h"
19 #include <string>
20 #include <fstream>
21
22 class LTOBugPoint {
23  public:
24
25   LTOBugPoint(std::istream &args, std::istream &ins);
26   ~LTOBugPoint();
27
28   /// findTroubleMakers - Find minimum set of input files that causes error
29   /// identified by the script.
30   bool findTroubleMakers(llvm::SmallVector<std::string, 4> &TroubleMakers,
31                         std::string &Script);
32
33   /// getNativeObjectFile - Generate native object file based from llvm
34   /// bitcode file. Return false in case of an error. Generated native
35   /// object file is inserted in to the NativeInputFiles list.
36   bool getNativeObjectFile(std::string &FileName);
37
38   std::string &getErrMsg() { return ErrMsg; }
39
40  private:
41   /// LinkerInputFiles - This is a list of linker input files. Once populated
42   /// this list is not modified.
43   llvm::SmallVector<std::string, 16> LinkerInputFiles;
44
45   /// LinkerOptions - List of linker command line options.
46   llvm::SmallVector<std::string, 16> LinkerOptions;
47
48   /// NativeInputFiles - This is a list of input files that are not llvm
49   /// bitcode files. The order in this list is important. The a file
50   /// in LinkerInputFiles at index 4 is a llvm bitcode file then the file
51   /// at index 4 in NativeInputFiles is corresponding native object file.
52   llvm::SmallVector<std::string, 16> NativeInputFiles;
53
54   /// BCFiles - This bit vector tracks input bitcode files.
55   llvm::BitVector BCFiles;
56
57   /// ConfirmedClean - This bit vector tracks input files that are confirmed
58   /// to be clean.
59   llvm::BitVector ConfirmedClean;
60
61   /// ConfirmedGuilty - This bit vector tracks input files that are confirmed
62   /// to contribute to the bug being investigated.
63   llvm::BitVector ConfirmedGuilty;
64   std::string getFeatureString(const char *TargetTriple);
65   std::string ErrMsg;
66
67   llvm::sys::Path TempDir;
68
69   /// findLinkingFailure - If true, investigate link failure bugs when
70   /// one or more linker input files are llvm bitcode files. If false,
71   /// investigate optimization or code generation bugs in LTO mode.
72   bool findLinkingFailure;
73
74 private:
75   /// assembleBitcode - Generate assembly code from the module. Return false
76   /// in case of an error.
77   bool assembleBitcode(llvm::Module *M, const char *AsmFileName);
78
79   /// relinkProgram - Relink program. Return false if linking fails.
80   bool relinkProgram(llvm::SmallVector<std::string, 16> &InputFiles);
81
82   /// reproduceProgramError - Validate program using user provided script.
83   bool reproduceProgramError(std::string &Script);
84
85   /// identifyTroubleMakers - Identify set of inputs from the given 
86   /// bitvector that are causing the bug under investigation.
87   void identifyTroubleMakers(llvm::BitVector &In);
88 };