Input: void b(char a) { asm("" : : "pIr" (a)); } Output: $ xgcc -x c++ -S -Wall - during RTL pass: reload <stdin>: In function 'void b(char)': <stdin>:3:1: internal compiler error: Segmentation fault 0x3155789 crash_signal /home/vegard/git/gcc/gcc/toplev.c:325 0x28a3e20 process_address_1 /home/vegard/git/gcc/gcc/lra-constraints.c:3424 0x28a7ba3 process_address /home/vegard/git/gcc/gcc/lra-constraints.c:3521 0x28a7ba3 curr_insn_transform /home/vegard/git/gcc/gcc/lra-constraints.c:3836 0x28bbf56 lra_constraints(bool) /home/vegard/git/gcc/gcc/lra-constraints.c:4877 0x282c524 lra(_IO_FILE*) /home/vegard/git/gcc/gcc/lra.c:2419 0x260b334 do_reload /home/vegard/git/gcc/gcc/ira.c:5465 0x260b334 execute /home/vegard/git/gcc/gcc/ira.c:5649 $ xgcc --version xgcc (GCC) 8.0.1 20180301 (experimental) Built from git c435a9e730c6e8f10da09d58b4fc9aaeb401b0d5 (r258097). Seems to have been introduced between 4.8.5 and 4.9.0. Test case was minimised by C-Reduce.
Confirmed. Segfault reading through NULL in reload here: process_address_1 (nop=nop@entry=0, check_only_p=check_only_p@entry=false, before=before@entry=0x7fffffffcea0, after=after@entry=0x7fffffffcea8) at ../../src/gcc/lra-constraints.c:3424 3424 if (poly_int_rtx_p (*ad.disp, &orig_offset) (gdb) p ad.disp $1 = (rtx *) 0x0
I'm also seeing a different crash with this (using -O3): int a; void b() { float c; for (int d; d;) ; a = c; asm("" : : "pIr"(c)); } Output: $ xgcc -x c++ -S -Wall -fpermissive -O3 - <stdin>: In function 'void b()': <stdin>:4:15: warning: 'd' is used uninitialized in this function [-Wuninitialized] <stdin>:6:5: warning: 'c' is used uninitialized in this function [-Wuninitialized] during RTL pass: reload <stdin>:8:1: internal compiler error: in emit_move_insn, at expr.c:3717 0x1e906d7 emit_move_insn(rtx_def*, rtx_def*) /home/vegard/git/gcc/gcc/expr.c:3716 0x280edaa lra_emit_move(rtx_def*, rtx_def*) /home/vegard/git/gcc/gcc/lra.c:497 0x28a3871 process_address_1 /home/vegard/git/gcc/gcc/lra-constraints.c:3368 0x28a7ba3 process_address /home/vegard/git/gcc/gcc/lra-constraints.c:3521 0x28a7ba3 curr_insn_transform /home/vegard/git/gcc/gcc/lra-constraints.c:3836 0x28bbf56 lra_constraints(bool) /home/vegard/git/gcc/gcc/lra-constraints.c:4877 0x282c524 lra(_IO_FILE*) /home/vegard/git/gcc/gcc/lra.c:2419 0x260b334 do_reload /home/vegard/git/gcc/gcc/ira.c:5465 0x260b334 execute /home/vegard/git/gcc/gcc/ira.c:5649 I'm not opening a new bug because the stack trace is quite similar and also it seems that making very small changes to this test case makes it crash in the original way, so I figure it's probably related.
Started with r198344.
Mine
Created attachment 43594 [details] candidate patch Here's what I'm testing
Improved patch posted https://gcc.gnu.org/ml/gcc-patches/2018-03/msg00416.html
Author: law Date: Fri Mar 9 18:50:56 2018 New Revision: 258393 URL: https://gcc.gnu.org/viewcvs?rev=258393&root=gcc&view=rev Log: PR rtl-optimization/84682 * lra-constraints.c (process_address_1): Check is_address flag for address constraints. (process_alt_operands): Likewise. * lra.c (lra_set_insn_recog_data): Pass asm operand locs to preprocess_constraints. * recog.h (preprocess_constraints): Add oploc parameter. Adjust callers. PR rtl-optimization/84682 * gcc.dg/torture/pr84682-1.c: New. * gcc.dg/torture/pr84682-2.c: New. * gcc.dg/torture/pr84682-3.c: New. Added: trunk/gcc/testsuite/gcc.dg/torture/pr84682-1.c trunk/gcc/testsuite/gcc.dg/torture/pr84682-2.c trunk/gcc/testsuite/gcc.dg/torture/pr84682-3.c Modified: trunk/gcc/ChangeLog trunk/gcc/lra-constraints.c trunk/gcc/lra.c trunk/gcc/recog.c trunk/gcc/recog.h trunk/gcc/testsuite/ChangeLog
Fixed on trunk so far.
GCC 6 branch is being closed
*** Bug 84677 has been marked as a duplicate of this bug. ***
*** Bug 92368 has been marked as a duplicate of this bug. ***
Fixed in GCC 8.