[llvm] r277580 - [XRay] Make the xray_instr_map section specification more correct

David Majnemer via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 3 09:17:00 PDT 2016


On Wed, Aug 3, 2016 at 12:21 AM, Dean Michael Berris via llvm-commits <
llvm-commits at lists.llvm.org> wrote:

> Author: dberris
> Date: Wed Aug  3 02:21:55 2016
> New Revision: 277580
>
> URL: http://llvm.org/viewvc/llvm-project?rev=277580&view=rev
> Log:
> [XRay] Make the xray_instr_map section specification more correct
>
> Summary:
> We also add a test to show what currently happens when we create a
> section per function and emit an xray_instr_map. This illustrates the
> relationship (or lack thereof) between the per-function section and the
> xray_instr_map section.
>
> We also change the code generation slightly so that we don't always
> create group sections, but rather only do so if a function where the
> table is associated with is in a group.
>
> Also in this change:
>
>   - Remove the "merge" flag on the xray_instr_map section.
>   - Test that we're generating the right table for comdat and non-comdat
> functions.
>
> Reviewers: echristo, majnemer
>
> Subscribers: llvm-commits, mehdi_amini
>
> Differential Revision: https://reviews.llvm.org/D23104
>
> Added:
>     llvm/trunk/test/CodeGen/X86/xray-section-group.ll
> Modified:
>     llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
>
> Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=277580&r1=277579&r2=277580&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Wed Aug  3 02:21:55 2016
> @@ -1096,11 +1096,18 @@ void X86AsmPrinter::EmitXRayTable() {
>    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 {
>

This will not correctly handle the -ffunction-sections case.  In that case,
we want to make it COMDAT associative with Fn.


> +      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);
>
> Added: llvm/trunk/test/CodeGen/X86/xray-section-group.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xray-section-group.ll?rev=277580&view=auto
>
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/xray-section-group.ll (added)
> +++ llvm/trunk/test/CodeGen/X86/xray-section-group.ll Wed Aug  3 02:21:55
> 2016
> @@ -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
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160803/34887224/attachment.html>


More information about the llvm-commits mailing list