Bug 736933 - Code generation bug for ppc64
Summary: Code generation bug for ppc64
Alias: None
Product: Fedora
Classification: Fedora
Component: 0xFFFF
Version: 16
Hardware: powerpc
OS: Unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL: http://gcc.gnu.org/ml/gcc-patches/201...
Depends On:
Blocks: F16Alphappc
TreeView+ depends on / blocked
Reported: 2011-09-09 06:16 UTC by David Gibson
Modified: 2012-03-14 13:06 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2011-10-04 12:29:50 UTC

Attachments (Terms of Use)

Description David Gibson 2011-09-09 06:16:18 UTC
Description of problem:

http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00304.html describes a bug found in upstream gcc which can cause faulty code generation for ppc64 targets.  The version of gcc currently in Fedora 16 for powerpc (gcc (GCC) 4.6.1 20110804 (Red Hat 4.6.1-7)) suffers from the bug described.

Specifically I have had it misgenerate code when compiling qemu, leading to garbled debug output.  An upstream svn gcc with Alan Modra's patch from that link applied no longer generates faulty code.

Unfortunately, Alan's patch does not trivially backport to the gcc sources used in FC16.

Version-Release number of selected component (if applicable):

Name        : gcc
Version     : 4.6.1
Release     : 7.fc16
Architecture: ppc64

How reproducible:

Steps to Reproduce:
1.  Obtain upstream qemu sources
2.  Compile for a ppc64 target, on a ppc64 host
3.  Run qemu-system-ppc64 with the -d cpu option

Actual results:

The GPR dumps in /tmp/qemu.log will be corrupted, showing strange characters instead of the expected hex values.

Examining target-ppc/translate.o with objdump -d will show that the code generated by gcc in cpu_dump_state() to compute the address of the format string for the messages in question is incorrect.  Specifically it needs to compute the address of the format string within the function's TOC by applying an offset to the TOC pointer in r2.  However, it places the code to do this in a window where r2 has been loaded with a pointer to a different function's TOC.

Comment 1 Alan Modra 2011-09-09 13:06:53 UTC
Self contained testcase in http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50341
I also have a backport of the patch to redhat/gcc-4_6-branch

Comment 2 Jakub Jelinek 2011-09-09 13:12:28 UTC
I'd like to wait with the backport of this until it is approved and committed to the trunk.

Comment 3 Peter Bergner 2011-09-09 14:37:54 UTC
Can we get target-ppc/translate.i attached here so we can create a minimal test case?

Comment 4 Peter Bergner 2011-09-09 15:18:57 UTC
Oops, Alan mentioned that the reduced test case is attached to the GCC PR, so that's good enough for me.

Comment 5 Phil Knirsch 2011-09-15 12:07:02 UTC
Doesn't look like it's in upstream trunk yet, at least didn't see it there yet.

Thanks & regards, phil

Comment 6 Peter Bergner 2011-09-15 18:11:33 UTC
Upstream patch submitted.

Comment 7 Peter Bergner 2011-09-19 18:14:13 UTC
Upstream patches committed to trunk and the FSF 4.6 branch.

Comment 8 Jakub Jelinek 2011-10-04 12:29:50 UTC
This is in gcc-4.6.1-10.fc16.

Comment 9 David Gibson 2011-10-05 07:08:30 UTC
Now that the fix is in gcc upstream, any ETA on getting it into the FC16 package?

Comment 10 Jakub Jelinek 2011-10-05 07:13:45 UTC
See previous comment?  The packages are now in f16-updates-testing, you can test them and give them karma if you want to have them pushed as errata sooner.

Comment 11 Tony Breeds 2011-10-05 09:05:49 UTC
(In reply to comment #10)
> See previous comment?  The packages are now in f16-updates-testing, you can
> test them and give them karma if you want to have them pushed as errata sooner.

As we're on ppc and the kohi-shadow instance wont pick this up automatically until it hits updates.  I've started a manual build for ppc and ppc64 at:


Assuming that's successful and the RPMS are fixed I'll bump the karma for you.

Comment 12 David Gibson 2011-10-05 14:04:50 UTC
Jakub, sorry I misread the earlier comment.

Tony, thanks, I'll check those when I get back.

Note You need to log in before you can comment on or make changes to this bug.