Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2383,6 +2383,15 @@ void AsmPrinter::emitRemarksSection(remarks::RemarkStreamer &RS) {
if (!RS.needsSection())
return;

MCSection *RemarksSection =
OutContext.getObjectFileInfo()->getRemarksSection();
if (!RemarksSection) {
OutContext.reportWarning(SMLoc(), "Current object file format does not "
"support remarks sections. Use the yaml "
"remark format instead.");
return;
}

remarks::RemarkSerializer &RemarkSerializer = RS.getSerializer();

std::optional<SmallString<128>> Filename;
Expand All @@ -2400,10 +2409,7 @@ void AsmPrinter::emitRemarksSection(remarks::RemarkStreamer &RS) {
MetaSerializer->emit();

// Switch to the remarks section.
MCSection *RemarksSection =
OutContext.getObjectFileInfo()->getRemarksSection();
OutStreamer->switchSection(RemarksSection);

OutStreamer->emitBinaryData(Buf);
}

Expand Down
5 changes: 5 additions & 0 deletions llvm/test/CodeGen/X86/remarks-section.ll
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
; RUN: llc < %s -mtriple=x86_64-darwin --pass-remarks-format=bitstream -remarks-section=false -pass-remarks-output=%/t.yaml | FileCheck --check-prefix=CHECK-DARWIN-OVERRIDE-BITSTREAM %s
; RUN: llc < %s -mtriple=x86_64-darwin --pass-remarks-format=yaml -remarks-section=true -pass-remarks-output=%/t.yaml | FileCheck --check-prefix=CHECK-DARWIN-OVERRIDE-YAML %s

; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu --pass-remarks-format=bitstream -pass-remarks-output=%/t.yaml 2>&1 | FileCheck --check-prefix=CHECK-LINUX-DEFAULT-BITSTREAM %s

; CHECK-DARWIN: .section __LLVM,__remarks,regular,debug
; CHECK-DARWIN-NEXT: .byte

Expand All @@ -22,3 +24,6 @@
define void @func1() {
ret void
}

; Currently no ELF support for bitstream remarks
; CHECK-LINUX-DEFAULT-BITSTREAM: warning: Current object file format does not support remarks sections.
Loading