[PATCH] D97110: [InstrProfiling] Use nobits as __llvm_prf_cnts section type in ELF

Petr Hosek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Feb 20 14:25:32 PST 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b286d93f7ec: [InstrProfiling] Use nobits as __llvm_prf_cnts section type in ELF (authored by phosek).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97110/new/

https://reviews.llvm.org/D97110

Files:
  llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
  llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll


Index: llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll
===================================================================
--- /dev/null
+++ llvm/test/Instrumentation/InstrProfiling/X86/nobits.ll
@@ -0,0 +1,15 @@
+;; 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
+
+ at __profc_foo = hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", align 8
+
+define void @foo() {
+  %pgocount = load i64, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0), align 4
+  %1 = add i64 %pgocount, 1
+  store i64 %1, i64* getelementptr inbounds ([1 x i64], [1 x i64]* @__profc_foo, i64 0, i64 0), align 4
+  ret void
+}
+
+declare void @llvm.instrprof.increment(i8*, i64, i32, i32)
+
+; CHECK: .section __llvm_prf_cnts,"aw", at nobits
Index: llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
===================================================================
--- llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -440,6 +440,10 @@
       Name == ".llvmbc" || Name == ".llvmcmd")
     return SectionKind::getMetadata();
 
+  if (Name == getInstrProfSectionName(IPSK_cnts, Triple::ELF,
+                                      /*AddSegmentInfo=*/false))
+    return SectionKind::getBSS();
+
   if (Name.empty() || Name[0] != '.') return K;
 
   // Default implementation based on some magic section names.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97110.325246.patch
Type: text/x-patch
Size: 1478 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210220/9a4b5512/attachment.bin>


More information about the llvm-commits mailing list