Skip to content

[Coverage] Mark coverage sections as metadata sections on COFF. #76834

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
11 changes: 10 additions & 1 deletion llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1669,9 +1669,18 @@ static int getSelectionForCOFF(const GlobalValue *GV) {

MCSection *TargetLoweringObjectFileCOFF::getExplicitSectionGlobal(
const GlobalObject *GO, SectionKind Kind, const TargetMachine &TM) const {
StringRef Name = GO->getSection();
if (Name == getInstrProfSectionName(IPSK_covmap, Triple::COFF,
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covfun, Triple::COFF,
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covdata, Triple::COFF,
/*AddSegmentInfo=*/false) ||
Name == getInstrProfSectionName(IPSK_covname, Triple::COFF,
/*AddSegmentInfo=*/false))
Kind = SectionKind::getMetadata();
int Selection = 0;
unsigned Characteristics = getCOFFSectionFlags(Kind, TM);
StringRef Name = GO->getSection();
StringRef COMDATSymName = "";
if (GO->hasComdat()) {
Selection = getSelectionForCOFF(GO);
Expand Down
15 changes: 15 additions & 0 deletions llvm/test/CodeGen/X86/cov-sections.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
; RUN: llc < %s -mtriple=x86_64-pc-windows-msvc -filetype=obj -o - | llvm-readobj -S - | FileCheck %s

@covmap = private global i32 0, section ".lcovmap$M"
@covfun = private global i32 0, section ".lcovfun$M"
@covname = private global i32 0, section ".lcovd"
@covdata= private global i32 0, section ".lcovn"

; CHECK: Name: .lcovmap$M
; CHECK: IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
; CHECK: Name: .lcovfun$M
; CHECK: IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
; CHECK: Name: .lcovd
; CHECK: IMAGE_SCN_MEM_DISCARDABLE (0x2000000)
; CHECK: Name: .lcovn
; CHECK: IMAGE_SCN_MEM_DISCARDABLE (0x2000000)