public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison
@ 2015-10-24 17:48 danglin at gcc dot gnu.org
  2015-10-24 17:52 ` [Bug middle-end/68079] " danglin at gcc dot gnu.org
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-24 17:48 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 68079
           Summary: hppa: pointers to method types need canonicalization
                    before comparison
           Product: gcc
           Version: 6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: danglin at gcc dot gnu.org
                CC: deller at gmx dot de
  Target Milestone: ---
              Host: hppa*-*-* (32-bit)
            Target: hppa*-*-* (32-bit)
             Build: hppa*-*-* (32-bit)

Created attachment 36573
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36573&action=edit
Test program.

On 32-bit hppa targets, pointers to functions need canonicalization prior
to comparison as they point to non unique function descriptors and not directly
to the functions themselves.

The attached testcase demonstrates the problem.  The test passes on x86
but fails on hppa.

A number of kde packages (e.g., kitemmodels) fail to build because of this bug.

Currently, we have the following code in dojump.c to canonicalize function
pointers:

  if (HAVE_canonicalize_funcptr_for_compare
      && TREE_CODE (TREE_TYPE (treeop0)) == POINTER_TYPE
      && TREE_CODE (TREE_TYPE (TREE_TYPE (treeop0)))
          == FUNCTION_TYPE
      && TREE_CODE (TREE_TYPE (treeop1)) == POINTER_TYPE
      && TREE_CODE (TREE_TYPE (TREE_TYPE (treeop1)))
          == FUNCTION_TYPE)
    {

At this point, we have using the testcase:

1209      if (targetm.have_canonicalize_funcptr_for_compare ()
(gdb) p debug_tree (treeop0)
<ssa_name 0xfb7f5e60
   type <pointer_type 0xfb644120
       type <method_type 0xfb644000 type <integer_type 0xfd508420 int>
           SI
           size <integer_cst 0xfd4f5c90 constant 32>
           unit size <integer_cst 0xfd4f5ca8 constant 4>
           align 32 symtab 0 alias set -1 canonical type 0xfb640b40 method
basetype <record_type 0xfb640960 testlib>
           arg-types <tree_list 0xfb6424f8 value <pointer_type 0xfb644060>
               chain <tree_list 0xfd50d4c8 value <void_type 0xfd508a20 void>>>
           pointer_to_this <pointer_type 0xfb644120>>
       public unsigned SI size <integer_cst 0xfd4f5c90 32> unit size
<integer_cst 0xfd4f5ca8 4>
       align 32 symtab 0 alias set -1 canonical type 0xfb644180>
   visiteddef_stmt _6 = MEM[(struct _t *)func_5].__pfn;

   version 6>
$1 = void
(gdb) p debug_tree (treeop1)
<addr_expr 0xfb642600
   type <pointer_type 0xfb644180
       type <method_type 0xfb640b40 type <integer_type 0xfd508420 int>
           SI
           size <integer_cst 0xfd4f5c90 constant 32>
           unit size <integer_cst 0xfd4f5ca8 constant 4>
           align 32 symtab 0 alias set -1 canonical type 0xfb640b40 method
basetype <record_type 0xfb640960 testlib>
           arg-types <tree_list 0xfb6421f8 value <pointer_type 0xfb640ba0>
               chain <tree_list 0xfd50d4c8 value <void_type 0xfd508a20 void>>>
           pointer_to_this <pointer_type 0xfb644180>>
       unsigned SI size <integer_cst 0xfd4f5c90 32> unit size <integer_cst
0xfd4f5ca8 4>
       align 32 symtab 0 alias set -1 canonical type 0xfb644180>
   constant
   arg 0 <function_decl 0xfb63cb00 func1 type <method_type 0xfb640b40>
       addressable asm_written used public static decl_5 SI file testlib.cpp
line 5 col 5 align 32 context <record_type 0xfb640960 testlib> initial
<error_mark 0xfd504220>
       full-name "int testlib::func1()"
       pending-inline-info 0xfc330a20
       (mem:SI (symbol_ref/v:SI ("@_ZN7testlib5func1Ev") [flags 0x1]
<function_decl 0xfb63cb00 func1>) [0  S4 A32])
       chain <function_decl 0xfb63cb80 findfunc type <function_type 0xfb640c60>
           public static decl_5 decl_6 SI file testlib.cpp line 10 col 6 align
32 context <record_type 0xfb640960 testlib> initial <block 0xfb61d930> result
<result_decl 0xfb643230 D.34957>
           full-name "static void testlib::findfunc(void**)"
           pending-inline-info 0xfb9fd3f0 arguments <parm_decl 0xfb643190 _a>
           struct-function 0xfbbf5d00>>>
$2 = void

A METHOD_TYPE is also a function and pointers to method types point at function
descriptors on hppa.  So, we also need to canonicalize pointers to methods.

The current code also fails to canonicalize REFERENCE_TYPEs that refer to
functions:

#define POINTER_TYPE_P(TYPE) \
  (TREE_CODE (TYPE) == POINTER_TYPE || TREE_CODE (TYPE) == REFERENCE_TYPE)


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
  2015-10-24 17:52 ` [Bug middle-end/68079] " danglin at gcc dot gnu.org
@ 2015-10-24 17:52 ` danglin at gcc dot gnu.org
  2015-10-24 18:42 ` deller at gmx dot de
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-24 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from John David Anglin <danglin at gcc dot gnu.org> ---
Created attachment 36574
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36574&action=edit
Patch for trunk


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
@ 2015-10-24 17:52 ` danglin at gcc dot gnu.org
  2015-10-24 17:52 ` danglin at gcc dot gnu.org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-24 17:52 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from John David Anglin <danglin at gcc dot gnu.org> ---
Created attachment 36575
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36575&action=edit
Patch for gcc-5


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
  2015-10-24 17:52 ` [Bug middle-end/68079] " danglin at gcc dot gnu.org
  2015-10-24 17:52 ` danglin at gcc dot gnu.org
@ 2015-10-24 18:42 ` deller at gmx dot de
  2015-10-25 15:19 ` danglin at gcc dot gnu.org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: deller at gmx dot de @ 2015-10-24 18:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from deller at gmx dot de ---
Hi Dave,

Thanks for creating this bug report.

On 24.10.2015 19:48, danglin at gcc dot gnu.org wrote:
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68079
> A number of kde packages (e.g., kitemmodels) fail to build because of this bug.

Nitpick:
The bug/miscompilation is actually in kdebase, but it's true that it then shows
up in kitemmodels first.

Helge


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
                   ` (2 preceding siblings ...)
  2015-10-24 18:42 ` deller at gmx dot de
@ 2015-10-25 15:19 ` danglin at gcc dot gnu.org
  2015-10-25 15:35 ` danglin at gcc dot gnu.org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-25 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from John David Anglin <danglin at gcc dot gnu.org> ---
Author: danglin
Date: Sun Oct 25 15:18:48 2015
New Revision: 229299

URL: https://gcc.gnu.org/viewcvs?rev=229299&root=gcc&view=rev
Log:
        PR middle-end/68079
        * dojump.c (do_compare_and_jump): Canonicalize both function and
        method types.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/dojump.c


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
                   ` (3 preceding siblings ...)
  2015-10-25 15:19 ` danglin at gcc dot gnu.org
@ 2015-10-25 15:35 ` danglin at gcc dot gnu.org
  2015-10-25 15:42 ` danglin at gcc dot gnu.org
  2015-10-25 15:46 ` danglin at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-25 15:35 UTC (permalink / raw)
  To: gcc-bugs

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

John David Anglin <danglin at gcc dot gnu.org> changed:

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

--- Comment #5 from John David Anglin <danglin at gcc dot gnu.org> ---
Fixed on trunk.


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
                   ` (4 preceding siblings ...)
  2015-10-25 15:35 ` danglin at gcc dot gnu.org
@ 2015-10-25 15:42 ` danglin at gcc dot gnu.org
  2015-10-25 15:46 ` danglin at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-25 15:42 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from John David Anglin <danglin at gcc dot gnu.org> ---
Author: danglin
Date: Sun Oct 25 15:42:19 2015
New Revision: 229300

URL: https://gcc.gnu.org/viewcvs?rev=229300&root=gcc&view=rev
Log:
        PR middle-end/68079
        * dojump.c (do_compare_and_jump): Canonicalize both function and
        method types.


Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/dojump.c


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

* [Bug middle-end/68079] hppa: pointers to method types need canonicalization before comparison
  2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
                   ` (5 preceding siblings ...)
  2015-10-25 15:42 ` danglin at gcc dot gnu.org
@ 2015-10-25 15:46 ` danglin at gcc dot gnu.org
  6 siblings, 0 replies; 8+ messages in thread
From: danglin at gcc dot gnu.org @ 2015-10-25 15:46 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from John David Anglin <danglin at gcc dot gnu.org> ---
Author: danglin
Date: Sun Oct 25 15:45:33 2015
New Revision: 229301

URL: https://gcc.gnu.org/viewcvs?rev=229301&root=gcc&view=rev
Log:
        PR middle-end/68079
        * dojump.c (do_compare_and_jump): Canonicalize both function and
        method types.


Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/dojump.c


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

end of thread, other threads:[~2015-10-25 15:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-24 17:48 [Bug middle-end/68079] New: hppa: pointers to method types need canonicalization before comparison danglin at gcc dot gnu.org
2015-10-24 17:52 ` [Bug middle-end/68079] " danglin at gcc dot gnu.org
2015-10-24 17:52 ` danglin at gcc dot gnu.org
2015-10-24 18:42 ` deller at gmx dot de
2015-10-25 15:19 ` danglin at gcc dot gnu.org
2015-10-25 15:35 ` danglin at gcc dot gnu.org
2015-10-25 15:42 ` danglin at gcc dot gnu.org
2015-10-25 15:46 ` danglin 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).