public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
@ 2022-03-16 13:01 dmalcolm at gcc dot gnu.org
  2022-03-16 13:03 ` [Bug analyzer/104954] " rguenth at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-16 13:01 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

            Bug ID: 104954
           Summary: Analyzer takes a very long time on Linux kernel
                    drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: analyzer
          Assignee: dmalcolm at gcc dot gnu.org
          Reporter: dmalcolm at gcc dot gnu.org
  Target Milestone: ---

According to my notes, attempting to build a Linux kernel with -fanalyzer, I
found that building:
  drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/dce_calcs.c
was taking over 15 hours; I think this was with a debug build of cc1.

On testing this with trunk this week, I saw it take about 31 minutes on a debug
build, and about 4 minutes on a release build.

Am attaching preprocessed source.

Compilation flags in use the 4 minute build (with release build of cc1):

./xgcc -B. -fanalyzer -S ../../src/dce_calcs.i -nostdinc -fmacro-prefix-map=./=
-Wall -Wundef -Werror=strict-prototypes -Wno-trigraphs -fno-strict-aliasing
-fno-common -fshort-wchar -fno-PIE -Werror=implicit-function-declaration
-Werror=implicit-int -Werror=return-type -Wno-format-security -std=gnu89
-mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -fcf-protection=none -m64
-falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387
-mpreferred-stack-boundary=3 -mskip-rax-setup -mtune=generic -mno-red-zone
-mcmodel=kernel -Wno-sign-compare -fno-asynchronous-unwind-tables
-mindirect-branch=thunk-extern -mindirect-branch-register -fno-jump-tables
-fno-delete-null-pointer-checks -Wno-frame-address -Wno-format-truncation
-Wno-format-overflow -Wno-address-of-packed-member -O2
-fno-allow-store-data-races -Wframe-larger-than=2048 -fstack-protector-strong
-Wimplicit-fallthrough=5 -Wno-unused-but-set-variable
-Wno-unused-const-variable -fno-stack-clash-protection -g -pg -mrecord-mcount
-mfentry -DCC_USING_FENTRY -fno-inline-functions-called-once
-Wdeclaration-after-statement -Wvla -Wno-pointer-sign -Wno-stringop-truncation
-Wno-zero-length-bounds -Wno-array-bounds -Wno-stringop-overflow -Wno-restrict
-Wno-maybe-uninitialized -fno-strict-overflow -fno-stack-check -fconserve-stack
-Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init
-Wno-packed-not-aligned -fanalyzer -Wno-analyzer-null-dereference
-Wno-analyzer-use-of-uninitialized-value -Wno-array-bounds
-Wno-analyzer-null-argument -Wno-analyzer-shift-count-overflow
-Wno-analyzer-use-of-pointer-in-stale-stack-frame
-Wno-analyzer-shift-count-negative -Wno-analyzer-write-to-const
-Wno-use-after-free -fsanitize=kernel-address
-fasan-shadow-offset=0xdffffc0000000000   --param asan-globals=1   --param
asan-instrumentation-with-call-threshold=10000   --param
asan-instrument-allocas=1   --param asan-stack=1

(i.e. with various -Wno-analyzer-* flags; perhaps re-enabling these will
trigger the more extreme multihour slowdown)

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
@ 2022-03-16 13:03 ` rguenth at gcc dot gnu.org
  2022-03-16 13:07 ` dmalcolm at gcc dot gnu.org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu.org @ 2022-03-16 13:03 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
Does not enabling sanitizer improve things?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
  2022-03-16 13:03 ` [Bug analyzer/104954] " rguenth at gcc dot gnu.org
@ 2022-03-16 13:07 ` dmalcolm at gcc dot gnu.org
  2022-03-16 13:13 ` dmalcolm at gcc dot gnu.org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-16 13:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |104943

--- Comment #2 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Part of the slowdown may relate to PR analyzer/104943: "perf" shows lots of
time spent traversing state objects, and I'm seeing huge numbers of temporaries
that aren't getting purged.  The state bindings show dozens of "region:
{<anonymous>, value: UNKNOWN(struct bw_fixed)}") presumably relating to struct
temporaries.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104943
[Bug 104943] Analyzer fails to purge state for local structs

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
  2022-03-16 13:03 ` [Bug analyzer/104954] " rguenth at gcc dot gnu.org
  2022-03-16 13:07 ` dmalcolm at gcc dot gnu.org
@ 2022-03-16 13:13 ` dmalcolm at gcc dot gnu.org
  2022-03-16 13:16 ` dmalcolm at gcc dot gnu.org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-16 13:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #3 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
I'm also seeing states with dozens of bindings for touched regions for
__UNIQUE_ID_ddebugN for various N:

VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
clusters within :: {, region: {__UNIQUE_ID_ddebug277, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug277) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug278, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug278) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug279, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug279) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug280, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug280) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug281, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug281) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug282, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug282) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug283, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug283) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug284, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug284) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug285, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug285) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug286, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug286) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug287, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug287) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug288, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug288) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug289, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug289) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug290, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug290) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug291, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug291) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug292, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug292) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug293, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug293) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug294, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug294) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug295, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug295) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug296, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug296) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug297, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug297) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug298, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug298) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug299, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug299) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug300, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug300) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug301, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug301) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug302, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug302) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug303, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug303) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug304, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug304) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug305, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug305) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug306, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (value_4(D));, __UNIQUE_ID_ddebug306) (ESCAPED)
(TOUCHED)}, region: {__UNIQUE_ID_ddebug307, value: CONJURED(D.56070 =
bw_int_to_fixed_nonconst (
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

where these seem to be coming from macro expansions of debug logging like this:

VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
            static void print_bw_calcs_dceip(struct dc_context *ctx,
                                 const struct bw_calcs_dceip *dceip) {

  do {
    static struct _ddebug __attribute__((__aligned__(8)))
    __attribute__((__section__("__dyndbg"))) __UNIQUE_ID_ddebug277 = {
        .modname = "amdgpu",
        .function = __func__,
        .filename =
            "drivers/gpu/drm/amd/amdgpu/../display/dc/calcs/calcs_logger.h",
        .format = ("[BANDWIDTH_CALCS]:"
                  
"###########################################################"
                   "##########"),
        .lineno = 33,
        .flags = 0,
        .key.dd_key_false = ((struct static_key_false){
            .key = {.enabled = {0}, {.entries = (void *)0UL}},
        })};
    if (({
          bool branch;
          if (__builtin_types_compatible_p(
                  typeof(*&__UNIQUE_ID_ddebug277.key.dd_key_false),
                  struct static_key_true))
            branch = arch_static_branch_jump(
                &(&__UNIQUE_ID_ddebug277.key.dd_key_false)->key, false);
          else if (__builtin_types_compatible_p(
                       typeof(*&__UNIQUE_ID_ddebug277.key.dd_key_false),
                       struct static_key_false))
            branch = arch_static_branch(
                &(&__UNIQUE_ID_ddebug277.key.dd_key_false)->key, false);
          else
            branch = ____wrong_branch_error();
          __builtin_expect(!!(branch), 0);
        }))
      __dynamic_pr_debug(&__UNIQUE_ID_ddebug277,
                         "[BANDWIDTH_CALCS]:"
                        
"#####################################################"
                         "################");
  } while (0);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
and there are a *lot* of these.

Each of these calls to __dynamic_pr_debug escapes the region, so each of these
escaped regions gets clobbered by every unknown function.

VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV
extern __attribute__((__format__(printf, 2, 3))) void
__dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

(should this take a const descriptor???)


We're effectively accumulating the set of all of these that have ever escaped,
and combining that with the set of unknown functions that have been called, and
generating a complicated matrix of values, none of which we care about; the
contents are completely uninteresting.

I've experimented with fixing this by simply not bothering to track regions for
decls with a non-NULL DECL_SECTION_NAME, which eliminates the bindings above,
but it doesn't seem to help much with the timing (still seeing lots of the
comment #2 material).

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2022-03-16 13:13 ` dmalcolm at gcc dot gnu.org
@ 2022-03-16 13:16 ` dmalcolm at gcc dot gnu.org
  2022-03-16 13:56 ` dmalcolm at gcc dot gnu.org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-16 13:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
Created attachment 52634
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=52634&action=edit
Gzipped preprocessed source, unreduced

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2022-03-16 13:16 ` dmalcolm at gcc dot gnu.org
@ 2022-03-16 13:56 ` dmalcolm at gcc dot gnu.org
  2022-03-18 23:21 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-16 13:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |104955

--- Comment #5 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to David Malcolm from comment #0)
> (i.e. with various -Wno-analyzer-* flags; perhaps re-enabling these will
> trigger the more extreme multihour slowdown)

Perhaps this related to PR analyzer/104955 also?  But if so, I think it's still
checking feasibility even before rejecting the diagnostic due to the
-Wno-analyzer-* option flag within diagnostic.cc.  If that's the case we could
reject such diagnostics earlier.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104955
[Bug 104955] Analyzer slowdown with many diagnostics

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2022-03-16 13:56 ` dmalcolm at gcc dot gnu.org
@ 2022-03-18 23:21 ` cvs-commit at gcc dot gnu.org
  2022-03-18 23:26 ` dmalcolm at gcc dot gnu.org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-18 23:21 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:faacafd2306ad7ece721a79dedbb6e44e0d65bdb

commit r12-7718-gfaacafd2306ad7ece721a79dedbb6e44e0d65bdb
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Dec 7 19:22:47 2021 -0500

    analyzer: extend state-purging to locals [PR104943]

    The existing analyzer code attempts to purge the state of SSA names
    where it can in order to minimize the size of program_state instances,
    and to increase the chances of being able to reuse exploded_node
    instances whilst exploring the user's code.

    PR analyzer/104943 identifies that we fail to purge state of local
    variables, based on behavior seen in PR analyzer/104954 when attempting
    to profile slow performance of -fanalyzer on a particular file in the
    Linux kernel, where that testcase has many temporary "boxed" values of
    structs containing ints, which are never cleaned up, leading to bloat
    of the program_state instances (specifically, of the store objects).

    This patch generalizes the state purging from just being on SSA names
    to also work on local variables.  Doing so requires that we detect where
    addresses to a local variable (or within them) are taken; we assume that
    once a pointer has been taken, it's not longer safe to purge the value
    of that decl at any successor point within the function.

    Doing so speeds up the PR analyzer/104954 Linux kernel analyzer testcase
    from taking 254 seconds to "just" 186 seconds (and I have a followup
    patch in development that seems to further reduce this to 37 seconds).

    The patch may also help with scaling up taint-detection so that it can
    eventually be turned on by default, but we're not quite there (this
    is PR analyzer/103533).

    gcc/analyzer/ChangeLog:
            PR analyzer/104943
            PR analyzer/104954
            PR analyzer/103533
            * analyzer.h (class state_purge_per_decl): New forward decl.
            * engine.cc (impl_run_checkers): Pass region_model_manager to
            state_purge_map ctor.
            * program-point.cc (function_point::final_stmt_p): New.
            (function_point::get_next): New.
            * program-point.h (function_point::final_stmt_p): New decl.
            (function_point::get_next): New decl.
            * program-state.cc (program_state::prune_for_point): Generalize to
            purge local decls as well as SSA names.
            (program_state::can_purge_base_region_p): New.
            * program-state.h (program_state::can_purge_base_region_p): New
            decl.
            * region-model.cc (struct append_ssa_names_cb_data): Rename to...
            (struct append_regions_cb_data): ...this.
            (region_model::get_ssa_name_regions_for_current_frame): Rename
            to...
            (region_model::get_regions_for_current_frame): ...this, updating
            for other renamings.
            (region_model::append_ssa_names_cb): Rename to...
            (region_model::append_regions_cb): ...this, and drop the
requirement
            that the subregion be a SSA name.
            * region-model.h (struct append_ssa_names_cb_data): Rename decl
            to...
            (struct append_regions_cb_data): ...this.
            (region_model::get_ssa_name_regions_for_current_frame): Rename
            decl to...
            (region_model::get_regions_for_current_frame): ...this.
            (region_model::append_ssa_names_cb): Rename decl to...
            (region_model::append_regions_cb): ...this.
            * state-purge.cc: Include "tristate.h", "selftest.h",
            "analyzer/store.h", "analyzer/region-model.h", and
            "gimple-walk.h".
            (get_candidate_for_purging): New.
            (class gimple_op_visitor): New.
            (my_load_cb): New.
            (my_store_cb): New.
            (my_addr_cb): New.
            (state_purge_map::state_purge_map): Add "mgr" param.  Update for
            renamings.  Find uses of local variables.
            (state_purge_map::~state_purge_map): Update for renaming of m_map
            to m_ssa_map.  Clean up m_decl_map.
            (state_purge_map::get_or_create_data_for_decl): New.
            (state_purge_per_ssa_name::state_purge_per_ssa_name): Update for
            inheriting from state_purge_per_tree.
            (state_purge_per_ssa_name::add_to_worklist): Likewise.
            (state_purge_per_decl::state_purge_per_decl): New.
            (state_purge_per_decl::add_needed_at): New.
            (state_purge_per_decl::add_pointed_to_at): New.
            (state_purge_per_decl::process_worklists): New.
            (state_purge_per_decl::add_to_worklist): New.
            (same_binding_p): New.
            (fully_overwrites_p): New.
            (state_purge_per_decl::process_point_backwards): New.
            (state_purge_per_decl::process_point_forwards): New.
            (state_purge_per_decl::needed_at_point_p): New.
            (state_purge_annotator::print_needed): Generalize to print local
            decls as well as SSA names.
            * state-purge.h (class state_purge_map): Update leading comment.
            (state_purge_map::map_t): Rename to...
            (state_purge_map::ssa_map_t): ...this.
            (state_purge_map::iterator): Rename to...
            (state_purge_map::ssa_iterator): ...this.
            (state_purge_map::decl_map_t): New typedef.
            (state_purge_map::decl_iterator): New typedef.
            (state_purge_map::state_purge_map): Add "mgr" param.
            (state_purge_map::get_data_for_ssa_name): Update for renaming.
            (state_purge_map::get_any_data_for_decl): New.
            (state_purge_map::get_or_create_data_for_decl): New decl.
            (state_purge_map::begin): Rename to...
            (state_purge_map::begin_ssas): ...this.
            (state_purge_map::end): Rename to...
            (state_purge_map::end_ssa): ...this.
            (state_purge_map::begin_decls): New.
            (state_purge_map::end_decls): New.
            (state_purge_map::m_map): Rename to...
            (state_purge_map::m_ssa_map): ...this.
            (state_purge_map::m_decl_map): New field.
            (class state_purge_per_tree): New class.
            (class state_purge_per_ssa_name): Inherit from
state_purge_per_tree.
            (state_purge_per_ssa_name::get_function): Move to base class.
            (state_purge_per_ssa_name::point_set_t): Likewise.
            (state_purge_per_ssa_name::m_fun): Likewise.
            (class state_purge_per_decl): New.

    gcc/testsuite/ChangeLog:
            PR analyzer/104943
            PR analyzer/104954
            PR analyzer/103533
            * gcc.dg/analyzer/torture/boxed-ptr-1.c: Update expected number
            of exploded nodes to reflect improvements in state purging.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2022-03-18 23:21 ` cvs-commit at gcc dot gnu.org
@ 2022-03-18 23:26 ` dmalcolm at gcc dot gnu.org
  2022-03-25  1:00 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-18 23:26 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954
Bug 104954 depends on bug 104943, which changed state.

Bug 104943 Summary: Analyzer fails to purge state for local structs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104943

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |FIXED

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (6 preceding siblings ...)
  2022-03-18 23:26 ` dmalcolm at gcc dot gnu.org
@ 2022-03-25  1:00 ` cvs-commit at gcc dot gnu.org
  2022-03-25  1:17 ` dmalcolm at gcc dot gnu.org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-25  1:00 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #7 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:5f6197d7c197f9d2b7fb2e1a19dac39a023755e8

commit r12-7809-g5f6197d7c197f9d2b7fb2e1a19dac39a023755e8
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Thu Mar 24 20:58:10 2022 -0400

    analyzer: add region::tracked_p to optimize state objects [PR104954]

    PR analyzer/104954 tracks that -fanalyzer was taking a very long time
    on a particular source file in the Linux kernel:
      drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c

    One issue occurs with the repeated use of dynamic debug lines e.g. via
    the DC_LOG_BANDWIDTH_CALCS macro, such as in print_bw_calcs_dceip in
    drivers/gpu/drm/amd/display/dc/calcs/calcs_logger.h:

     
DC_LOG_BANDWIDTH_CALCS("#####################################################################");
      DC_LOG_BANDWIDTH_CALCS("struct bw_calcs_dceip");
     
DC_LOG_BANDWIDTH_CALCS("#####################################################################");

      [...snip dozens of lines...]

      DC_LOG_BANDWIDTH_CALCS("[bw_fixed] dmif_request_buffer_size: %d",
                             bw_fixed_to_int(dceip->dmif_request_buffer_size));

    When this is configured to use __dynamic_pr_debug, each of these becomes
    code like:

      do {
        static struct _ddebug __attribute__((__aligned__(8)))
        __attribute__((__section__("__dyndbg"))) __UNIQUE_ID_ddebug277 = {
          [...snip...]
        };
        if (arch_static_branch(&__UNIQUE_ID_ddebug277.key, false))
          __dynamic_pr_debug(&__UNIQUE_ID_ddebug277, [...the message...]);
      } while (0);

    The analyzer was naively seeing each call to __dynamic_pr_debug, noting
    that the __UNIQUE_ID_nnnn object escapes.  At each call, as successive
    __UNIQUE_ID_nnnn object escapes, there are N escaped objects, and thus N
    need clobbering, and so we have O(N^2) clobbering of escaped objects
overall,
    leading to huge amounts of pointless work: print_bw_calcs_data has 225
    uses of DC_LOG_BANDWIDTH_CALCS, many of which are in loops.

    This patch adds a way to identify declarations that aren't interesting
    to the analyzer, so that we don't attempt to create binding_clusters
    for them (i.e. we don't store any state for them in our state objects).
    This is implemented by adding a new region::tracked_p, implemented for
    declarations by walking the existing IPA data the first time the
    analyzer sees a declaration, setting it to false for global vars that
    have no loads/stores/aliases, and "sufficiently safe" address-of
    ipa-refs.

    The patch gives a large speedup of -fanalyzer on the above kernel
    source file:
                               Before  After
    Total cc1 wallclock time:    180s    36s
    analyzer wallclock time:     162s    17s
    % spent in analyzer:          90%    47%

    gcc/analyzer/ChangeLog:
            PR analyzer/104954
            * analyzer.opt (-fdump-analyzer-untracked): New option.
            * engine.cc (impl_run_checkers): Handle it.
            * region-model-asm.cc (region_model::on_asm_stmt): Don't attempt
            to clobber regions with !tracked_p ().
            * region-model-manager.cc (dump_untracked_region): New.
            (region_model_manager::dump_untracked_regions): New.
            (frame_region::dump_untracked_regions): New.
            * region-model.h (region_model_manager::dump_untracked_regions):
            New decl.
            * region.cc (ipa_ref_requires_tracking): New.
            (symnode_requires_tracking_p): New.
            (decl_region::calc_tracked_p): New.
            * region.h (region::tracked_p): New vfunc.
            (frame_region::dump_untracked_regions): New decl.
            (class decl_region): Note that this is also used fo SSA names.
            (decl_region::decl_region): Initialize m_tracked.
            (decl_region::tracked_p): New.
            (decl_region::calc_tracked_p): New decl.
            (decl_region::m_tracked): New.
            * store.cc (store::get_or_create_cluster): Assert that we
            don't try to create clusters for base regions that aren't
            trackable.
            (store::mark_as_escaped): Don't mark base regions that we're not
            tracking.

    gcc/ChangeLog:
            PR analyzer/104954
            * doc/invoke.texi (Static Analyzer Options): Add
            -fdump-analyzer-untracked.

    gcc/testsuite/ChangeLog:
            PR analyzer/104954
            * gcc.dg/analyzer/asm-x86-dyndbg-1.c: New test.
            * gcc.dg/analyzer/asm-x86-dyndbg-2.c: New test.
            * gcc.dg/analyzer/many-unused-locals.c: New test.
            * gcc.dg/analyzer/untracked-1.c: New test.
            * gcc.dg/analyzer/unused-local-1.c: New test.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (7 preceding siblings ...)
  2022-03-25  1:00 ` cvs-commit at gcc dot gnu.org
@ 2022-03-25  1:17 ` dmalcolm at gcc dot gnu.org
  2022-03-25  1:30 ` dmalcolm at gcc dot gnu.org
  2022-03-29 21:51 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-25  1:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

David Malcolm <dmalcolm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #8 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
At this point, the analyzer is taking less than half of the wallclock time of
cc1 on this file, so I'm declaring success.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (8 preceding siblings ...)
  2022-03-25  1:17 ` dmalcolm at gcc dot gnu.org
@ 2022-03-25  1:30 ` dmalcolm at gcc dot gnu.org
  2022-03-29 21:51 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: dmalcolm at gcc dot gnu.org @ 2022-03-25  1:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #9 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #1)
> Does not enabling sanitizer improve things?

Removing the sanitizer options speeds up the non-analyzer part of the build,
reducing the overall wallclock time of cc1 from about 36s to 21s; the
-fanalyzer part of that remains steady at about 16s.

Without -fanalyzer, cc1 wallclock is:
  with sanitizer:    ~18s
  without sanitizer:  ~5s

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug analyzer/104954] Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
  2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
                   ` (9 preceding siblings ...)
  2022-03-25  1:30 ` dmalcolm at gcc dot gnu.org
@ 2022-03-29 21:51 ` cvs-commit at gcc dot gnu.org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-03-29 21:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104954

--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:c788a0eae0a7144e6f148162512fa2e93a45a035

commit r12-7905-gc788a0eae0a7144e6f148162512fa2e93a45a035
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Mar 29 17:50:48 2022 -0400

    analyzer: skip constant pool in -fdump-analyzer-untracked [PR
testsuite/105085]

    In r12-7809-g5f6197d7c197f9 I added -fdump-analyzer-untracked as support
    for DejaGnu testing of an optimization of -fanalyzer,
    PR analyzer/104954.

    PR testsuite/105085 notes testsuite failures of the form:
      FAIL: gcc.dg/analyzer/untracked-1.c (test for excess errors)
      Excess errors:
      cc1: warning: track '*.LC1': yes
    where these warnings are emitted on some targets where the test
    causes labelled constants to be created in the constant pool.

    We probably ought not to be tracking the values of such decls in the
    store, given that they're meant to be constant, and I attempted various
    fixes to make the "should we track this decl" logic smarter, but given
    that we're in stage 4, the simplest fix seems to be for
    -fdump-analyzer-untracked to skip such decls in its output, to minimize
    test output differences between targets.

    gcc/analyzer/ChangeLog:
            PR testsuite/105085
            * region-model-manager.cc (dump_untracked_region): Skip decls in
            the constant pool.

    gcc/testsuite/ChangeLog:
            PR testsuite/105085
            * gcc.dg/analyzer/untracked-1.c: Add further test coverage.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2022-03-29 21:51 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-16 13:01 [Bug analyzer/104954] New: Analyzer takes a very long time on Linux kernel drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c dmalcolm at gcc dot gnu.org
2022-03-16 13:03 ` [Bug analyzer/104954] " rguenth at gcc dot gnu.org
2022-03-16 13:07 ` dmalcolm at gcc dot gnu.org
2022-03-16 13:13 ` dmalcolm at gcc dot gnu.org
2022-03-16 13:16 ` dmalcolm at gcc dot gnu.org
2022-03-16 13:56 ` dmalcolm at gcc dot gnu.org
2022-03-18 23:21 ` cvs-commit at gcc dot gnu.org
2022-03-18 23:26 ` dmalcolm at gcc dot gnu.org
2022-03-25  1:00 ` cvs-commit at gcc dot gnu.org
2022-03-25  1:17 ` dmalcolm at gcc dot gnu.org
2022-03-25  1:30 ` dmalcolm at gcc dot gnu.org
2022-03-29 21:51 ` cvs-commit at gcc dot gnu.org

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).