]> granicus.if.org Git - clang/commitdiff
[Remarks][Driver] Use the specified format in the remarks file extension
authorFrancis Visoiu Mistrih <francisvm@yahoo.com>
Mon, 17 Jun 2019 22:49:38 +0000 (22:49 +0000)
committerFrancis Visoiu Mistrih <francisvm@yahoo.com>
Mon, 17 Jun 2019 22:49:38 +0000 (22:49 +0000)
By default, use `.opt.yaml`, but when a format is specified with
`-fsave-optimization-record=<format>`, use `.opt.<format>`.

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

docs/UsersManual.rst
lib/Driver/ToolChains/Clang.cpp
lib/Driver/ToolChains/Darwin.cpp
test/Driver/darwin-ld.c
test/Driver/opt-record.c

index 0e2d1c82e92e9f29a59c8962d444ec00d618b5f8..001003a3fa6fcff3029fc4213b7c68588b452d72 100644 (file)
@@ -351,7 +351,9 @@ output format of the diagnostics that it generates.
 
    If this option is not used, optimization records are output to a file named
    after the primary file being compiled. If that's "foo.c", for example,
-   optimization records are output to "foo.opt.yaml".
+   optimization records are output to "foo.opt.yaml". If a specific
+   serialization format is specified, the file will be named
+   "foo.opt.<format>".
 
 .. _opt_foptimization-record-passes:
 
index 82d4da414a662d81f8c69ff751a8d4dbe942c3be..b6264351f9d537e71a3de873d1ae353137f149e0 100644 (file)
@@ -5132,9 +5132,17 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
         }
       }
 
-      llvm::sys::path::replace_extension(F, "opt.yaml");
+      std::string Extension = "opt.";
+      if (const Arg *A =
+              Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+        Extension += A->getValue();
+      else
+        Extension += "yaml";
+
+      llvm::sys::path::replace_extension(F, Extension);
       CmdArgs.push_back(Args.MakeArgString(F));
     }
+
     if (const Arg *A =
             Args.getLastArg(options::OPT_foptimization_record_passes_EQ)) {
       CmdArgs.push_back("-opt-record-passes");
index fbdc0b50189b4dbd3897443dad910cb36da32604..5de7d7132df818964a8ad8c81273d681436f6062 100644 (file)
@@ -470,7 +470,13 @@ void darwin::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
     SmallString<128> F;
     F = Output.getFilename();
-    F += ".opt.yaml";
+    F += ".opt.";
+    if (const Arg *A =
+            Args.getLastArg(options::OPT_fsave_optimization_record_EQ))
+      F += A->getValue();
+    else
+      F += "yaml";
+
     CmdArgs.push_back(Args.MakeArgString(F));
 
     if (getLastProfileUseArg(Args)) {
index 9dc31297e8bc14ba27dab469be13fcb56695e46a..f01eeb4ea28e029990199376fdeb7c8c2161b962 100644 (file)
 //
 // RUN: %clang -target x86_64-apple-darwin12 %t.o -fsave-optimization-record=some-format -### -o foo/bar.out 2> %t.log
 // RUN: FileCheck -check-prefix=PASS_REMARKS_WITH_FORMAT %s < %t.log
-// PASS_REMARKS_WITH_FORMAT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.yaml" "-mllvm" "-lto-pass-remarks-format=some-format"
+// PASS_REMARKS_WITH_FORMAT: "-mllvm" "-lto-pass-remarks-output" "-mllvm" "foo/bar.out.opt.some-format" "-mllvm" "-lto-pass-remarks-format=some-format"
 
 // RUN: %clang -target x86_64-apple-ios6.0 -miphoneos-version-min=6.0 -fprofile-instr-generate -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=LINK_PROFILE_FIRST %s < %t.log
index f7dd5eb740cb616095bd3f6ca6ac0b83eee7ebf9..062d0acc17da88659761a28a5eb22f39ade9492a 100644 (file)
@@ -37,6 +37,7 @@
 // CHECK-FOPT-DISABLE-PASSES-NOT: "-fno-save-optimization-record"
 
 // CHECK-EQ-FORMAT: "-cc1"
+// CHECK-EQ-FORMAT: "-opt-record-file" "FOO.opt.some-format"
 // CHECK-EQ-FORMAT: "-opt-record-format" "some-format"
 
 // CHECK-FOPT-DISABLE-FORMAT-NOT: "-fno-save-optimization-record"