[PATCH] D37791: [XRay][CodeGen] Use the current function symbol as the associated symbol for the instrumentation map

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 23:07:24 PDT 2017


On Tue, Sep 12, 2017 at 10:42 PM Dean Michael Berris via Phabricator via
llvm-commits <llvm-commits at lists.llvm.org> wrote:

> dberris created this revision.
> Herald added a subscriber: aprantl.
>
> XRay had been assuming that the previous section is the "text" section
> of the function. Unfortunately for in-lined functions where we're also
> generating the comdat definition for debugging purposes, we may be
> coming from a section that isn't "text" (could be .zdebug_types).
>

This statement "unfortunately for in-lined functions where we're also
generating the comdat definition for debugging purposes" is still confusing
to me - I don't think this has anything to do with comdats.

Indeed I think the test case you mentioned having had no inline functions
at all - just that if type units are enabled and any debug types are
emitted during endFunction, then that causes a switch to the debug_types
section, rather than the text section. (most of the DWARF emission is
delayed - we mostly don't switch to DWARF sections and produce DWARF bytes
until the end of the module - except for type units, since they're
whole/complete by themselves the moment we emit the type, so for those we
do it immediately - causing section changes)


>
> This fixes an issue with combining -gsplit-dwarf and -fxray-instrument
> for functions inlined, where the original definition may be lowered
> into the debug sections. When the debug section is stripped, we're
> left with references from the xray_instr_map to the debug section. The
> change now uses the function's symbol instead of the previous
> section's start symbol.
>
>
> https://reviews.llvm.org/D37791
>
> Files:
>   lib/CodeGen/AsmPrinter/AsmPrinter.cpp
>
>
> Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> ===================================================================
> --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp
> @@ -2785,7 +2785,7 @@
>    MCSection *InstMap = nullptr;
>    MCSection *FnSledIndex = nullptr;
>    if (MF->getSubtarget().getTargetTriple().isOSBinFormatELF()) {
> -    auto Associated =
> dyn_cast<MCSymbolELF>(PrevSection->getBeginSymbol());
> +    auto Associated = dyn_cast<MCSymbolELF>(CurrentFnSym);
>      assert(Associated != nullptr);
>      auto Flags = ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_LINK_ORDER;
>      std::string GroupName;
>
>
> _______________________________________________
> 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/20170914/7db0f92e/attachment.html>


More information about the llvm-commits mailing list