blob: 417912430966f047f185dcd8cd90694d3d530ed0 [file] [log] [blame]
Devang Patele330f2d2008-07-18 22:59:45 +00001//===- 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"
Devang Patelcfb54102008-07-24 00:34:11 +000016#include "llvm/ADT/BitVector.h"
Devang Patel4f574f52008-07-21 23:04:39 +000017#include "llvm/Module.h"
Devang Patel35b39b4f2008-07-22 20:03:45 +000018#include "llvm/System/Path.h"
Devang Patele330f2d2008-07-18 22:59:45 +000019#include <string>
20#include <fstream>
21
22class LTOBugPoint {
23 public:
24
25 LTOBugPoint(std::istream &args, std::istream &ins);
Devang Patel35b39b4f2008-07-22 20:03:45 +000026 ~LTOBugPoint();
Devang Patele330f2d2008-07-18 22:59:45 +000027
Devang Patel5dd66a02008-07-18 23:46:41 +000028 /// 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);
Devang Patel4f574f52008-07-21 23:04:39 +000032
33 /// getNativeObjectFile - Generate native object file based from llvm
Devang Patelcfb54102008-07-24 00:34:11 +000034 /// bitcode file. Return false in case of an error. Generated native
35 /// object file is inserted in to the NativeInputFiles list.
Devang Patel4f574f52008-07-21 23:04:39 +000036 bool getNativeObjectFile(std::string &FileName);
37
38 std::string &getErrMsg() { return ErrMsg; }
39
Devang Patele330f2d2008-07-18 22:59:45 +000040 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;
Devang Patel5dd66a02008-07-18 23:46:41 +000044
45 /// LinkerOptions - List of linker command line options.
Devang Patele330f2d2008-07-18 22:59:45 +000046 llvm::SmallVector<std::string, 16> LinkerOptions;
47
Devang Patel5dd66a02008-07-18 23:46:41 +000048 /// 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
Devang Patelcfb54102008-07-24 00:34:11 +000054 /// 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;
Devang Patel4f574f52008-07-21 23:04:39 +000064 std::string getFeatureString(const char *TargetTriple);
65 std::string ErrMsg;
66
Devang Patel35b39b4f2008-07-22 20:03:45 +000067 llvm::sys::Path TempDir;
Devang Patelcfb54102008-07-24 00:34:11 +000068
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
Devang Patel4f574f52008-07-21 23:04:39 +000074private:
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);
Devang Patela11ec252008-07-22 22:20:18 +000078
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);
Devang Patelcfb54102008-07-24 00:34:11 +000084
85 /// identifyTroubleMakers - Identify set of inputs from the given
86 /// bitvector that are causing the bug under investigation.
87 void identifyTroubleMakers(llvm::BitVector &In);
Devang Patele330f2d2008-07-18 22:59:45 +000088};