]> granicus.if.org Git - clang/commitdiff
Reapply "Change -save-temps to emit unoptimized bitcode files."
authorBob Wilson <bob.wilson@apple.com>
Sun, 21 Dec 2014 07:00:00 +0000 (07:00 +0000)
committerBob Wilson <bob.wilson@apple.com>
Sun, 21 Dec 2014 07:00:00 +0000 (07:00 +0000)
This reapplies r224503 along with a fix for compiling Fortran by having the
clang driver invoke gcc (see r224546, where it was reverted). I have added
a testcase for that as well.

Original commit message:
It is often convenient to use -save-temps to collect the intermediate
results of a compilation, e.g., when triaging a bug report. Besides the
temporary files for preprocessed source and assembly code, this adds the
unoptimized bitcode files as well.

This adds a new BackendJobAction, which is mostly mechanical, to run after
the CompileJobAction. When not using -save-temps, the BackendJobAction is
combined into one job with the CompileJobAction, similar to the way the
integrated assembler is handled. I've implemented this entirely as a
driver change, so under the hood, it is just using -disable-llvm-optzns
to get the unoptimized bitcode.

Based in part on a patch by Steven Wu.
rdar://problem/18909437

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224688 91177308-0d34-0410-b5e6-96231b3b80d8

17 files changed:
include/clang/Driver/Action.h
include/clang/Driver/Phases.h
include/clang/Driver/Tool.h
lib/Driver/Action.cpp
lib/Driver/Driver.cpp
lib/Driver/Phases.cpp
lib/Driver/ToolChain.cpp
lib/Driver/Tools.cpp
lib/Driver/Tools.h
lib/Driver/Types.cpp
test/Driver/ast.c
test/Driver/darwin-dsymutil.c
test/Driver/darwin-verify-debug.c
test/Driver/fortran.f95 [new file with mode: 0644]
test/Driver/lto.c
test/Driver/phases.c
test/Driver/save-temps.c

index 2739d4934d1f9de680c0d4a3445b420bf8e939aa..dd0261c2f3a191c34571e91b4821119ba725afe0 100644 (file)
@@ -46,6 +46,7 @@ public:
     AnalyzeJobClass,
     MigrateJobClass,
     CompileJobClass,
+    BackendJobClass,
     AssembleJobClass,
     LinkJobClass,
     LipoJobClass,
@@ -195,6 +196,16 @@ public:
   }
 };
 
+class BackendJobAction : public JobAction {
+  void anchor() override;
+public:
+  BackendJobAction(std::unique_ptr<Action> Input, types::ID OutputType);
+
+  static bool classof(const Action *A) {
+    return A->getKind() == BackendJobClass;
+  }
+};
+
 class AssembleJobAction : public JobAction {
   void anchor() override;
 public:
index e2160e6531e0e405d6ae9308d5d5b32c951ab1a7..cd6b5b5c9f05661ef6cf576a5aafc2d64a29bd9b 100644 (file)
@@ -19,6 +19,7 @@ namespace phases {
     Preprocess,
     Precompile,
     Compile,
+    Backend,
     Assemble,
     Link
   };
index aa895d0ba66449648426b7fe0eac0f930fe206c7..b9eac1cad65dbd9ab1a7c8cdb32611e5ba90e10e 100644 (file)
@@ -84,6 +84,7 @@ public:
   const ToolChain &getToolChain() const { return TheToolChain; }
 
   virtual bool hasIntegratedAssembler() const { return false; }
+  virtual bool canEmitIR() const { return false; }
   virtual bool hasIntegratedCPP() const = 0;
   virtual bool isLinkJob() const { return false; }
   virtual bool isDsymutilJob() const { return false; }
index d4f339d376ddec549a85606e48eb15588ae444dd..360dbeecabf97d08825fdcd4afbf4d90ad036db7 100644 (file)
@@ -29,6 +29,7 @@ const char *Action::getClassName(ActionClass AC) {
   case AnalyzeJobClass: return "analyzer";
   case MigrateJobClass: return "migrator";
   case CompileJobClass: return "compiler";
+  case BackendJobClass: return "backend";
   case AssembleJobClass: return "assembler";
   case LinkJobClass: return "linker";
   case LipoJobClass: return "lipo";
@@ -92,6 +93,12 @@ CompileJobAction::CompileJobAction(std::unique_ptr<Action> Input,
                                    types::ID OutputType)
     : JobAction(CompileJobClass, std::move(Input), OutputType) {}
 
+void BackendJobAction::anchor() {}
+
+BackendJobAction::BackendJobAction(std::unique_ptr<Action> Input,
+                                   types::ID OutputType)
+    : JobAction(BackendJobClass, std::move(Input), OutputType) {}
+
 void AssembleJobAction::anchor() {}
 
 AssembleJobAction::AssembleJobAction(std::unique_ptr<Action> Input,
index 99d84432dee07af8fd6a237b4d5ac2953b996f4e..1f9e11afdc43503b18d480f0bd7c61a4eefbd866 100644 (file)
@@ -165,7 +165,7 @@ const {
       (PhaseArg = DAL.getLastArg(options::OPT__SLASH_P))) {
     FinalPhase = phases::Preprocess;
 
-    // -{fsyntax-only,-analyze,emit-ast,S} only run up to the compiler.
+    // -{fsyntax-only,-analyze,emit-ast} only run up to the compiler.
   } else if ((PhaseArg = DAL.getLastArg(options::OPT_fsyntax_only)) ||
              (PhaseArg = DAL.getLastArg(options::OPT_module_file_info)) ||
              (PhaseArg = DAL.getLastArg(options::OPT_verify_pch)) ||
@@ -174,10 +174,13 @@ const {
              (PhaseArg = DAL.getLastArg(options::OPT__migrate)) ||
              (PhaseArg = DAL.getLastArg(options::OPT__analyze,
                                         options::OPT__analyze_auto)) ||
-             (PhaseArg = DAL.getLastArg(options::OPT_emit_ast)) ||
-             (PhaseArg = DAL.getLastArg(options::OPT_S))) {
+             (PhaseArg = DAL.getLastArg(options::OPT_emit_ast))) {
     FinalPhase = phases::Compile;
 
+    // -S only runs up to the backend.
+  } else if ((PhaseArg = DAL.getLastArg(options::OPT_S))) {
+    FinalPhase = phases::Backend;
+
     // -c only runs up to the assembler.
   } else if ((PhaseArg = DAL.getLastArg(options::OPT_c))) {
     FinalPhase = phases::Assemble;
@@ -849,7 +852,9 @@ void Driver::PrintActions(const Compilation &C) const {
 /// \brief Check whether the given input tree contains any compilation or
 /// assembly actions.
 static bool ContainsCompileOrAssembleAction(const Action *A) {
-  if (isa<CompileJobAction>(A) || isa<AssembleJobAction>(A))
+  if (isa<CompileJobAction>(A) ||
+      isa<BackendJobAction>(A) ||
+      isa<AssembleJobAction>(A))
     return true;
 
   for (Action::const_iterator it = A->begin(), ie = A->end(); it != ie; ++it)
@@ -1346,17 +1351,21 @@ Driver::ConstructPhaseAction(const ArgList &Args, phases::ID Phase,
     if (Args.hasArg(options::OPT_verify_pch))
       return llvm::make_unique<VerifyPCHJobAction>(std::move(Input),
                                                    types::TY_Nothing);
+    return llvm::make_unique<CompileJobAction>(std::move(Input),
+                                               types::TY_LLVM_BC);
+  }
+  case phases::Backend: {
     if (IsUsingLTO(Args)) {
       types::ID Output =
         Args.hasArg(options::OPT_S) ? types::TY_LTO_IR : types::TY_LTO_BC;
-      return llvm::make_unique<CompileJobAction>(std::move(Input), Output);
+      return llvm::make_unique<BackendJobAction>(std::move(Input), Output);
     }
     if (Args.hasArg(options::OPT_emit_llvm)) {
       types::ID Output =
         Args.hasArg(options::OPT_S) ? types::TY_LLVM_IR : types::TY_LLVM_BC;
-      return llvm::make_unique<CompileJobAction>(std::move(Input), Output);
+      return llvm::make_unique<BackendJobAction>(std::move(Input), Output);
     }
-    return llvm::make_unique<CompileJobAction>(std::move(Input),
+    return llvm::make_unique<BackendJobAction>(std::move(Input),
                                                types::TY_PP_Asm);
   }
   case phases::Assemble:
@@ -1494,12 +1503,34 @@ static const Tool *SelectToolForJob(Compilation &C, const ToolChain *TC,
       !C.getArgs().hasArg(options::OPT__SLASH_FA) &&
       !C.getArgs().hasArg(options::OPT__SLASH_Fa) &&
       isa<AssembleJobAction>(JA) &&
-      Inputs->size() == 1 && isa<CompileJobAction>(*Inputs->begin())) {
-    const Tool *Compiler =
-      TC->SelectTool(cast<JobAction>(**Inputs->begin()));
+      Inputs->size() == 1 && isa<BackendJobAction>(*Inputs->begin())) {
+    // A BackendJob is always preceded by a CompileJob, and without
+    // -save-temps they will always get combined together, so instead of
+    // checking the backend tool, check if the tool for the CompileJob
+    // has an integrated assembler.
+    const ActionList *BackendInputs = &(*Inputs)[0]->getInputs();
+    JobAction *CompileJA = cast<CompileJobAction>(*BackendInputs->begin());
+    const Tool *Compiler = TC->SelectTool(*CompileJA);
     if (!Compiler)
       return nullptr;
     if (Compiler->hasIntegratedAssembler()) {
+      Inputs = &(*BackendInputs)[0]->getInputs();
+      ToolForJob = Compiler;
+    }
+  }
+
+  // A backend job should always be combined with the preceding compile job
+  // unless OPT_save_temps is enabled and the compiler is capable of emitting
+  // LLVM IR as an intermediate output.
+  if (isa<BackendJobAction>(JA)) {
+    // Check if the compiler supports emitting LLVM IR.
+    assert(Inputs->size() == 1);
+    JobAction *CompileJA = cast<CompileJobAction>(*Inputs->begin());
+    const Tool *Compiler = TC->SelectTool(*CompileJA);
+    if (!Compiler)
+      return nullptr;
+    if (!Compiler->canEmitIR() ||
+        !C.getArgs().hasArg(options::OPT_save_temps)) {
       Inputs = &(*Inputs)[0]->getInputs();
       ToolForJob = Compiler;
     }
@@ -1751,6 +1782,12 @@ const char *Driver::GetNamedOutputPath(Compilation &C,
       Suffixed += "-";
       Suffixed.append(BoundArch);
     }
+    // When using both -save-temps and -emit-llvm, use a ".tmp.bc" suffix for
+    // the unoptimized bitcode so that it does not get overwritten by the ".bc"
+    // optimized bitcode output.
+    if (!AtTopLevel && C.getArgs().hasArg(options::OPT_emit_llvm) &&
+        JA.getType() == types::TY_LLVM_BC)
+      Suffixed += ".tmp";
     Suffixed += '.';
     Suffixed += Suffix;
     NamedOutput = C.getArgs().MakeArgString(Suffixed.c_str());
@@ -2083,7 +2120,7 @@ bool Driver::ShouldUseClangCompiler(const JobAction &JA) const {
 
   // Otherwise make sure this is an action clang understands.
   if (!isa<PreprocessJobAction>(JA) && !isa<PrecompileJobAction>(JA) &&
-      !isa<CompileJobAction>(JA))
+      !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA))
     return false;
 
   return true;
index 155e53b64fc151a8c3d1f1234732f04f1a828473..7ae270857f4d02feb3d9b624bf10616ddbf75cec 100644 (file)
@@ -18,6 +18,7 @@ const char *phases::getPhaseName(ID Id) {
   case Preprocess: return "preprocessor";
   case Precompile: return "precompiler";
   case Compile: return "compiler";
+  case Backend: return "backend";
   case Assemble: return "assembler";
   case Link: return "linker";
   }
index 6734ce7d709904f0d3a9477194faadd7b0c7677a..2bcfecf6bde61664988e3e285883be53525db0b5 100644 (file)
@@ -129,6 +129,7 @@ Tool *ToolChain::getTool(Action::ActionClass AC) const {
   case Action::AnalyzeJobClass:
   case Action::MigrateJobClass:
   case Action::VerifyPCHJobClass:
+  case Action::BackendJobClass:
     return getClang();
   }
 
index 20d14bf36c4597a1ee1f7952416ae2d968e9437a..1c5a9aa4046958408a52ad845e4ca33b63ca5008 100644 (file)
@@ -2002,7 +2002,7 @@ static bool ShouldDisableDwarfDirectory(const ArgList &Args,
 
 /// \brief Check whether the given input tree contains any compilation actions.
 static bool ContainsCompileAction(const Action *A) {
-  if (isa<CompileJobAction>(A))
+  if (isa<CompileJobAction>(A) || isa<BackendJobAction>(A))
     return true;
 
   for (const auto &Act : *A)
@@ -2528,7 +2528,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   } else if (isa<VerifyPCHJobAction>(JA)) {
     CmdArgs.push_back("-verify-pch");
   } else {
-    assert(isa<CompileJobAction>(JA) && "Invalid action for clang tool.");
+    assert((isa<CompileJobAction>(JA) || isa<BackendJobAction>(JA)) &&
+           "Invalid action for clang tool.");
 
     if (JA.getType() == types::TY_Nothing) {
       CmdArgs.push_back("-fsyntax-only");
@@ -4405,18 +4406,27 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // Forward -Xclang arguments to -cc1, and -mllvm arguments to the LLVM option
   // parser.
   Args.AddAllArgValues(CmdArgs, options::OPT_Xclang);
+  bool OptDisabled = false;
   for (arg_iterator it = Args.filtered_begin(options::OPT_mllvm),
          ie = Args.filtered_end(); it != ie; ++it) {
     (*it)->claim();
 
     // We translate this by hand to the -cc1 argument, since nightly test uses
     // it and developers have been trained to spell it with -mllvm.
-    if (StringRef((*it)->getValue(0)) == "-disable-llvm-optzns")
+    if (StringRef((*it)->getValue(0)) == "-disable-llvm-optzns") {
       CmdArgs.push_back("-disable-llvm-optzns");
-    else
+      OptDisabled = true;
+    } else
       (*it)->render(Args, CmdArgs);
   }
 
+  // With -save-temps, we want to save the unoptimized bitcode output from the
+  // CompileJobAction, so disable optimizations if they are not already
+  // disabled.
+  if (Args.hasArg(options::OPT_save_temps) && !OptDisabled &&
+      isa<CompileJobAction>(JA))
+    CmdArgs.push_back("-disable-llvm-optzns");
+
   if (Output.getType() == types::TY_Dependencies) {
     // Handled with other dependency code.
   } else if (Output.isFilename()) {
@@ -4462,7 +4472,8 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // can propagate it to the backend.
   bool SplitDwarf = Args.hasArg(options::OPT_gsplit_dwarf) &&
     getToolChain().getTriple().isOSLinux() &&
-    (isa<AssembleJobAction>(JA) || isa<CompileJobAction>(JA));
+    (isa<AssembleJobAction>(JA) || isa<CompileJobAction>(JA) ||
+     isa<BackendJobAction>(JA));
   const char *SplitDwarfOut;
   if (SplitDwarf) {
     CmdArgs.push_back("-split-dwarf-file");
@@ -4486,7 +4497,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // Handle the debug info splitting at object creation time if we're
   // creating an object.
   // TODO: Currently only works on linux with newer objcopy.
-  if (SplitDwarf && !isa<CompileJobAction>(JA))
+  if (SplitDwarf && !isa<CompileJobAction>(JA) && !isa<BackendJobAction>(JA))
     SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, SplitDwarfOut);
 
   if (Arg *A = Args.getLastArg(options::OPT_pg))
index 59af8a0ec97823e70dc8a6eeace3e4c5ed092b1d..6647f39ce817ffe891927c7f73f66340ab5fffd8 100644 (file)
@@ -95,6 +95,7 @@ using llvm::opt::ArgStringList;
     bool hasGoodDiagnostics() const override { return true; }
     bool hasIntegratedAssembler() const override { return true; }
     bool hasIntegratedCPP() const override { return true; }
+    bool canEmitIR() const override { return true; }
 
     void ConstructJob(Compilation &C, const JobAction &JA,
                       const InputInfo &Output, const InputInfoList &Inputs,
index 4a22dcff46a73ad2d367df5f826d296f1ac3224c..6ee764c64e3484fa2dd108d2caed015a99a82bbe 100644 (file)
@@ -203,6 +203,7 @@ void types::getCompilationPhases(ID Id, llvm::SmallVectorImpl<phases::ID> &P) {
     } else {
       if (!onlyAssembleType(Id)) {
         P.push_back(phases::Compile);
+        P.push_back(phases::Backend);
       }
       P.push_back(phases::Assemble);
     }
index 83dfcc37a9c8ca26414390cc20dc036ab5147716..c1d7b1a6d7b0356857c5b10e3f476108926d14ae 100644 (file)
 
 // COMPILE-AST-PHASES: 0: input,
 // COMPILE-AST-PHASES: , ast
-// COMPILE-AST-PHASES: 1: compiler, {0}, assembler
-// COMPILE-AST-PHASES: 2: assembler, {1}, object
-// COMPILE-AST-PHASES-NOT: 3:
+// COMPILE-AST-PHASES: 1: compiler, {0}, ir
+// COMPILE-AST-PHASES: 2: backend, {1}, assembler
+// COMPILE-AST-PHASES: 3: assembler, {2}, object
+// COMPILE-AST-PHASES-NOT: 4:
 // COMPILE-AST-PHASES: END
 
 // FIXME: There is a problem with compiling AST's in that the input language is
index 59084a2c85ed56186b8aa2a46f52298299ada358..0e2c4907104e838029203810aabe8d9cd69feabc 100644 (file)
@@ -6,13 +6,14 @@
 //
 // CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-dsymutil.c", c
 // CHECK-MULTIARCH-ACTIONS: 1: preprocessor, {0}, cpp-output
-// CHECK-MULTIARCH-ACTIONS: 2: compiler, {1}, assembler
-// CHECK-MULTIARCH-ACTIONS: 3: assembler, {2}, object
-// CHECK-MULTIARCH-ACTIONS: 4: linker, {3}, image
-// CHECK-MULTIARCH-ACTIONS: 5: bind-arch, "i386", {4}, image
-// CHECK-MULTIARCH-ACTIONS: 6: bind-arch, "x86_64", {4}, image
-// CHECK-MULTIARCH-ACTIONS: 7: lipo, {5, 6}, image
-// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
+// CHECK-MULTIARCH-ACTIONS: 2: compiler, {1}, ir
+// CHECK-MULTIARCH-ACTIONS: 3: backend, {2}, assembler
+// CHECK-MULTIARCH-ACTIONS: 4: assembler, {3}, object
+// CHECK-MULTIARCH-ACTIONS: 5: linker, {4}, image
+// CHECK-MULTIARCH-ACTIONS: 6: bind-arch, "i386", {5}, image
+// CHECK-MULTIARCH-ACTIONS: 7: bind-arch, "x86_64", {5}, image
+// CHECK-MULTIARCH-ACTIONS: 8: lipo, {6, 7}, image
+// CHECK-MULTIARCH-ACTIONS: 9: dsymutil, {8}, dSYM
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   -arch i386 -arch x86_64 %s -g 2> %t
index 50a6cf31b8e9122c596660a44b6a8b7a31fe324c..ebbf89a4d63632a510570345e214bc5ea1e5d280 100644 (file)
@@ -5,8 +5,8 @@
 // RUN: FileCheck -check-prefix=CHECK-MULTIARCH-ACTIONS < %t %s
 //
 // CHECK-MULTIARCH-ACTIONS: 0: input, "{{.*}}darwin-verify-debug.c", c
-// CHECK-MULTIARCH-ACTIONS: 8: dsymutil, {7}, dSYM
-// CHECK-MULTIARCH-ACTIONS: 9: verify-debug-info, {8}, none
+// CHECK-MULTIARCH-ACTIONS: 9: dsymutil, {8}, dSYM
+// CHECK-MULTIARCH-ACTIONS: 10: verify-debug-info, {9}, none
 //
 // RUN: %clang -target x86_64-apple-darwin10 -ccc-print-bindings \
 // RUN:   --verify-debug-info -arch i386 -arch x86_64 %s -g 2> %t
diff --git a/test/Driver/fortran.f95 b/test/Driver/fortran.f95
new file mode 100644 (file)
index 0000000..9334cbe
--- /dev/null
@@ -0,0 +1,9 @@
+// Check that the clang driver can invoke gcc to compile Fortran.
+
+// RUN: %clang -target x86_64-unknown-linux-gnu -integrated-as -c %s -### 2>&1 \
+// RUN:   | FileCheck %s
+// CHECK: gcc
+// CHECK: "-S"
+// CHECK: "-x" "f95"
+// CHECK: clang
+// CHECK: "-cc1as"
index 91524bf78b1d688324c1f3bae28435b45798e08d..ec6b3f1162df9b38f4cbb2429b242477c058956f 100644 (file)
@@ -1,18 +1,21 @@
 // -flto causes a switch to llvm-bc object files.
 // RUN: %clang -ccc-print-phases -c %s -flto 2> %t.log
-// RUN: grep '2: compiler, {1}, lto-bc' %t.log
+// RUN: grep '2: compiler, {1}, ir' %t.log
+// RUN: grep '3: backend, {2}, lto-bc' %t.log
 
 // RUN: %clang -ccc-print-phases %s -flto 2> %t.log
 // RUN: grep '0: input, ".*lto.c", c' %t.log
 // RUN: grep '1: preprocessor, {0}, cpp-output' %t.log
-// RUN: grep '2: compiler, {1}, lto-bc' %t.log
-// RUN: grep '3: linker, {2}, image' %t.log
+// RUN: grep '2: compiler, {1}, ir' %t.log
+// RUN: grep '3: backend, {2}, lto-bc' %t.log
+// RUN: grep '4: linker, {3}, image' %t.log
 
 // llvm-bc and llvm-ll outputs need to match regular suffixes
 // (unfortunately).
 // RUN: %clang %s -flto -save-temps -### 2> %t.log
 // RUN: grep '"-o" ".*lto\.i" "-x" "c" ".*lto\.c"' %t.log
-// RUN: grep '"-o" ".*lto\.o" .*".*lto\.i"' %t.log
+// RUN: grep '"-o" ".*lto\.bc" .*".*lto\.i"' %t.log
+// RUN: grep '"-o" ".*lto\.o" .*".*lto\.bc"' %t.log
 // RUN: grep '".*a.out" .*".*lto\.o"' %t.log
 
 // RUN: %clang %s -flto -S -### 2> %t.log
index 4c480d59c14a7cba391b308769fb2040d0a0ae13..0283800825ac62f7fb12ea7dcfa5335f9c03152b 100644 (file)
@@ -2,47 +2,53 @@
 // RUN: %clang -target i386-unknown-unknown -ccc-print-phases -x c %s -x objective-c %s -x c++ %s -x objective-c++ -x assembler %s -x assembler-with-cpp %s -x none %s 2>&1 | FileCheck -check-prefix=BASIC %s
 // BASIC: 0: input, "{{.*}}phases.c", c
 // BASIC: 1: preprocessor, {0}, cpp-output
-// BASIC: 2: compiler, {1}, assembler
-// BASIC: 3: assembler, {2}, object
-// BASIC: 4: input, "{{.*}}phases.c", objective-c
-// BASIC: 5: preprocessor, {4}, objective-c-cpp-output
-// BASIC: 6: compiler, {5}, assembler
-// BASIC: 7: assembler, {6}, object
-// BASIC: 8: input, "{{.*}}phases.c", c++
-// BASIC: 9: preprocessor, {8}, c++-cpp-output
-// BASIC: 10: compiler, {9}, assembler
-// BASIC: 11: assembler, {10}, object
-// BASIC: 12: input, "{{.*}}phases.c", assembler
-// BASIC: 13: assembler, {12}, object
-// BASIC: 14: input, "{{.*}}phases.c", assembler-with-cpp
-// BASIC: 15: preprocessor, {14}, assembler
+// BASIC: 2: compiler, {1}, ir
+// BASIC: 3: backend, {2}, assembler
+// BASIC: 4: assembler, {3}, object
+// BASIC: 5: input, "{{.*}}phases.c", objective-c
+// BASIC: 6: preprocessor, {5}, objective-c-cpp-output
+// BASIC: 7: compiler, {6}, ir
+// BASIC: 8: backend, {7}, assembler
+// BASIC: 9: assembler, {8}, object
+// BASIC: 10: input, "{{.*}}phases.c", c++
+// BASIC: 11: preprocessor, {10}, c++-cpp-output
+// BASIC: 12: compiler, {11}, ir
+// BASIC: 13: backend, {12}, assembler
+// BASIC: 14: assembler, {13}, object
+// BASIC: 15: input, "{{.*}}phases.c", assembler
 // BASIC: 16: assembler, {15}, object
-// BASIC: 17: input, "{{.*}}phases.c", c
-// BASIC: 18: preprocessor, {17}, cpp-output
-// BASIC: 19: compiler, {18}, assembler
-// BASIC: 20: assembler, {19}, object
-// BASIC: 21: linker, {3, 7, 11, 13, 16, 20}, image
+// BASIC: 17: input, "{{.*}}phases.c", assembler-with-cpp
+// BASIC: 18: preprocessor, {17}, assembler
+// BASIC: 19: assembler, {18}, object
+// BASIC: 20: input, "{{.*}}phases.c", c
+// BASIC: 21: preprocessor, {20}, cpp-output
+// BASIC: 22: compiler, {21}, ir
+// BASIC: 23: backend, {22}, assembler
+// BASIC: 24: assembler, {23}, object
+// BASIC: 25: linker, {4, 9, 14, 16, 19, 24}, image
 
 // Universal linked image.
 // RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=ULI %s
 // ULI: 0: input, "{{.*}}phases.c", c
 // ULI: 1: preprocessor, {0}, cpp-output
-// ULI: 2: compiler, {1}, assembler
-// ULI: 3: assembler, {2}, object
-// ULI: 4: linker, {3}, image
-// ULI: 5: bind-arch, "ppc", {4}, image
-// ULI: 6: bind-arch, "i386", {4}, image
-// ULI: 7: lipo, {5, 6}, image
+// ULI: 2: compiler, {1}, ir
+// ULI: 3: backend, {2}, assembler
+// ULI: 4: assembler, {3}, object
+// ULI: 5: linker, {4}, image
+// ULI: 6: bind-arch, "ppc", {5}, image
+// ULI: 7: bind-arch, "i386", {5}, image
+// ULI: 8: lipo, {6, 7}, image
 
 // Universal object file.
 // RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x c %s -arch ppc -arch i386 2>&1 | FileCheck -check-prefix=UOF %s
 // UOF: 0: input, "{{.*}}phases.c", c
 // UOF: 1: preprocessor, {0}, cpp-output
-// UOF: 2: compiler, {1}, assembler
-// UOF: 3: assembler, {2}, object
-// UOF: 4: bind-arch, "ppc", {3}, object
-// UOF: 5: bind-arch, "i386", {3}, object
-// UOF: 6: lipo, {4, 5}, object
+// UOF: 2: compiler, {1}, ir
+// UOF: 3: backend, {2}, assembler
+// UOF: 4: assembler, {3}, object
+// UOF: 5: bind-arch, "ppc", {4}, object
+// UOF: 6: bind-arch, "i386", {4}, object
+// UOF: 7: lipo, {5, 6}, object
 
 // Arch defaulting
 // RUN: %clang -target i386-apple-darwin9 -ccc-print-phases -c -x assembler %s 2>&1 | FileCheck -check-prefix=ARCH1 %s
index a4ca3b26649eddb431b0a5685b6f23c82653b813..a157aeaaff4acf710a4b64020a9f23fc59921b42 100644 (file)
@@ -1,17 +1,28 @@
 // RUN: %clang -target x86_64-apple-darwin -save-temps -arch x86_64 %s -### 2>&1 \
 // RUN:   | FileCheck %s
 // CHECK: "-o" "save-temps.i"
+// CHECK: "-disable-llvm-optzns"
+// CHECK: "-o" "save-temps.bc"
 // CHECK: "-o" "save-temps.s"
 // CHECK: "-o" "save-temps.o"
 // CHECK: "-o" "a.out" 
 
+// Check for a single clang cc1 invocation when NOT using -save-temps.
+// RUN: %clang -target x86_64-apple-darwin -arch x86_64 -S %s -### 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=NO-TEMPS
+// NO-TEMPS: "-cc1"
+// NO-TEMPS: "-S"
+// NO-TEMPS: "-x" "c"
+
 // RUN: %clang -target x86_64-apple-darwin -save-temps -arch i386 -arch x86_64 %s -### 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=MULT-ARCH
 // MULT-ARCH: "-o" "save-temps-i386.i"
+// MULT-ARCH: "-o" "save-temps-i386.bc"
 // MULT-ARCH: "-o" "save-temps-i386.s"
 // MULT-ARCH: "-o" "save-temps-i386.o"
 // MULT-ARCH: "-o" "a.out-i386" 
 // MULT-ARCH: "-o" "save-temps-x86_64.i"
+// MULT-ARCH: "-o" "save-temps-x86_64.bc"
 // MULT-ARCH: "-o" "save-temps-x86_64.s"
 // MULT-ARCH: "-o" "save-temps-x86_64.o"
 // MULT-ARCH: "-o" "a.out-x86_64"