[llvm-commits] [llvm] r53777 - in /llvm/trunk/tools/lto-bugpoint: LTOBugPoint.cpp LTOBugPoint.h Makefile lto-bugpoint.cpp

Devang Patel dpatel at apple.com
Fri Jul 18 16:46:41 PDT 2008


Author: dpatel
Date: Fri Jul 18 18:46:41 2008
New Revision: 53777

URL: http://llvm.org/viewvc/llvm-project?rev=53777&view=rev
Log:
If all linker input files are native object files then lto-bugpoint is not useful.

Modified:
    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

Modified: llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp?rev=53777&r1=53776&r2=53777&view=diff

==============================================================================
--- llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp (original)
+++ llvm/trunk/tools/lto-bugpoint/LTOBugPoint.cpp Fri Jul 18 18:46:41 2008
@@ -13,7 +13,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "LTOBugPoint.h"
+#include "llvm/Support/SystemUtils.h"
+#include "llvm/System/Path.h"
+#include <iostream>
 
+/// LTOBugPoint -- Constructor. Popuate list of linker options and
+/// list of linker input files.
 LTOBugPoint::LTOBugPoint(std::istream &args, std::istream &ins) {
 
   // Read linker options. Order is important here.
@@ -26,3 +31,27 @@
   while(getline(ins, inFile))
     LinkerInputFiles.push_back(inFile);
 }
+
+/// findTroubleMakers - Find minimum set of input files that causes error
+/// identified by the script.
+bool
+LTOBugPoint::findTroubleMakers(llvm::SmallVector<std::string, 4> &TroubleMakers,
+			       std::string &Script) {
+
+  // First, build native object files set.
+  bool bitcodeFileSeen = false;
+  for(llvm::SmallVector<std::string, 16>::iterator I = LinkerInputFiles.begin(),
+	E = LinkerInputFiles.end(); I != E; ++I) {
+    std::string &path = *I;
+    if (llvm::sys::Path(path.c_str()).isBitcodeFile()) 
+      bitcodeFileSeen = true;
+  }
+
+  if (!bitcodeFileSeen) {
+    std::cerr << "lto-bugpoint: Error: Unable to help!"; 
+    std::cerr << " Need at least one input file that contains llvm bitcode\n";
+    return false;
+  }
+
+  return true;
+}

Modified: llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h?rev=53777&r1=53776&r2=53777&view=diff

==============================================================================
--- llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h (original)
+++ llvm/trunk/tools/lto-bugpoint/LTOBugPoint.h Fri Jul 18 18:46:41 2008
@@ -21,10 +21,22 @@
 
   LTOBugPoint(std::istream &args, std::istream &ins);
 
+  /// 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);
  private:
   /// LinkerInputFiles - This is a list of linker input files. Once populated
   /// this list is not modified.
   llvm::SmallVector<std::string, 16> LinkerInputFiles;
+
+  /// LinkerOptions - List of linker command line options.
   llvm::SmallVector<std::string, 16> LinkerOptions;
 
+  /// 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;
+
 };

Modified: llvm/trunk/tools/lto-bugpoint/Makefile
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/Makefile?rev=53777&r1=53776&r2=53777&view=diff

==============================================================================
--- llvm/trunk/tools/lto-bugpoint/Makefile (original)
+++ llvm/trunk/tools/lto-bugpoint/Makefile Fri Jul 18 18:46:41 2008
@@ -10,6 +10,8 @@
 
 TOOLNAME = lto-bugpoint
 
+LINK_COMPONENTS := system
+
 REQUIRES_EH := 1
 
 include $(LEVEL)/Makefile.common

Modified: llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp?rev=53777&r1=53776&r2=53777&view=diff

==============================================================================
--- llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp (original)
+++ llvm/trunk/tools/lto-bugpoint/lto-bugpoint.cpp Fri Jul 18 18:46:41 2008
@@ -47,16 +47,13 @@
 
     // 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;
-    }
-
+    std::string ValidationScript = argv[3];
     LTOBugPoint bugFinder(*LinkerArgsFile, *LinkerInputsFile);
 
+    llvm::SmallVector<std::string, 4> TroubleMakers;
+    if (!bugFinder.findTroubleMakers(TroubleMakers, ValidationScript))
+      return 1;
+
     return 0;
   } catch (const std::string& msg) {
     std::cerr << argv[0] << ": " << msg << "\n";





More information about the llvm-commits mailing list