This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug rtl-optimization/48181] New: [4.5/4.6/4.7 Regression] wrong code with -O -fgcse --param ira-max-conflict-table-size=0
- From: "zsojka at seznam dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 18 Mar 2011 14:39:14 +0000
- Subject: [Bug rtl-optimization/48181] New: [4.5/4.6/4.7 Regression] wrong code with -O -fgcse --param ira-max-conflict-table-size=0
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48181
Summary: [4.5/4.6/4.7 Regression] wrong code with -O -fgcse
--param ira-max-conflict-table-size=0
Product: gcc
Version: 4.7.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: rtl-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: zsojka@seznam.cz
CC: jakub@gcc.gnu.org
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Created attachment 23705
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=23705
reduced testcase
Output:
$ gcc -O -fgcse --param ira-max-conflict-table-size=0 testcase.c
$ valgrind -q ./a.out
==11903== Invalid read of size 8
==11903== at 0x4C2B44C: memcpy (in
/usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==11903== by 0x400602: foo (testcase.c:47)
==11903== by 0x4006AA: main (testcase.c:65)
==11903== Address 0x38 is not stack'd, malloc'd or (recently) free'd
The way it crashes is similiar to PR48156:
...
lea rcx, [rsp+128] # tmp126,
cmp QWORD PTR [rsp+8], 0 # %sfp,
jne .L11 #,
mov esi, r14d #, qsize
mov rdi, rcx #, tmp126
call bar #
.L11:
mov rdx, r12 #, D.2735
mov rsi, rcx #, tmp126 # -fno-gcse: lea rsi, [rsp+128]
lea rdi, [rsp+64] #,
call memcpy #
mov rdx, r12 #, D.2735
mov rsi, rcx #, tmp126 # -fno-gcse: lea rsi, [rsp+128]
lea rdi, [rsp+32] #,
call memcpy #
...
both calls to memcpy() read rcx to set its parameters, but rcx is not preserved
across function call (changes either by call to bar(), or by first memcpy())
Tested revisions:
r171088 - fail
4.6 r170095 - fail
4.5 r170095 - fail
4.4 r170095 - OK