@@ -4737,6 +4737,14 @@ Action *Driver::ConstructPhaseAction(
47374737 if (Args.hasArg (options::OPT_extract_api))
47384738 return C.MakeAction <ExtractAPIJobAction>(Input, types::TY_API_INFO);
47394739
4740+ // With '-fgen-reduced-bmi', we don't want to run the precompile phase
4741+ // unless the user specified '--precompile'. In the case the '--precompile'
4742+ // flag is enabled, we will try to emit the reduced BMI as a by product
4743+ // in GenerateModuleInterfaceAction.
4744+ if (Args.hasArg (options::OPT_gen_reduced_bmi) &&
4745+ !Args.getLastArg (options::OPT__precompile))
4746+ return Input;
4747+
47404748 types::ID OutputTy = getPrecompiledType (Input->getType ());
47414749 assert (OutputTy != types::TY_INVALID &&
47424750 " Cannot precompile this input type!" );
@@ -5802,19 +5810,8 @@ static const char *GetModuleOutputPath(Compilation &C, const JobAction &JA,
58025810 (C.getArgs ().hasArg (options::OPT_fmodule_output) ||
58035811 C.getArgs ().hasArg (options::OPT_fmodule_output_EQ)));
58045812
5805- if (Arg *ModuleOutputEQ =
5806- C.getArgs ().getLastArg (options::OPT_fmodule_output_EQ))
5807- return C.addResultFile (ModuleOutputEQ->getValue (), &JA);
5808-
5809- SmallString<64 > OutputPath;
5810- Arg *FinalOutput = C.getArgs ().getLastArg (options::OPT_o);
5811- if (FinalOutput && C.getArgs ().hasArg (options::OPT_c))
5812- OutputPath = FinalOutput->getValue ();
5813- else
5814- OutputPath = BaseInput;
5815-
5816- const char *Extension = types::getTypeTempSuffix (JA.getType ());
5817- llvm::sys::path::replace_extension (OutputPath, Extension);
5813+ SmallString<256 > OutputPath =
5814+ tools::getCXX20NamedModuleOutputPath (C.getArgs (), BaseInput);
58185815 return C.addResultFile (C.getArgs ().MakeArgString (OutputPath.c_str ()), &JA);
58195816}
58205817
@@ -5901,8 +5898,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
59015898 // If we're emitting a module output with the specified option
59025899 // `-fmodule-output`.
59035900 if (!AtTopLevel && isa<PrecompileJobAction>(JA) &&
5904- JA.getType () == types::TY_ModuleFile && SpecifiedModuleOutput)
5901+ JA.getType () == types::TY_ModuleFile && SpecifiedModuleOutput) {
5902+ assert (!C.getArgs ().hasArg (options::OPT_gen_reduced_bmi));
59055903 return GetModuleOutputPath (C, JA, BaseInput);
5904+ }
59065905
59075906 // Output to a temporary file?
59085907 if ((!AtTopLevel && !isSaveTempsEnabled () &&
0 commit comments