* [PATCH] Fix possible sanopt compile-time hog
@ 2023-02-14 15:20 Richard Biener
2023-02-14 15:55 ` Jakub Jelinek
0 siblings, 1 reply; 2+ messages in thread
From: Richard Biener @ 2023-02-14 15:20 UTC (permalink / raw)
To: gcc-patches; +Cc: Jakub Jelinek
While working on bitmap operations I figured sanopt.cc uses
a sbitmap worklist, iterating using bitmap_first_set_bit on it.
That's quadratic since bitmap_first_set_bit for sbitmap is O(n).
The fix is to use regular bitmaps for the worklist and the bitmap
feeding it and to avoid a useless copy.
Bootstrap and regtest running on x86_64-unknown-linux-gnu.
OK for trunk?
Thanks,
Richard.
* sanopt.cc (sanitize_asan_mark_unpoison): Use bitmap
for with_poison and alias worklist to it.
(sanitize_asan_mark_poison): Likewise.
---
gcc/sanopt.cc | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/gcc/sanopt.cc b/gcc/sanopt.cc
index aed22850079..b356a21eca3 100644
--- a/gcc/sanopt.cc
+++ b/gcc/sanopt.cc
@@ -987,15 +987,11 @@ static void
sanitize_asan_mark_unpoison (void)
{
/* 1) Find all BBs that contain an ASAN_MARK poison call. */
- auto_sbitmap with_poison (last_basic_block_for_fn (cfun) + 1);
- bitmap_clear (with_poison);
+ auto_bitmap with_poison;
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
{
- if (bitmap_bit_p (with_poison, bb->index))
- continue;
-
gimple_stmt_iterator gsi;
for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
{
@@ -1010,8 +1006,8 @@ sanitize_asan_mark_unpoison (void)
auto_sbitmap poisoned (last_basic_block_for_fn (cfun) + 1);
bitmap_clear (poisoned);
- auto_sbitmap worklist (last_basic_block_for_fn (cfun) + 1);
- bitmap_copy (worklist, with_poison);
+ /* We now treat with_poison as worklist. */
+ bitmap worklist = with_poison;
/* 2) Propagate the information to all reachable blocks. */
while (!bitmap_empty_p (worklist))
@@ -1088,8 +1084,7 @@ static void
sanitize_asan_mark_poison (void)
{
/* 1) Find all BBs that possibly contain an ASAN_CHECK. */
- auto_sbitmap with_check (last_basic_block_for_fn (cfun) + 1);
- bitmap_clear (with_check);
+ auto_bitmap with_check;
basic_block bb;
FOR_EACH_BB_FN (bb, cfun)
@@ -1108,8 +1103,8 @@ sanitize_asan_mark_poison (void)
auto_sbitmap can_reach_check (last_basic_block_for_fn (cfun) + 1);
bitmap_clear (can_reach_check);
- auto_sbitmap worklist (last_basic_block_for_fn (cfun) + 1);
- bitmap_copy (worklist, with_check);
+ /* We now treat with_check as worklist. */
+ bitmap worklist = with_check;
/* 2) Propagate the information to all definitions blocks. */
while (!bitmap_empty_p (worklist))
--
2.35.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Fix possible sanopt compile-time hog
2023-02-14 15:20 [PATCH] Fix possible sanopt compile-time hog Richard Biener
@ 2023-02-14 15:55 ` Jakub Jelinek
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Jelinek @ 2023-02-14 15:55 UTC (permalink / raw)
To: Richard Biener; +Cc: gcc-patches
On Tue, Feb 14, 2023 at 04:20:24PM +0100, Richard Biener wrote:
> While working on bitmap operations I figured sanopt.cc uses
> a sbitmap worklist, iterating using bitmap_first_set_bit on it.
> That's quadratic since bitmap_first_set_bit for sbitmap is O(n).
>
> The fix is to use regular bitmaps for the worklist and the bitmap
> feeding it and to avoid a useless copy.
>
> Bootstrap and regtest running on x86_64-unknown-linux-gnu.
>
> OK for trunk?
>
> Thanks,
> Richard.
>
> * sanopt.cc (sanitize_asan_mark_unpoison): Use bitmap
> for with_poison and alias worklist to it.
> (sanitize_asan_mark_poison): Likewise.
Ok, thanks.
Jakub
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-14 15:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-14 15:20 [PATCH] Fix possible sanopt compile-time hog Richard Biener
2023-02-14 15:55 ` Jakub Jelinek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).