Skip to content

Fix performance bug in buildLocationList#1

Open
tmsri wants to merge 10000 commits intomainfrom
debug_loc_perf_fix
Open

Fix performance bug in buildLocationList#1
tmsri wants to merge 10000 commits intomainfrom
debug_loc_perf_fix

Conversation

@tmsri
Copy link
Copy Markdown
Owner

@tmsri tmsri commented Sep 16, 2024

Fix performance bug in buildLocationList

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   <blah>
        .loc    0 4 0                           # ex2.cc:4:0
        .cfi_startproc
.Ltmp0:
        #DEBUG_VALUE: test:i <- 7
        .loc    0 8 5 prologue_end              # ex2.cc:8:5
        ....
.LBB_END0_0:
        .cfi_endproc
        .section        .text._Z4testv,"ax",@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.

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.