Commit 7902d6cc authored by Francis Visoiu Mistrih's avatar Francis Visoiu Mistrih
Browse files

[Remarks][ThinLTO] Use the correct file extension based on the format

Since we now have multiple formats, the ThinLTO remark files should also
respect that.
parent 8f2c100f
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1381,8 +1381,12 @@ lto::setupOptimizationRemarks(LLVMContext &Context, StringRef RemarksFilename,
                              StringRef RemarksPasses, StringRef RemarksFormat,
                              bool RemarksWithHotness, int Count) {
  std::string Filename = RemarksFilename;
  // For ThinLTO, file.opt.<format> becomes
  // file.opt.<format>.thin.<num>.<format>.
  if (!Filename.empty() && Count != -1)
    Filename += ".thin." + llvm::utostr(Count) + ".yaml";
    Filename =
        (Twine(Filename) + ".thin." + llvm::utostr(Count) + "." + RemarksFormat)
            .str();

  auto ResultOrErr = llvm::setupOptimizationRemarks(
      Context, Filename, RemarksPasses, RemarksFormat, RemarksWithHotness);
+13 −0
Original line number Diff line number Diff line
@@ -51,6 +51,19 @@
; YAML2-NEXT:   - String:          ')'
; YAML2-NEXT: ...

; The file extension depends on the format of the remarks
; RUN: rm -f %t.bitstream.thin.0.bitstream %t.bitstream.thin.1.bitstream
; RUN: llvm-lto -thinlto-action=run \
; RUN:          -lto-pass-remarks-output=%t.bitstream \
; RUN:          -lto-pass-remarks-filter=inline \
; RUN:          -lto-pass-remarks-format=bitstream \
; RUN:          -exported-symbol _func2 \
; RUN:          -exported-symbol _main %t1.bc %t2.bc 2>&1 | \
; RUN:     FileCheck %s -allow-empty
; RUN: llvm-bcanalyzer %t.bitstream.thin.0.bitstream
; RUN: llvm-bcanalyzer %t.bitstream.thin.1.bitstream
; CHECK-NOT: remark:
; CHECK-NOT: llvm-lto:

target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.11.0"