[llvm-commits] [llvm] r98618 - in /llvm/trunk/tools/bugpoint: ExecutionDriver.cpp ToolRunner.cpp ToolRunner.h

Chris Lattner sabre at nondot.org
Mon Mar 15 23:41:47 PDT 2010


Author: lattner
Date: Tue Mar 16 01:41:47 2010
New Revision: 98618

URL: http://llvm.org/viewvc/llvm-project?rev=98618&view=rev
Log:
add support for bugpointing the integrated assembler.  Something like this
works for me: bugpoint Output/bisort.llvm.bc -run-llc-ia -safe-run-llc

This uses llc with the integrated assembler as the test compiler and llc
without it as the safe compiler.

Modified:
    llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
    llvm/trunk/tools/bugpoint/ToolRunner.cpp
    llvm/trunk/tools/bugpoint/ToolRunner.h

Modified: llvm/trunk/tools/bugpoint/ExecutionDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ExecutionDriver.cpp?rev=98618&r1=98617&r2=98618&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ExecutionDriver.cpp (original)
+++ llvm/trunk/tools/bugpoint/ExecutionDriver.cpp Tue Mar 16 01:41:47 2010
@@ -28,7 +28,7 @@
   // for miscompilation.
   //
   enum OutputType {
-    AutoPick, RunLLI, RunJIT, RunLLC, RunCBE, CBE_bug, LLC_Safe, Custom
+    AutoPick, RunLLI, RunJIT, RunLLC, RunLLCIA, RunCBE, CBE_bug, LLC_Safe,Custom
   };
 
   cl::opt<double>
@@ -45,6 +45,8 @@
                                        "Execute with the interpreter"),
                             clEnumValN(RunJIT, "run-jit", "Execute with JIT"),
                             clEnumValN(RunLLC, "run-llc", "Compile with LLC"),
+                            clEnumValN(RunLLCIA, "run-llc-ia",
+                                  "Compile with LLC with integrated assembler"),
                             clEnumValN(RunCBE, "run-cbe", "Compile with CBE"),
                             clEnumValN(CBE_bug,"cbe-bug", "Find CBE bugs"),
                             clEnumValN(LLC_Safe, "llc-safe", "Use LLC for all"),
@@ -168,9 +170,11 @@
                                                  &ToolArgv);
     break;
   case RunLLC:
+  case RunLLCIA:
   case LLC_Safe:
     Interpreter = AbstractInterpreter::createLLC(getToolName(), Message,
-                                                 &ToolArgv, &GCCToolArgv);
+                                                 &ToolArgv, &GCCToolArgv,
+                                                 InterpreterSel == RunLLCIA);
     break;
   case RunJIT:
     Interpreter = AbstractInterpreter::createJIT(getToolName(), Message,
@@ -244,10 +248,12 @@
     }
     break;
   case RunLLC:
+  case RunLLCIA:
     SafeToolArgs.push_back("--relocation-model=pic");
     SafeInterpreter = AbstractInterpreter::createLLC(Path.c_str(), Message,
                                                      &SafeToolArgs,
-                                                     &GCCToolArgv);
+                                                     &GCCToolArgv,
+                                                SafeInterpreterSel == RunLLCIA);
     break;
   case RunCBE:
     SafeInterpreter = AbstractInterpreter::createCBE(Path.c_str(), Message,

Modified: llvm/trunk/tools/bugpoint/ToolRunner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.cpp?rev=98618&r1=98617&r2=98618&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ToolRunner.cpp (original)
+++ llvm/trunk/tools/bugpoint/ToolRunner.cpp Tue Mar 16 01:41:47 2010
@@ -141,7 +141,7 @@
   for (const char **Arg = Args; *Arg; ++Arg)
     OS << " " << *Arg;
   OS << "\n";
-
+  
   // Rerun the compiler, capturing any error messages to print them.
   sys::Path ErrorFilename("bugpoint.program_error_messages");
   std::string ErrMsg;
@@ -352,7 +352,8 @@
 //
 GCC::FileType LLC::OutputCode(const std::string &Bitcode, 
                               sys::Path &OutputAsmFile) {
-  sys::Path uniqueFile(Bitcode+".llc.s");
+  const char *Suffix = (UseIntegratedAssembler ? ".llc.o" : ".llc.s");
+  sys::Path uniqueFile(Bitcode + Suffix);
   std::string ErrMsg;
   if (uniqueFile.makeUnique(true, &ErrMsg)) {
     errs() << "Error making unique filename: " << ErrMsg << "\n";
@@ -360,18 +361,23 @@
   }
   OutputAsmFile = uniqueFile;
   std::vector<const char *> LLCArgs;
-  LLCArgs.push_back (LLCPath.c_str());
+  LLCArgs.push_back(LLCPath.c_str());
 
   // Add any extra LLC args.
   for (unsigned i = 0, e = ToolArgs.size(); i != e; ++i)
     LLCArgs.push_back(ToolArgs[i].c_str());
 
-  LLCArgs.push_back ("-o");
-  LLCArgs.push_back (OutputAsmFile.c_str()); // Output to the Asm file
-  LLCArgs.push_back (Bitcode.c_str());      // This is the input bitcode
+  LLCArgs.push_back("-o");
+  LLCArgs.push_back(OutputAsmFile.c_str()); // Output to the Asm file
+  LLCArgs.push_back(Bitcode.c_str());      // This is the input bitcode
+  
+  if (UseIntegratedAssembler)
+    LLCArgs.push_back("-filetype=obj");
+  
   LLCArgs.push_back (0);
 
-  outs() << "<llc>"; outs().flush();
+  outs() << (UseIntegratedAssembler ? "<llc-ia>" : "<llc>");
+  outs().flush();
   DEBUG(errs() << "\nAbout to run:\t";
         for (unsigned i=0, e = LLCArgs.size()-1; i != e; ++i)
           errs() << " " << LLCArgs[i];
@@ -381,7 +387,7 @@
                             sys::Path(), sys::Path(), sys::Path()))
     ProcessFailure(sys::Path(LLCPath), &LLCArgs[0]);
 
-  return GCC::AsmFile;                              
+  return UseIntegratedAssembler ? GCC::ObjectFile : GCC::AsmFile;
 }
 
 void LLC::compileProgram(const std::string &Bitcode) {
@@ -400,7 +406,7 @@
                         unsigned MemoryLimit) {
 
   sys::Path OutputAsmFile;
-  OutputCode(Bitcode, OutputAsmFile);
+  GCC::FileType FileKind = OutputCode(Bitcode, OutputAsmFile);
   FileRemover OutFileRemover(OutputAsmFile, !SaveTemps);
 
   std::vector<std::string> GCCArgs(ArgsForGCC);
@@ -408,7 +414,7 @@
   GCCArgs.insert(GCCArgs.end(), gccArgs.begin(), gccArgs.end());
 
   // Assuming LLC worked, compile the result with GCC and run it.
-  return gcc->ExecuteProgram(OutputAsmFile.str(), Args, GCC::AsmFile,
+  return gcc->ExecuteProgram(OutputAsmFile.str(), Args, FileKind,
                              InputFile, OutputFile, GCCArgs,
                              Timeout, MemoryLimit);
 }
@@ -418,7 +424,8 @@
 LLC *AbstractInterpreter::createLLC(const char *Argv0,
                                     std::string &Message,
                                     const std::vector<std::string> *Args,
-                                    const std::vector<std::string> *GCCArgs) {
+                                    const std::vector<std::string> *GCCArgs,
+                                    bool UseIntegratedAssembler) {
   std::string LLCPath =
     FindExecutable("llc", Argv0, (void *)(intptr_t)&createLLC).str();
   if (LLCPath.empty()) {
@@ -432,7 +439,7 @@
     errs() << Message << "\n";
     exit(1);
   }
-  return new LLC(LLCPath, gcc, Args, GCCArgs);
+  return new LLC(LLCPath, gcc, Args, GCCArgs, UseIntegratedAssembler);
 }
 
 //===---------------------------------------------------------------------===//
@@ -605,17 +612,14 @@
 // GCC abstraction
 //
 
-static bool
-IsARMArchitecture(std::vector<std::string> Args)
-{
+static bool IsARMArchitecture(std::vector<std::string> Args) {
   for (std::vector<std::string>::const_iterator
          I = Args.begin(), E = Args.end(); I != E; ++I) {
     StringRef S(*I);
     if (!S.equals_lower("-arch")) {
       ++I;
-      if (I != E && !S.substr(0, strlen("arm")).equals_lower("arm")) {
+      if (I != E && !S.substr(0, strlen("arm")).equals_lower("arm"))
         return true;
-      }
     }
   }
 
@@ -634,26 +638,33 @@
 
   GCCArgs.push_back(GCCPath.c_str());
 
+  if (TargetTriple.getArch() == Triple::x86)
+    GCCArgs.push_back("-m32");
+
   for (std::vector<std::string>::const_iterator
          I = gccArgs.begin(), E = gccArgs.end(); I != E; ++I)
     GCCArgs.push_back(I->c_str());
 
   // Specify -x explicitly in case the extension is wonky
-  GCCArgs.push_back("-x");
-  if (fileType == CFile) {
-    GCCArgs.push_back("c");
-    GCCArgs.push_back("-fno-strict-aliasing");
-  } else {
-    GCCArgs.push_back("assembler");
-
-    // For ARM architectures we don't want this flag. bugpoint isn't
-    // explicitly told what architecture it is working on, so we get
-    // it from gcc flags
-    if ((TargetTriple.getOS() == Triple::Darwin) &&
-        !IsARMArchitecture(ArgsForGCC))
-      GCCArgs.push_back("-force_cpusubtype_ALL");
+  if (fileType != ObjectFile) {
+    GCCArgs.push_back("-x");
+    if (fileType == CFile) {
+      GCCArgs.push_back("c");
+      GCCArgs.push_back("-fno-strict-aliasing");
+    } else {
+      GCCArgs.push_back("assembler");
+
+      // For ARM architectures we don't want this flag. bugpoint isn't
+      // explicitly told what architecture it is working on, so we get
+      // it from gcc flags
+      if ((TargetTriple.getOS() == Triple::Darwin) &&
+          !IsARMArchitecture(ArgsForGCC))
+        GCCArgs.push_back("-force_cpusubtype_ALL");
+    }
   }
-  GCCArgs.push_back(ProgramFile.c_str());  // Specify the input filename...
+  
+  GCCArgs.push_back(ProgramFile.c_str());  // Specify the input filename.
+  
   GCCArgs.push_back("-x");
   GCCArgs.push_back("none");
   GCCArgs.push_back("-o");
@@ -765,13 +776,18 @@
   
   GCCArgs.push_back(GCCPath.c_str());
 
+  if (TargetTriple.getArch() == Triple::x86)
+    GCCArgs.push_back("-m32");
+
   for (std::vector<std::string>::const_iterator
          I = gccArgs.begin(), E = gccArgs.end(); I != E; ++I)
     GCCArgs.push_back(I->c_str());
 
   // Compile the C/asm file into a shared object
-  GCCArgs.push_back("-x");
-  GCCArgs.push_back(fileType == AsmFile ? "assembler" : "c");
+  if (fileType != ObjectFile) {
+    GCCArgs.push_back("-x");
+    GCCArgs.push_back(fileType == AsmFile ? "assembler" : "c");
+  }
   GCCArgs.push_back("-fno-strict-aliasing");
   GCCArgs.push_back(InputFile.c_str());   // Specify the input filename.
   GCCArgs.push_back("-x");

Modified: llvm/trunk/tools/bugpoint/ToolRunner.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/bugpoint/ToolRunner.h?rev=98618&r1=98617&r2=98618&view=diff
==============================================================================
--- llvm/trunk/tools/bugpoint/ToolRunner.h (original)
+++ llvm/trunk/tools/bugpoint/ToolRunner.h Tue Mar 16 01:41:47 2010
@@ -58,7 +58,7 @@
     if (GCCArgs) gccArgs = *GCCArgs;
   }
 public:
-  enum FileType { AsmFile, CFile };
+  enum FileType { AsmFile, ObjectFile, CFile };
 
   static GCC *create(std::string &Message,
                      const std::vector<std::string> *Args);
@@ -101,7 +101,8 @@
                         const std::vector<std::string> *GCCArgs = 0);
   static LLC *createLLC(const char *Argv0, std::string &Message,
                         const std::vector<std::string> *Args = 0,
-                        const std::vector<std::string> *GCCArgs = 0);
+                        const std::vector<std::string> *GCCArgs = 0,
+                        bool UseIntegratedAssembler = false);
 
   static AbstractInterpreter* createLLI(const char *Argv0, std::string &Message,
                                         const std::vector<std::string> *Args=0);
@@ -195,11 +196,14 @@
   std::vector<std::string> ToolArgs; // Extra args to pass to LLC.
   std::vector<std::string> gccArgs;  // Extra args to pass to GCC.
   GCC *gcc;
+  bool UseIntegratedAssembler;
 public:
   LLC(const std::string &llcPath, GCC *Gcc,
       const std::vector<std::string> *Args,
-      const std::vector<std::string> *GCCArgs)
-    : LLCPath(llcPath), gcc(Gcc) {
+      const std::vector<std::string> *GCCArgs,
+      bool useIntegratedAssembler)
+    : LLCPath(llcPath), gcc(Gcc),
+      UseIntegratedAssembler(useIntegratedAssembler) {
     ToolArgs.clear();
     if (Args) ToolArgs = *Args;
     if (GCCArgs) gccArgs = *GCCArgs;





More information about the llvm-commits mailing list