@@ -302,7 +302,7 @@ SupplementaryOutputPathsComputer::computeOutputPaths() const {
302
302
// In WMO mode compute supplementary output paths for optimization record
303
303
// data (opt-remarks). We need one path per LLVMModule that will be created as
304
304
// part of wmo.
305
- if (!InputsAndOutputs.hasPrimaryInputs () && OutputFiles. size () > 1 ) {
305
+ if (!InputsAndOutputs.hasPrimaryInputs ()) {
306
306
unsigned i = 0 ;
307
307
InputsAndOutputs.forEachInput ([&](const InputFile &input) -> bool {
308
308
// First input is already computed.
@@ -313,23 +313,26 @@ SupplementaryOutputPathsComputer::computeOutputPaths() const {
313
313
SupplementaryOutputPaths outputs;
314
314
315
315
// 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
+ }
333
336
334
337
outputPaths.emplace_back (std::move (outputs));
335
338
++i;
@@ -603,11 +606,11 @@ SupplementaryOutputPathsComputer::computeOutputPathsForOneInput(
603
606
defaultSupplementaryOutputPathExcludingExtension);
604
607
605
608
auto YAMLOptRecordPath = determineSupplementaryOutputFilename (
606
- OPT_save_optimization_record_path , pathsFromArguments.YAMLOptRecordPath ,
609
+ OPT_save_optimization_record , pathsFromArguments.YAMLOptRecordPath ,
607
610
file_types::TY_YAMLOptRecord, " " ,
608
611
defaultSupplementaryOutputPathExcludingExtension);
609
612
auto bitstreamOptRecordPath = determineSupplementaryOutputFilename (
610
- OPT_save_optimization_record_path , pathsFromArguments.BitstreamOptRecordPath ,
613
+ OPT_save_optimization_record , pathsFromArguments.BitstreamOptRecordPath ,
611
614
file_types::TY_BitstreamOptRecord, " " ,
612
615
defaultSupplementaryOutputPathExcludingExtension);
613
616
@@ -656,6 +659,15 @@ SupplementaryOutputPathsComputer::determineSupplementaryOutputFilename(
656
659
StringRef defaultSupplementaryOutputPathExcludingExtension,
657
660
bool forceDefaultSupplementaryOutputPathExcludingExtension) const {
658
661
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
+
659
671
auto computeDefaultSupplementaryOutputPathExcludingExtension =
660
672
[&] () -> std::string {
661
673
llvm::SmallString<128 > path (
@@ -666,13 +678,16 @@ SupplementaryOutputPathsComputer::determineSupplementaryOutputFilename(
666
678
};
667
679
668
680
if (forceDefaultSupplementaryOutputPathExcludingExtension) {
681
+ if (!hasEmitOptArg ()) {
682
+ return std::string ();
683
+ }
669
684
return computeDefaultSupplementaryOutputPathExcludingExtension ();
670
685
}
671
686
672
687
if (!pathFromArguments.empty ())
673
688
return pathFromArguments;
674
689
675
- if (!Args. hasArg (emitOpt ))
690
+ if (!hasEmitOptArg ( ))
676
691
return std::string ();
677
692
678
693
if (!mainOutputIfUsable.empty ()) {
0 commit comments