[clang] [Clang][Driver] Final phase also determined by input (PR #218802)

Michael Kruse via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 26 00:10:45 PDT 2026


================
@@ -401,9 +403,25 @@ phases::ID Driver::getFinalPhase(const DerivedArgList &DAL,
   } else if ((PhaseArg = DAL.getLastArg(options::OPT_emit_interface_stubs))) {
     FinalPhase = phases::IfsMerge;
 
-  // Otherwise do everything.
-  } else
-    FinalPhase = phases::Link;
+    // Otherwise, autodetect from last phase triggered by input file
+  } else {
+    llvm::BitVector UsedPhases(phases::MaxNumberOfPhases);
+    for (auto &I : Inputs) {
+      types::ID InputType = I.first;
+      const Arg *InputArg = I.second;
+
+      // Linker options should not trigger more phases
+      if (InputArg->getOption().hasFlag(options::LinkerInput))
+        continue;
+
+      auto PL = types::getCompilationPhases(InputType);
+      for (phases::ID P : PL)
+        UsedPhases.set(P);
+    }
+    FinalPhase = UsedPhases.any()
----------------
Meinersbur wrote:

I don't understand this comment. It *is* a function of the compiler flags and input types. Did you read the PR summary?

https://github.com/llvm/llvm-project/pull/218802


More information about the cfe-commits mailing list