On Mon, 19 Oct 2026, John David Anglin wrote:

> On 2026-10-15 5:41 a.m., Richard Biener wrote:
> > I've seen a flurry of recent pa changes, including one regarding
> > fnptr canonicalization.  Did you have a chance to check this patch
> > series?
> 
> GCC bootstraps successfully with the patch on hppa-unknown-linux-gnu.  Check 
> is still running
> but I see some new testsuite fails in the gcc suite:
> 
> FAIL: c-c++-common/analyzer/feasibility-3.c  (test for bogus messages, line 
> 129)
> FAIL: c-c++-common/analyzer/feasibility-3.c  (test for bogus messages, line 
> 132)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 23)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 24)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 25)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 26)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 38)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 39)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 40)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 41)
> FAIL: c-c++-common/analyzer/function-ptr-2.c (test for excess errors)
> FAIL: gcc.dg/addr_equal-1.c execution test
> FAIL: gcc.dg/pr44024.c (test for excess errors)
> 
> I looked at addr_equal-1.c.  It aborts:
> Breakpoint 1, __GI_abort () at abort.c:77
> ⚠️ warning: 77   abort.c: No such file or directory
> (gdb) bt
> #0  __GI_abort () at abort.c:77
> #1  0x00010364 in main (argc=<optimized out>, argv=<optimized out>)
>     at /home/dave/gnu/gcc/gcc/gcc/testsuite/gcc.dg/addr_equal-1.c:46
> 
> main is optimized to just a call to abort:

So this is

  /* Two definitions are always different unless they can be interposed.  
*/
  if (!__builtin_constant_p (def_fn0 == def_fn1))
    abort();

and likely similar to the analyzer warnings which do

 __analyzer_eval (fn_ptr == calls_free); /* { dg-warning "TRUE" } */

and gcc.dg/pr44024.c which does

  if (foo == (void *)0)
    link_error ();

are missed constant foldings.  We see

  _1 = .CANONICALIZE_FUNCPTR_FOR_COMPARE (foo);
  if (_1 == 0B)

while I see that hppas canonicalization special-cases page zero
and thus NULL, the documentation of canonicalize_funcptr_for_compare
does not say that NULL is canonical.

The equality is properly folded, but the analyzer doesn't know,

Inequality of two different decls is a missed optimization.

In general, can we elide canonicalization when comparing two
decls?  That is, when does &function yield a canonical address?

The way it is implemented now is that such comparisons are folded
ignoring canonicalization which to me means that

(simplify
 (tcc_comparison (.CANONICALIZE_FUNCPTR_FOR_COMPARE @0)
  (.CANONICALIZE_FUNCPTR_FOR_COMPARE @1))

can be simplified if @0 @1 simplifies via address_compare?

I do wonder whether the not strict specification requires this to
be target specific folding?  Did we ever have another port than pa
to require this?

Thanks for any hint,
Richard.

> .globl main
>         .type   main, @function
> main:
>         .PROC
>         .CALLINFO FRAME=64,CALLS,SAVE_RP
>         .ENTRY
> .LVL0:
> .LFB6:
>         .loc 1 43 1 is_stmt 1 view -0
>         .cfi_startproc
>         .loc 1 45 3 view .LVU9
>         .loc 1 46 5 view .LVU10
>         .loc 1 43 1 is_stmt 0 view .LVU11
>         stw %r2,-20(%r30)
>         ldo 64(%r30),%r30
>         .cfi_def_cfa_offset -64
>         .cfi_offset 2, -20
>         .loc 1 46 5 view .LVU12
>         b,l abort,%r2
>         nop
> .LVL1:
>         .loc 1 46 5 view .LVU13
>         nop
>         .EXIT
>         .PROCEND
>         .cfi_endproc
> .LFE6:
>         .size   main, .-main
> 
> The pr44024.c fail is:
> spawn -ignore SIGHUP /home/dave/gnu/gcc/objdir1/gcc/xgcc 
> -B/home/dave/gnu/gcc/ob
> jdir1/gcc/ /home/dave/gnu/gcc/gcc/gcc/testsuite/gcc.dg/pr44024.c 
> -fdiagnostics-p
> lain-output -O1 -fdelete-null-pointer-checks -fdump-tree-ccp1 -lm -o 
> pr44024.exe
> /usr/bin/hppa-linux-gnu-ld.bfd: /tmp/ccZ2jEsO.o: in function `main':
> (.text+0x28): undefined reference to `link_error'
> /usr/bin/hppa-linux-gnu-ld.bfd: /tmp/ccZ2jEsO.o: in function `.LC0':
> (.rodata.cst4+0x0): undefined reference to `foo'
> collect2: error: ld returned 1 exit status
> compiler exited with status 1
> FAIL: gcc.dg/pr44024.c (test for excess errors)
> Excess errors:
> (.text+0x28): undefined reference to `link_error'
> (.rodata.cst4+0x0): undefined reference to `foo'
> 
> The feasibility-3.c fail is:
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c:127:6
> : note: (8) ...to here
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c:127:6:
>  note: (9) following 'false' branch (when 'rv != 0')...
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c:132:4:
>  note: (10) ...to here
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/feasibility-3.c:132:4:
>  note: (11) use of uninitialized value 'pdeo' here
> FAIL: c-c++-common/analyzer/feasibility-3.c  (test for bogus messages, line 
> 129)
> FAIL: c-c++-common/analyzer/feasibility-3.c  (test for bogus messages, line 
> 132)
> PASS: c-c++-common/analyzer/feasibility-3.c (test for excess errors)
> 
> The function-ptr-2.c fail is:
> spawn -ignore SIGHUP /home/dave/gnu/gcc/objdir1/gcc/xgcc 
> -B/home/dave/gnu/gcc/objdir1/gcc/
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c 
> -fdiagnostics-plain-output -fanalyzer -Wanalyzer-too-complex
> -Wanalyzer-symbol-too-complex -S -o function-ptr-2.s
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c: 
> In function 'test_2':
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:38:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:39:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:40:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:41:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c: 
> In function 'test_1':
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:23:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:24:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:25:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:26:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c: 
> In function 'calls_free':
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:11:3:
>  warning: double-'free' of 'victim' [CWE-415]
> [-Wanalyzer-double-free]
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:20:6:
>  note: (1) entry to 'test_1'
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:28:3:
>  note: (2) calling 'calls_free' from 'test_1'
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:9:1:
>  note: (3) entry to 'calls_free'
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:11:3:
>  note: (4) first 'free' here
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:28:3:
>  note: (5) returning to 'test_1' from 'calls_free'
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:29:3:
>  note: (6) passing freed pointer 'ptr' in call to 'calls_free'
> from 'test_1'
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:9:1:
>  note: (7) entry to 'calls_free'
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:11:3:
>  note: (8) second 'free' here; first 'free' was at (4)
> PASS: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 11)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 23)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 24)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 25)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 26)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 38)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 39)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 40)
> FAIL: c-c++-common/analyzer/function-ptr-2.c  (test for warnings, line 41)
> FAIL: c-c++-common/analyzer/function-ptr-2.c (test for excess errors)
> Excess errors:
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:38:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:39:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:40:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:41:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:23:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:24:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:25:3:
>  warning: UNKNOWN
> /home/dave/gnu/gcc/gcc/gcc/testsuite/c-c++-common/analyzer/function-ptr-2.c:26:3:
>  warning: UNKNOWN
> 
> Dave
> 

-- 
Richard Biener <[email protected]>
SUSE Software Solutions Germany GmbH,
Frankenstrasse 146, 90461 Nuernberg, Germany;
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri; (HRB 36809, AG Nuernberg)

Reply via email to