Summary: | ARM gcc 4.1 optimization bug | ||
---|---|---|---|
Product: | gcc | Reporter: | yfw <yfw.debian> |
Component: | target | Assignee: | Paul Brook <pbrook> |
Status: | RESOLVED FIXED | ||
Severity: | major | CC: | dberlin, dirk.behme, enrico.scholz+bugsgcc, gcc-bugs, m.k.edwards, s_j_newbury, tbm |
Priority: | P3 | ||
Version: | 4.1.0 | ||
Target Milestone: | 4.1.2 | ||
Host: | i386 | Target: | arm xscale iwmmxt |
Build: | i386 | Known to work: | |
Known to fail: | Last reconfirmed: | 2006-07-18 21:42:28 | |
Attachments: |
.i file of pcm_native.c and .s files for -Os, -O1 and -O2
Fix. |
Description
yfw
2006-04-30 04:48:43 UTC
We really need a self contianed example but I think this was already fixed for 4.1.1. Subject: Re: ARM gcc 4.1 optimization bug Hi pinskia, I tried to make a simple test example for this bug. But If I put the code from ALSA subsystem of Linux kernel to a test.c file, the gcc will product correct assembly code. :(. So I put the Linux kernel assembly code(with -Os and withoud -O) to bug reporter. I will try the 4.1.1 later. Thanks & Regards yfw On 30 Apr 2006 05:01:19 -0000, pinskia at gcc dot gnu dot org <gcc-bugzilla@gcc.gnu.org> wrote: > > > ------- Comment #1 from pinskia at gcc dot gnu dot org 2006-04-30 05:01 ------- > We really need a self contianed example but I think this was already fixed for > 4.1.1. > > > -- > > pinskia at gcc dot gnu dot org changed: > > What |Removed |Added > ---------------------------------------------------------------------------- > Status|UNCONFIRMED |WAITING > Component|c |target > > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27363 > > ------- You are receiving this mail because: ------- > You reported the bug, or are watching the reporter. > Where can I get gcc 4.1.1? From the ftp site, the latest gcc 4.1 release is 4.1.0. Thanks. I tried the gcc 4.1.1 snapshot 20060421. The bug still there. The assembly code producted with -Os option is the same as gcc 4.1.0. (In reply to comment #4) > I tried the gcc 4.1.1 snapshot 20060421. The bug still there. The assembly code > producted with -Os option is the same as gcc 4.1.0. > Have you got anywhere with this? I wonder if I'm hitting it too. All the ALSA modules load but no devices become available. Kernels 2.6.16 - 2.6.17-rc4 + ALSA SoC GCC 4.1.0 & 4.1.1 Target arm-iwmmxt-linux-gnueabi (-mabi=linux-aapcs, -march=armv5te, -mtune=iwmmxt, -Os) Created attachment 11628 [details]
.i file of pcm_native.c and .s files for -Os, -O1 and -O2
Attached the .i and .s for -Os & -O2 (failing) and -O1 (working) (generated with --save-temps).
Used compile options (from Linux kernel 2.6.17-rc5):
arm-linux-gcc -Wp,-MD,sound/core/.pcm_native.o.d -nostdinc -isystem /usr/arm/arm-linux_4_1_0/bin/../lib/gcc/arm-linux/4.1.0/include -D__KERNEL__ -Iinclude -include include/linux/autoconf.h -mlittle-endian -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -O1 -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-omit-frame-pointer -mapcs -mno-sched-prolog -mabi=apcs-gnu -mno-thumb-interwork -D__LINUX_ARM_ARCH__=5 -march=armv5te -mtune=arm9tdmi -msoft-float -Uarm -Wdeclaration-after-statement -Wno-pointer-sign -DMODULE -D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(pcm_native)" -D"KBUILD_MODNAME=KBUILD_STR(snd_pcm)" --save-temps -c -o sound/core/pcm_native.o sound/core/pcm_native.c
Only -O1 & -O2 & -Os were modified.
Small note:
While compiling only pcm_native.c with -O1 and using the resulting modules (4 modules depend on it) while using -Os for all other modules make the error I observed go away. However, I get no sound output like if I compile all sound modules with -O1. Seems that some other files of kernels sound system have (the same?) optimization issue as well. But I think to start we should concentrate on this file.
Until a fix for this bug is found, there are two possible workarounds: - Compile kernels sound system as modules and compile these modules with -O1 instead of default -Os or -O2 (e.g. by changing main Makefile). - Use this patch from Fengwei Yin <yfw.debian@gmail.com> (then -Os or -O2 should work): -- linux/include/sound/pcm_params.h 2005-03-02 09:31:53.000000000 +0800 +++ linux-ok/include/sound/pcm_params.h 2006-06-08 09:57:11.000000000 +0800 @@ -196,6 +196,11 @@ INLINE int snd_mask_refine(snd_mask_t *m snd_mask_t old; assert(!snd_mask_empty(mask)); snd_mask_copy(&old, mask); + /* + * add the barrier to fix the optimization + * error of GCC 4.1 + */ + mb(); snd_mask_intersect(mask, v); if (snd_mask_empty(mask)) return -EINVAL; Note that this is only a workaround. It will drop the Alsa subsystem performance. One thing we have is some extra virtual operands from CCP: before: <bb 2>: mask_5 = &old; v_7 = mask_6; # SFT.2_33 = V_MAY_DEF <SFT.2_32>; *mask_5 = *v_7; mask_8 = mask_6; v_10 = v_9; i_11 = 0; goto <bb 4> (<L4>); after: <bb 2>: mask_5 = &old; v_7 = mask_6; # SFT.2 = V_MUST_DEF <SFT.2>; # VUSE <SFT.2>; old = *v_7; mask_8 = mask_6; v_10 = v_9; i_11 = 0; goto <bb 4> (<L4>); all of the SFT.2 are actually the same tree object. *** Bug 28362 has been marked as a duplicate of this bug. *** Bug #28362 contains a self contained example. Basically, it needs only | some_struct = *some_other_struct; to trigger this bug. I wonder for how much other segfaults/brokeness this bug is responsible for. Btw, happens for every gcc release (3.4.6, 4.0.3, 4.1.1). I'm working on this. Looks like a CSE bug. Subject: Bug 27363 Author: pbrook Date: Thu Jul 20 13:57:31 2006 New Revision: 115614 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115614 Log: 2006-07-20 Paul Brook <paul@codesourcery.com> PR 27363 gcc/ * cse.c (cse_insn): Add destination addresses to hash table. Check if they are invalidated by this instruction. gcc/testsuite/ * gcc.dg/pr27363.c: New test. Added: trunk/gcc/testsuite/gcc.dg/pr27363.c Modified: trunk/gcc/ChangeLog trunk/gcc/cse.c trunk/gcc/testsuite/ChangeLog Subject: Bug 27363 Author: pbrook Date: Thu Jul 20 13:59:22 2006 New Revision: 115616 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115616 Log: Backport from mainline. PR 27363 gcc/ * cse.c (cse_insn): Add destination addresses to hash table. Check if they are invalidated by this instruction. gcc/testsuite/ * gcc.dg/pr27363.c: New test. Added: branches/csl/sourcerygxx-4_1/gcc/testsuite/gcc.dg/pr27363.c Modified: branches/csl/sourcerygxx-4_1/ChangeLog.csl branches/csl/sourcerygxx-4_1/gcc/cse.c Subject: Bug 27363 Author: pbrook Date: Thu Jul 20 15:07:25 2006 New Revision: 115620 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115620 Log: 2006-07-20 Paul Brook <paul@codesourcery.com> Backport from mainline. PR 27363 gcc/ * cse.c (cse_insn): Add destination addresses to hash table. Check if they are invalidated by this instruction. gcc/testsuite/ * gcc.dg/pr27363.c: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/pr27363.c Modified: branches/gcc-4_1-branch/gcc/ChangeLog branches/gcc-4_1-branch/gcc/cse.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog FIxed. Coooool. pbrook. I will try the latest gcc snapshot. Thanks a lot. Regards Yin, Fengwei Subject: Re: ARM gcc 4.1 optimization bug
yfw dot debian at gmail dot com wrote:
> ------- Comment #16 from yfw dot debian at gmail dot com 2006-07-22 06:21 -------
> Coooool. pbrook.
> I will try the latest gcc snapshot.
>
> Thanks a lot.
I tested it using crosstool and applying the patch manually
against GCC 4.1.0 and it works.
Many thanks from me as well,
Dirk
Created attachment 12464 [details] Fix. Copied from http://www.freaknet.org/martin/crosstool/patches/gcc-4.1.1/gcc-4.1.1-bugfix-27363.patch so that it linked to this report. Still generates bad code for snd_mask_refine in the gcc-4.1-20070115 snapshot. I have verified that the patch claimed to fix this bug is in this snapshot. My gcc is tuned for arm-926ejs, old ABI. -O1 works. |