[llvm-commits] [llvm] r53774 - in /llvm/trunk/tools/lto-bugpoint: ./ LTOBugPoint.cpp LTOBugPoint.h Makefile lto-bugpoint.cpp
Devang Patel
dpatel at apple.com
Fri Jul 18 15:59:45 PDT 2008
Author: dpatel
Date: Fri Jul 18 17:59:45 2008
New Revision: 53774
URL: http://llvm.org/viewvc/llvm-project?rev=53774&view=rev
Log:
Start writing lto-bugpoint tool.
Added:
llvm/trunk/tools/lto-bugpoint/
llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp
llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h
llvm/trunk/tools/lto-bugpoint/Makefile
llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp
Added: llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp?rev=53774&view=auto
==============================================================================
--- llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp (added)
+++ llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp Fri Jul 18 17:59:45 2008
@@ -0,0 +1,28 @@
+//===- LTOBugPoint.cpp - Top-Level LTO BugPoint class ---------------------===//
+//
+// 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 "LTOBugPoint.h"
+
+LTOBugPoint::LTOBugPoint(std::istream &args, std::istream &ins) {
+
+ // Read linker options. Order is important here.
+ std::string option;
+ while (getline(args, option))
+ LinkerOptions.push_back(option);
+
+ // Read linker input files. Order is important here.
+ std::string inFile;
+ while(getline(ins, inFile))
+ LinkerInputFiles.push_back(inFile);
+}
Added: llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h?rev=53774&view=auto
==============================================================================
--- llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h (added)
+++ llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h Fri Jul 18 17:59:45 2008
@@ -0,0 +1,30 @@
+//===- 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"
+#include <string>
+#include <fstream>
+
+class LTOBugPoint {
+ public:
+
+ LTOBugPoint(std::istream &args, std::istream &ins);
+
+ private:
+ /// LinkerInputFiles - This is a list of linker input files. Once populated
+ /// this list is not modified.
+ llvm::SmallVector<std::string, 16> LinkerInputFiles;
+ llvm::SmallVector<std::string, 16> LinkerOptions;
+
+};
Added: llvm/trunk/tools/lto-bugpoint/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/Makefile?rev=53774&view=auto
==============================================================================
--- llvm/trunk/tools/lto-bugpoint/Makefile (added)
+++ llvm/trunk/tools/lto-bugpoint/Makefile Fri Jul 18 17:59:45 2008
@@ -0,0 +1,15 @@
+##===- tools/lto-bugpoint/Makefile -------------------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../..
+
+TOOLNAME = lto-bugpoint
+
+REQUIRES_EH := 1
+
+include $(LEVEL)/Makefile.common
Added: llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp?rev=53774&view=auto
==============================================================================
--- llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp (added)
+++ llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp Fri Jul 18 17:59:45 2008
@@ -0,0 +1,67 @@
+//===- lto-bugpoing.cpp - The lto-bugpoint driver -------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// lto-bugpoint tool identifies minmal set of bitcode files that is causing
+// failure when Link Time Optimization is enabled. The failure is identified
+// using developer provided validation script.
+//
+//===----------------------------------------------------------------------===//
+
+#include "LTOBugPoint.h"
+#include <iostream>
+#include <fstream>
+
+int main(int argc, char **argv) {
+ try {
+
+ if (argc != 4) {
+ std::cerr << "Invalid number of lto-bugpoint arguments!\n";
+ return 1;
+ }
+
+ std::ios::openmode input_mode = std::ios::in;
+
+ // First argument is linker command line options file. This text file
+ // is a list of linker command line options, one option per line.
+ // First line always list the absolute path to invoke the linker.
+ std::istream *LinkerArgsFile = new std::ifstream(argv[1], input_mode);
+ if (!LinkerArgsFile->good()) {
+ std::cerr << argv[0] << ": error opening " << argv[1] << "!\n";
+ return 1;
+ }
+
+ // Second argment is a text file that includes the linker input
+ // file paths, one input file path per line.
+ std::istream *LinkerInputsFile = new std::ifstream(argv[2], input_mode);
+ if (!LinkerInputsFile->good()) {
+ std::cerr << argv[0] << ": error opening " << argv[2] << "!\n";
+ delete LinkerArgsFile;
+ return 1;
+ }
+
+ // Third argument is absolute path to the validation script. This
+ // script is used to validate LTO error under investigation.
+ std::istream *ValidationScriptFile = new std::ifstream(argv[3], input_mode);
+ if (!ValidationScriptFile->good()) {
+ std::cerr << argv[0] << ": error opening " << argv[3] << "!\n";
+ delete LinkerArgsFile;
+ delete LinkerInputsFile;
+ return 1;
+ }
+
+ LTOBugPoint bugFinder(*LinkerArgsFile, *LinkerInputsFile);
+
+ return 0;
+ } catch (const std::string& msg) {
+ std::cerr << argv[0] << ": " << msg << "\n";
+ } catch (...) {
+ std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
+ }
+ return 1;
+}
More information about the llvm-commits
mailing list