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

            Bug ID: 78288
           Summary: Compile time hog (with var-tracking) in
                    libsanitizer/asan/asan_interceptors.cc
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: debug
          Assignee: unassigned at gcc dot gnu.org
          Reporter: marxin at gcc dot gnu.org
  Target Milestone: ---

I've noticed that compilation of sanitizer interceptors take quite significant
time.

With -fno-checking it takes 0m18.664s, while adding -gtoggle time shrinks to
0m12.680s.
As var-tracking eats 1/3 of compile time, I'm wondering whether there's a space
for improvement?

perf report:
5.72%  cc1plus   cc1plus                          [.] canonicalize_values_star
3.64%  cc1plus   cc1plus                          [.] set_slot_part
1.50%  cc1plus   cc1plus                          [.] bitmap_set_bit
1.39%  cc1plus   libc-2.24.so                     [.] _int_malloc
1.35%  cc1plus   cc1plus                          [.] ggc_set_mark
1.23%  cc1plus   cc1plus                          [.]
hash_table<variable_hasher, xcallocator>::find_slot_with_hash
1.21%  cc1plus   cc1plus                          [.] loc_cmp

perf annotate of the 2 hottest functions:

       │         if (GET_CODE (node->loc) == VALUE)
  0.13 │ 88:   mov    0x8(%rax),%rdx
  0.99 │       cmpw   $0x1,(%rdx)
  1.86 │     ↑ jne    80
       │           {
       │             has_value = true;
       │             if (VALUE_RECURSED_INTO (node->loc))
       │               has_marks = true;
  5.04 │       testb  $0x20,0x3(%rdx)
  0.96 │       mov    $0x1,%edi
       │       cmovne %edi,%ecx
       │     canon_value_cmp():
       │         || CSELIB_VAL_PTR (tval)->uid < CSELIB_VAL_PTR (cval)->uid;
  5.74 │       test   %rbx,%rbx
       │     ↓ je     455
       │       mov    0x8(%rbx),%r8
 17.32 │       mov    0x8(%rdx),%rdi
       │     _Z24canonicalize_values_starPP8variableP12dataflow_set():
       │       for (node = var->var_part[0].loc_chain; node; node = node->next)
  0.04 │       mov    (%rax),%rax
       │     canon_value_cmp():
       │         || CSELIB_VAL_PTR (tval)->uid < CSELIB_VAL_PTR (cval)->uid;
  0.38 │       mov    0x4(%rdi),%edi
  3.81 │       cmp    %edi,0x4(%r8)
 31.32 │       mov    $0x1,%edi
  0.02 │       cmovg  %rdx,%rbx
       │     _Z24canonicalize_values_starPP8variableP12dataflow_set():
       │       for (node = var->var_part[0].loc_chain; node; node = node->next)
 10.26 │       test   %rax,%rax
       │     ↑ jne    88
       │             if (canon_value_cmp (node->loc, cval))
       │               cval = node->loc;
       │           }
       │
       │       if (!has_value)
       │ c7:   test   %dil,%dil
       │     ↓ je     310
       │         return 1;
       │
       │       if (cval == val)
  0.02 │       cmp    %rbx,%r12
       │     ↓ je     4ad


       │                 else if (REG_P (node->loc) || MEM_P (node->loc))
  0.14 │650:   cmp    $0x2f,%cx
       │     ↓ je     660
       │       cmp    $0x29,%cx
       │     ↑ jne    2c0
       │                    nextp = &node->next)
 14.58 │660:   mov    %rbx,%rbp
       │               for (nextp = &var->var_part[0].loc_chain; (node =
*nextp);
  0.04 │       mov    (%rbx),%rbx
       │                   c++;
  2.01 │       mov    %eax,%r14d
       │       add    $0x1,%eax
       │               for (nextp = &var->var_part[0].loc_chain; (node =
*nextp);
  7.20 │       test   %rbx,%rbx
       │     ↑ je     2c0
       │                 if (GET_CODE (node->loc) == VALUE)
  0.14 │675:   mov    0x8(%rbx),%rsi
  4.02 │       lea    -0x1(%rax),%r14d
  0.04 │       movzwl (%rsi),%ecx
 12.35 │       cmp    $0x1,%cx
       │     ↑ jne    650
       │                     if (node->loc == loc)
  1.27 │       cmp    %r13,%rsi
       │     ↑ je     503
       │     canon_value_cmp():
       │         || CSELIB_VAL_PTR (tval)->uid < CSELIB_VAL_PTR (cval)->uid;
  1.52 │       mov    0x8(%r13),%rdi
  0.07 │       mov    0x8(%rsi),%rcx
  9.25 │       mov    0x4(%rcx),%edx
 42.46 │       cmp    %edx,0x4(%rdi)

Giving me an advise, I can help with that.
Thanks

Reply via email to