@@ -302,7 +302,7 @@ SupplementaryOutputPathsComputer::computeOutputPaths() const {
302302 // In WMO mode compute supplementary output paths for optimization record
303303 // data (opt-remarks). We need one path per LLVMModule that will be created as
304304 // part of wmo.
305- if (!InputsAndOutputs.hasPrimaryInputs () && OutputFiles. size () > 1 ) {
305+ if (!InputsAndOutputs.hasPrimaryInputs ()) {
306306 unsigned i = 0 ;
307307 InputsAndOutputs.forEachInput ([&](const InputFile &input) -> bool {
308308 // First input is already computed.
@@ -313,23 +313,26 @@ SupplementaryOutputPathsComputer::computeOutputPaths() const {
313313 SupplementaryOutputPaths outputs;
314314
315315 // Compute auxiliar opt record paths.
316- StringRef defaultSupplementaryOutputPathExcludingExtension =
317- deriveDefaultSupplementaryOutputPathExcludingExtension (OutputFiles[i], input);
318-
319- auto YAMLOptRecordPath = determineSupplementaryOutputFilename (
320- options::OPT_save_optimization_record_path,
321- " " ,
322- file_types::TY_YAMLOptRecord, " " ,
323- defaultSupplementaryOutputPathExcludingExtension, true );
324- outputs.YAMLOptRecordPath = YAMLOptRecordPath;
325-
326- auto bitstreamOptRecordPath = determineSupplementaryOutputFilename (
327- options::OPT_save_optimization_record_path,
328- " " ,
329- file_types::TY_BitstreamOptRecord, " " ,
330- defaultSupplementaryOutputPathExcludingExtension, true );
331-
332- outputs.BitstreamOptRecordPath = bitstreamOptRecordPath;
316+ if (OutputFiles.size () > 1 ) {
317+ StringRef defaultSupplementaryOutputPathExcludingExtension =
318+ deriveDefaultSupplementaryOutputPathExcludingExtension (
319+ OutputFiles[i], input);
320+
321+ auto YAMLOptRecordPath = determineSupplementaryOutputFilename (
322+ options::OPT_save_optimization_record,
323+ " " ,
324+ file_types::TY_YAMLOptRecord, " " ,
325+ defaultSupplementaryOutputPathExcludingExtension, true );
326+ outputs.YAMLOptRecordPath = YAMLOptRecordPath;
327+
328+ auto bitstreamOptRecordPath = determineSupplementaryOutputFilename (
329+ options::OPT_save_optimization_record,
330+ " " ,
331+ file_types::TY_BitstreamOptRecord, " " ,
332+ defaultSupplementaryOutputPathExcludingExtension, true );
333+
334+ outputs.BitstreamOptRecordPath = bitstreamOptRecordPath;
335+ }
333336
334337 outputPaths.emplace_back (std::move (outputs));
335338 ++i;
@@ -603,11 +606,11 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
603606 defaultSupplementaryOutputPathExcludingExtension);
604607
605608 auto YAMLOptRecordPath = determineSupplementaryOutputFilename (
606- OPT_save_optimization_record_path , pathsFromArguments.YAMLOptRecordPath ,
609+ OPT_save_optimization_record , pathsFromArguments.YAMLOptRecordPath ,
607610 file_types::TY_YAMLOptRecord, " " ,
608611 defaultSupplementaryOutputPathExcludingExtension);
609612 auto bitstreamOptRecordPath = determineSupplementaryOutputFilename (
610- OPT_save_optimization_record_path , pathsFromArguments.BitstreamOptRecordPath ,
613+ OPT_save_optimization_record , pathsFromArguments.BitstreamOptRecordPath ,
611614 file_types::TY_BitstreamOptRecord, " " ,
612615 defaultSupplementaryOutputPathExcludingExtension);
613616
@@ -656,6 +659,15 @@ SupplementaryOutputPathsComputer::determineSupplementaryOutputFilename(
656659 StringRef defaultSupplementaryOutputPathExcludingExtension,
657660 bool forceDefaultSupplementaryOutputPathExcludingExtension) const {
658661
662+ auto hasEmitOptArg = [&] () -> bool {
663+ if (Args.hasArg (emitOpt))
664+ return true ;
665+ if (emitOpt == options::OPT_save_optimization_record &&
666+ Args.hasArg (options::OPT_save_optimization_record_EQ))
667+ return true ;
668+ return false ;
669+ };
670+
659671 auto computeDefaultSupplementaryOutputPathExcludingExtension =
660672 [&] () -> std::string {
661673 llvm::SmallString<128 > path (
@@ -666,13 +678,16 @@ SupplementaryOutputPathsComputer::determineSupplementaryOutputFilename(
666678 };
667679
668680 if (forceDefaultSupplementaryOutputPathExcludingExtension) {
681+ if (!hasEmitOptArg ()) {
682+ return std::string ();
683+ }
669684 return computeDefaultSupplementaryOutputPathExcludingExtension ();
670685 }
671686
672687 if (!pathFromArguments.empty ())
673688 return pathFromArguments;
674689
675- if (!Args. hasArg (emitOpt ))
690+ if (!hasEmitOptArg ( ))
676691 return std::string ();
677692
678693 if (!mainOutputIfUsable.empty ()) {
0 commit comments