[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:56:00 PST 2021
phosek updated this revision to Diff 325908.
phosek added a comment.
Updated test and extra comment.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97336/new/
https://reviews.llvm.org/D97336
Files:
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll
Index: llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll
===================================================================
--- llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll
+++ llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll
@@ -1,5 +1,6 @@
;; Ensure that SHT_NOBITS section type is set for __llvm_prf_cnts in ELF.
-; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu | FileCheck %s
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -binutils-version=2.27 | FileCheck %s --check-prefix=OLD
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -binutils-version=2.28 | FileCheck %s --check-prefix=NEW
@__profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
@@ -12,4 +13,5 @@
declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
-; CHECK: .section __llvm_prf_cnts,"aw", at nobits
+; OLD: .section __llvm_prf_cnts,"aw", at progbits
+; NEW: .section __llvm_prf_cnts,"aw", at nobits
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
@@ -440,8 +441,11 @@
Name == ".llvmbc" || Name == ".llvmcmd")
return SectionKind::getMetadata();
+ // GNU binutils ld.bfd <2.28 has a bug which causes __start_/__stop_ symbols
+ // for SHT_NOBITS sections to have incorrect address
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 +678,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.325908.patch
Type: text/x-patch
Size: 2557 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210223/7b983a6b/attachment.bin>
More information about the llvm-commits
mailing list