[PATCH] D97336: [InstrProfiling] Use nobits for __llvm_prf_cnts with binutils >=2.28
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 23 14:31:23 PST 2021
phosek created this revision.
phosek added reviewers: davidxl, MaskRay, mcgrathr.
Herald added a subscriber: hiraditya.
phosek requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
binutils <2.28 have a bug which causes __start_/__stop_ symbols have
incorrect address for nobits section which causes counters to come up
as empty in raw profiles.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D97336
Files:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -425,7 +425,8 @@
MMI, Streamer);
}
-static SectionKind getELFKindForNamedSection(StringRef Name, SectionKind K) {
+static SectionKind getELFKindForNamedSection(MCContext &Ctx, StringRef Name,
+ SectionKind K) {
// N.B.: The defaults used in here are not the same ones used in MC.
// We follow gcc, MC follows gas. For example, given ".section .eh_frame",
// both gas and MC will produce a section with no flags. Given
@@ -441,7 +442,8 @@
return SectionKind::getMetadata();
if (Name == getInstrProfSectionName(IPSK_cnts, Triple::ELF,
- /*AddSegmentInfo=*/false))
+ /*AddSegmentInfo=*/false) &&
+ Ctx.getAsmInfo()->binutilsIsAtLeast(2, 28))
return SectionKind::getBSS();
if (Name.empty() || Name[0] != '.') return K;
@@ -674,7 +676,7 @@
}
// Infer section flags from the section name if we can.
- Kind = getELFKindForNamedSection(SectionName, Kind);
+ Kind = getELFKindForNamedSection(getContext(), SectionName, Kind);
StringRef Group = "";
bool IsComdat = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97336.325897.patch
Type: text/x-patch
Size: 1431 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210223/02630849/attachment.bin>
More information about the llvm-commits
mailing list