[CodeGen] Speedup stack slot sharing during stack coloring (interval overlapping...
authorValery Pykhtin <valery.pykhtin@gmail.com>
Tue, 14 Mar 2023 15:30:46 +0000 (16:30 +0100)
committerValery Pykhtin <valery.pykhtin@gmail.com>
Thu, 6 Apr 2023 05:23:45 +0000 (07:23 +0200)
commite09b33feec1991876a3093d86348818df8b8edae
treefbf7f29b1467b35ef4b49661b80c94336143e85e
parent1ccd8cd6e68c1edfdfc0dbc21f4afb75f3a338e0
[CodeGen] Speedup stack slot sharing during stack coloring (interval overlapping test).

AMDGPU code with enabled address sanitizer generates tons of stack objects (> 200000 in my testcase) and
takes forever to compile due to the time spent on stack slot sharing.

While LiveRange::overlaps method has logarithmic complexity on the number of segments in the involved
liveranges the problem is that when a new interval is assigned to a used color it's tested against
overlapping every other assigned interval for that color.

Instead I decided to join all assigned intervals for a color into a single interval and this allows to
have logarithmic complexity on the number of segments for the joined interval.

This patch reduced time spent on stack slot coloring pass from 628 to 3 seconds on my testcase.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D146057
llvm/lib/CodeGen/StackSlotColoring.cpp