2008-07-18 22:59:45 +00:00
|
|
|
//===- LTOBugPoint.h - Top-Level LTO BugPoint class -------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This class contains all of the shared state and information that is used by
|
|
|
|
// the LTO BugPoint tool to track down bit code files that cause errors.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
2008-07-24 00:34:11 +00:00
|
|
|
#include "llvm/ADT/BitVector.h"
|
2008-07-21 23:04:39 +00:00
|
|
|
#include "llvm/Module.h"
|
2008-07-22 20:03:45 +00:00
|
|
|
#include "llvm/System/Path.h"
|
2008-07-18 22:59:45 +00:00
|
|
|
#include <string>
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
class LTOBugPoint {
|
|
|
|
public:
|
|
|
|
|
|
|
|
LTOBugPoint(std::istream &args, std::istream &ins);
|
2008-07-22 20:03:45 +00:00
|
|
|
~LTOBugPoint();
|
2008-07-18 22:59:45 +00:00
|
|
|
|
2008-07-18 23:46:41 +00:00
|
|
|
/// findTroubleMakers - Find minimum set of input files that causes error
|
|
|
|
/// identified by the script.
|
|
|
|
bool findTroubleMakers(llvm::SmallVector<std::string, 4> &TroubleMakers,
|
|
|
|
std::string &Script);
|
2008-07-21 23:04:39 +00:00
|
|
|
|
|
|
|
/// getNativeObjectFile - Generate native object file based from llvm
|
2008-07-24 00:34:11 +00:00
|
|
|
/// bitcode file. Return false in case of an error. Generated native
|
|
|
|
/// object file is inserted in to the NativeInputFiles list.
|
2008-07-21 23:04:39 +00:00
|
|
|
bool getNativeObjectFile(std::string &FileName);
|
|
|
|
|
|
|
|
std::string &getErrMsg() { return ErrMsg; }
|
|
|
|
|
2008-07-18 22:59:45 +00:00
|
|
|
private:
|
|
|
|
/// LinkerInputFiles - This is a list of linker input files. Once populated
|
|
|
|
/// this list is not modified.
|
|
|
|
llvm::SmallVector<std::string, 16> LinkerInputFiles;
|
2008-07-18 23:46:41 +00:00
|
|
|
|
|
|
|
/// LinkerOptions - List of linker command line options.
|
2008-07-18 22:59:45 +00:00
|
|
|
llvm::SmallVector<std::string, 16> LinkerOptions;
|
|
|
|
|
2008-07-18 23:46:41 +00:00
|
|
|
/// NativeInputFiles - This is a list of input files that are not llvm
|
|
|
|
/// bitcode files. The order in this list is important. The a file
|
|
|
|
/// in LinkerInputFiles at index 4 is a llvm bitcode file then the file
|
|
|
|
/// at index 4 in NativeInputFiles is corresponding native object file.
|
|
|
|
llvm::SmallVector<std::string, 16> NativeInputFiles;
|
|
|
|
|
2008-07-24 00:34:11 +00:00
|
|
|
/// BCFiles - This bit vector tracks input bitcode files.
|
|
|
|
llvm::BitVector BCFiles;
|
|
|
|
|
|
|
|
/// ConfirmedClean - This bit vector tracks input files that are confirmed
|
|
|
|
/// to be clean.
|
|
|
|
llvm::BitVector ConfirmedClean;
|
|
|
|
|
|
|
|
/// ConfirmedGuilty - This bit vector tracks input files that are confirmed
|
|
|
|
/// to contribute to the bug being investigated.
|
|
|
|
llvm::BitVector ConfirmedGuilty;
|
2008-07-21 23:04:39 +00:00
|
|
|
std::string getFeatureString(const char *TargetTriple);
|
|
|
|
std::string ErrMsg;
|
|
|
|
|
2008-07-22 20:03:45 +00:00
|
|
|
llvm::sys::Path TempDir;
|
2008-07-24 00:34:11 +00:00
|
|
|
|
|
|
|
/// findLinkingFailure - If true, investigate link failure bugs when
|
|
|
|
/// one or more linker input files are llvm bitcode files. If false,
|
|
|
|
/// investigate optimization or code generation bugs in LTO mode.
|
|
|
|
bool findLinkingFailure;
|
|
|
|
|
2008-07-21 23:04:39 +00:00
|
|
|
private:
|
|
|
|
/// assembleBitcode - Generate assembly code from the module. Return false
|
|
|
|
/// in case of an error.
|
|
|
|
bool assembleBitcode(llvm::Module *M, const char *AsmFileName);
|
2008-07-22 22:20:18 +00:00
|
|
|
|
|
|
|
/// relinkProgram - Relink program. Return false if linking fails.
|
|
|
|
bool relinkProgram(llvm::SmallVector<std::string, 16> &InputFiles);
|
|
|
|
|
|
|
|
/// reproduceProgramError - Validate program using user provided script.
|
|
|
|
bool reproduceProgramError(std::string &Script);
|
2008-07-24 00:34:11 +00:00
|
|
|
|
|
|
|
/// identifyTroubleMakers - Identify set of inputs from the given
|
|
|
|
/// bitvector that are causing the bug under investigation.
|
|
|
|
void identifyTroubleMakers(llvm::BitVector &In);
|
2008-07-18 22:59:45 +00:00
|
|
|
};
|