[PATCH] D23104: [XRay] Set entsize for the xray_instr_map section
Dean Michael Berris via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 3 00:07:43 PDT 2016
dberris updated this revision to Diff 66621.
dberris added a comment.
- Only use groups if the original function is defined in a group too
https://reviews.llvm.org/D23104
Files:
lib/Target/X86/X86MCInstLower.cpp
test/CodeGen/X86/xray-section-group.ll
Index: test/CodeGen/X86/xray-section-group.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/xray-section-group.ll
@@ -0,0 +1,14 @@
+; RUN: llc -filetype=asm -o - -mtriple=x86_64-unknown-linux-gnu -function-sections < %s | FileCheck %s
+
+define i32 @foo() nounwind noinline uwtable "function-instrument"="xray-always" {
+; CHECK: .section .text.foo,"ax", at progbits
+ ret i32 0
+; CHECK: .section xray_instr_map,"a", at progbits
+}
+
+$bar = comdat any
+define i32 @comdat() nounwind noinline uwtable "function-instrument"="xray-always" comdat($bar) {
+; CHECK: .section .text.comdat,"axG", at progbits,bar,comdat
+ ret i32 1
+; CHECK: .section xray_instr_map,"aG", at progbits,bar,comdat
+}
Index: lib/Target/X86/X86MCInstLower.cpp
===================================================================
--- lib/Target/X86/X86MCInstLower.cpp
+++ lib/Target/X86/X86MCInstLower.cpp
@@ -1096,11 +1096,18 @@
if (Sleds.empty())
return;
if (Subtarget->isTargetELF()) {
- auto *Section = OutContext.getELFSection(
- "xray_instr_map", ELF::SHT_PROGBITS,
- ELF::SHF_ALLOC | ELF::SHF_GROUP | ELF::SHF_MERGE, 0,
- CurrentFnSym->getName());
auto PrevSection = OutStreamer->getCurrentSectionOnly();
+ auto Fn = MF->getFunction();
+ MCSection *Section = nullptr;
+ if (Fn->hasComdat()) {
+ Section = OutContext.getELFSection("xray_instr_map", ELF::SHT_PROGBITS,
+ ELF::SHF_ALLOC | ELF::SHF_GROUP, 0,
+ Fn->getComdat()->getName());
+ OutStreamer->SwitchSection(Section);
+ } else {
+ Section = OutContext.getELFSection("xray_instr_map", ELF::SHT_PROGBITS,
+ ELF::SHF_ALLOC);
+ }
OutStreamer->SwitchSection(Section);
for (const auto &Sled : Sleds) {
OutStreamer->EmitSymbolValue(Sled.Sled, 8);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23104.66621.patch
Type: text/x-patch
Size: 1930 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160803/408582dc/attachment.bin>
More information about the llvm-commits
mailing list