Bug 66432 - [4.9 Regression] libgomp.c/appendix-a/a.29.1.c -O2 -g: type mismatch between an SSA_NAME and its symbol
Summary: [4.9 Regression] libgomp.c/appendix-a/a.29.1.c -O2 -g: type mismatch between ...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 6.0
: P3 normal
Target Milestone: 4.9.4
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code, patch
Depends on:
Blocks:
 
Reported: 2015-06-05 13:20 UTC by Tom de Vries
Modified: 2016-02-11 09:33 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2015-06-08 00:00:00


Attachments
tentative patch (552 bytes, patch)
2015-06-15 12:23 UTC, Tom de Vries
Details | Diff
gcc6-pr66432.patch (791 bytes, patch)
2015-11-20 16:54 UTC, Jakub Jelinek
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tom de Vries 2015-06-05 13:20:16 UTC
Run src/libgomp/testsuite/libgomp.c/appendix-a/a.29.1.c with '--target_board unix/-O2/-g':
...
FAIL: libgomp.c/appendix-a/a.29.1.c (test for excess errors)
Excess errors:
src/libgomp/testsuite/libgomp.c/appendix-a/a.29.1.c:6:1: error: type mismatch between an SSA_NAME and its symbol

UNRESOLVED: libgomp.c/appendix-a/a.29.1.c compilation failed to produce executable
...

Without -g, the testcase passes.
Comment 1 Richard Biener 2015-06-08 10:02:55 UTC
Confirmed.
Comment 2 Tom de Vries 2015-06-15 09:55:21 UTC
At fnsplit, we split off f.part.0 from f.

That introduces a debug_insn and ssa-name that references param B in f:
...
  # DEBUG D#4ptD.0 => B_3(D)
..

And a debug_insn that references param B in f.part.0:
...
  # DEBUG D#7ptD.0 s=> BD.1846
...

At this point, the type of the ssa name and the param are the same.

Then at inline, we decide to inline f.part.0 back into the f.

For inlining, we rewrite the body of inlined function f.part.0. While rewriting the debug insn mentioned above, we hit this code for param B:
...
      if (TREE_CODE (*tp) != OMP_CLAUSE)
        TREE_TYPE (*tp) = remap_type (TREE_TYPE (*tp), id);
...

And since it's a variable-sized type, the type of param is changed.

Now the type of the ssa name and the param are no longer the same, and a bit later we hit the ICE.
Comment 3 Tom de Vries 2015-06-15 12:23:25 UTC
Created attachment 35783 [details]
tentative patch
Comment 4 Tom de Vries 2015-06-30 15:02:40 UTC
Testing tentative patch
Comment 5 Tom de Vries 2015-06-30 21:31:43 UTC
(In reply to vries from comment #4)
> Testing tentative patch

Bootstrap and reg-test on x86_64 went ok.
Comment 7 Jakub Jelinek 2015-11-20 16:52:38 UTC
This has nothing to do with OpenMP actually.  Regressed with r202185.
Comment 8 Jakub Jelinek 2015-11-20 16:54:10 UTC
Created attachment 36785 [details]
gcc6-pr66432.patch

Untested fix.  We actually rely on decl_debug_args being the DECL_ORIGIN, not something similar to it, so your second patch will not work.
Comment 9 Jakub Jelinek 2015-11-21 08:24:49 UTC
Author: jakub
Date: Sat Nov 21 08:24:13 2015
New Revision: 230702

URL: https://gcc.gnu.org/viewcvs?rev=230702&root=gcc&view=rev
Log:
	PR debug/66432
	* tree-inline.c (copy_debug_stmt): If
	gimple_debug_source_bind_get_value is DECL_ORIGIN of a PARM_DECL
	in decl_debug_args, don't call remap_gimple_op_r on it.

	* gcc.dg/debug/pr66432.c: New test.

Added:
    trunk/gcc/testsuite/gcc.dg/debug/pr66432.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-inline.c
Comment 10 Jakub Jelinek 2015-11-21 08:26:32 UTC
Author: jakub
Date: Sat Nov 21 08:26:00 2015
New Revision: 230703

URL: https://gcc.gnu.org/viewcvs?rev=230703&root=gcc&view=rev
Log:
	PR debug/66432
	* tree-inline.c (copy_debug_stmt): If
	gimple_debug_source_bind_get_value is DECL_ORIGIN of a PARM_DECL
	in decl_debug_args, don't call remap_gimple_op_r on it.

	* gcc.dg/debug/pr66432.c: New test.

Added:
    branches/gcc-5-branch/gcc/testsuite/gcc.dg/debug/pr66432.c
Modified:
    branches/gcc-5-branch/gcc/ChangeLog
    branches/gcc-5-branch/gcc/testsuite/ChangeLog
    branches/gcc-5-branch/gcc/tree-inline.c
Comment 11 Jakub Jelinek 2015-11-23 09:53:16 UTC
Fixed for 5.3+ so far.
Comment 12 Jakub Jelinek 2016-02-11 09:08:35 UTC
Author: jakub
Date: Thu Feb 11 09:08:03 2016
New Revision: 233320

URL: https://gcc.gnu.org/viewcvs?rev=233320&root=gcc&view=rev
Log:
	Backported from mainline
	2015-11-21  Jakub Jelinek  <jakub@redhat.com>

	PR debug/66432
	* tree-inline.c (copy_debug_stmt): If
	gimple_debug_source_bind_get_value is DECL_ORIGIN of a PARM_DECL
	in decl_debug_args, don't call remap_gimple_op_r on it.

	* gcc.dg/debug/pr66432.c: New test.

Added:
    branches/gcc-4_9-branch/gcc/testsuite/gcc.dg/debug/pr66432.c
Modified:
    branches/gcc-4_9-branch/gcc/ChangeLog
    branches/gcc-4_9-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_9-branch/gcc/tree-inline.c
Comment 13 Jakub Jelinek 2016-02-11 09:33:42 UTC
Fixed.