[all-commits] [llvm/llvm-project] c7ef00: Fix performance bug in buildLocationList (#109343)

Sriraman Tallam via All-commits all-commits at lists.llvm.org
Thu Oct 31 09:00:49 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c7ef002bc6a6b99371865a416da781d0374c69fd
      https://github.com/llvm/llvm-project/commit/c7ef002bc6a6b99371865a416da781d0374c69fd
  Author: Sriraman Tallam <38991943+tmsri at users.noreply.github.com>
  Date:   2024-10-31 (Thu, 31 Oct 2024)

  Changed paths:
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
    A llvm/test/DebugInfo/X86/basic-block-sections-debug-loclist-6.ll
    A llvm/test/DebugInfo/X86/basic-block-sections-debug-loclist-7.ll
    A llvm/test/DebugInfo/X86/basic-block-sections-debug-loclist-8.ll
    A llvm/test/DebugInfo/X86/basic-block-sections-debug-loclist-9.ll
    M llvm/test/DebugInfo/X86/basic-block-sections_1.ll

  Log Message:
  -----------
  Fix performance bug in buildLocationList (#109343)

In buildLocationList, with basic block sections, we iterate over
every basic block twice to detect section start and end. This is
sub-optimal and shows up as significantly time consuming when
compiling large functions.

This patch uses the set of sections already stored in MBBSectionRanges
and iterates over sections rather than basic blocks.

When detecting if loclists can be merged, the end label of an entry is
matched with the beginning label of the next entry. For the section
corresponding to the entry basic block, this is skipped. This is
because the loc list uses the end label corresponding to the function
whereas the MBBSectionRanges map uses the function end label.

For example:

.Lfunc_begin0:
.file
.loc 0 4 0 # ex2.cc:4:0
.cfi_startproc
.Ltmp0:
.loc 0 8 5 prologue_end # ex2.cc:8:5
....
.LBB_END0_0:
.cfi_endproc
.section .text._Z4testv,"ax", at progbits,unique,1
...
.Lfunc_end0:
.size _Z4testv, .Lfunc_end0-_Z4testv

The debug loc uses ".LBB_END0_0" for the end of the section whereas
MBBSectionRanges uses ".Lfunc_end0".

It is alright to skip this as we already check the section corresponding
to the debugloc entry.

Added a new test case to check that if this works correctly when the
variable's value is mutated in the entry section.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list