Delete dead code after rematerializing.
[oota-llvm.git] / lib / CompilerDriver / Action.cpp
index 3503bd39db2714a6b8b6d39be5d15f6c353681e0..a8d625c7ac04ce431bf560c24d57e6da99e86089 100644 (file)
@@ -18,8 +18,8 @@
 
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Support/SystemUtils.h"
-#include "llvm/System/Program.h"
-#include "llvm/System/TimeValue.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/TimeValue.h"
 
 #include <stdexcept>
 #include <string>
@@ -53,18 +53,19 @@ namespace {
 #endif
   }
 
-  int ExecuteProgram (const std::string& name,
-                      const StrVector& args) {
+  int ExecuteProgram (const std::string& name, const StrVector& args) {
     sys::Path prog(name);
 
-    if (!prog.isAbsolute())
-      prog = FindExecutable(name, ProgramName, (void *)(intptr_t)&Main);
+    if (sys::path::is_relative(prog.str())) {
+      prog = PrependMainExecutablePath(name, ProgramName,
+                                       (void *)(intptr_t)&Main);
 
-    if (prog.isEmpty()) {
-      prog = sys::Program::FindProgramByName(name);
-      if (prog.isEmpty()) {
-        PrintError("Can't find program '" + name + "'");
-        return -1;
+      if (!prog.canExecute()) {
+        prog = sys::Program::FindProgramByName(name);
+        if (prog.isEmpty()) {
+          PrintError("Can't find program '" + name + "'");
+          return -1;
+        }
       }
     }
     if (!prog.canExecute()) {