This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch for 3.4.4. Infinite memory allocation on -O3.


Compilation of the following testcase leads to inifite memory allocation:

test.c:
int rd(int *p) {

 if (p<((int*)4)) return 0;
 return *p;
}

void wr(int *p) {
 if (p<((int*)4)) return;
 *p = 0;
}

void test(void *p)
{
 int i;
 int a[2];

 for(i=0;i<2;i++)
 {
   wr(p);
   a[i]=rd(p);
 }
}

How to reproduce:
/home/gt/fsf/inst/arm-3.4-20050429-2.3.2/arm-unknown-linux-gnu/gcc-3.4-20050429-glibc-2.3.2/bin/arm-unknown-linux-gnu-gcc -c -O3 test.c


gcc info:
[root@devzero root]# /home/gt/fsf/inst/arm-csl-arm-20050504-2.3.2/arm-unknown-linux-gnu/gcc-csl-arm-20050504-glibc-2.3.2/bin/arm-unknown-linux-gnu-gcc -v
-bash: /home/gt/fsf/inst/arm-csl-arm-20050504-2.3.2/arm-unknown-linux-gnu/gcc-csl-arm-20050504-glibc-2.3.2/bin/arm-unknown-linux-gnu-gcc: No such file or directory
[root@devzero root]# /home/gt/fsf/inst/arm-3.4-20050429-2.3.2/arm-unknown-linux-gnu/gcc-3.4-20050429-glibc-2.3.2/bin/arm-unknown-linux-gnu-gcc -v
Reading specs from /home/gt/fsf/inst/arm-3.4-20050429-2.3.2/arm-unknown-linux-gnu/gcc-3.4-20050429-glibc-2.3.2/lib/gcc/arm-unknown-linux-gnu/3.4.4/specs
Configured with: /home/gt/work/distr/fsf/crosstool-0.31/build/arm-unknown-linux-gnu/gcc-3.4-20050429-glibc-2.3.2/gcc-3.4-20050429/configure --target=arm-unknown-linux-gnu --host=i686-host_pc-linux-gnu --prefix=/home/gt/fsf/inst/arm-3.4-20050429-2.3.2/arm-unknown-linux-gnu/gcc-3.4-20050429-glibc-2.3.2 --with-local-prefix=/home/gt/fsf/inst/arm-3.4-20050429-2.3.2/arm-unknown-linux-gnu/gcc-3.4-20050429-glibc-2.3.2/arm-unknown-linux-gnu --disable-multilib --with-newlib --without-headers --disable-nls --enable-threads=no --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --disable-shared
Thread model: single
gcc version 3.4.4 20050429 (prerelease)


Fix the problem (was done by Richard Kenner (kenner@vlsi1.ultra.nyu.edu <mailto:kenner@vlsi1.ultra.nyu.edu>) on 2004-02-12 for gcc 3.5:
* emit-rtl.c (set_mem_attributes_minus_bitpos): Don't kill previous MEM_VOLATILE in REF)


diff -urN gcc-3.4.3/gcc/emit-rtl.c gcc-3.4.3-fix18081/gcc/emit-rtl.c
--- gcc-3.4.3/gcc/emit-rtl.c	2004-03-25 19:44:40.000000000 +0300
+++ gcc-3.4.3-fix18081/gcc/emit-rtl.c	2005-05-02 11:50:26.328539084 +0400
@@ -1592,7 +1592,7 @@
     front-end routine) and use it.  */
  alias = get_alias_set (t);

-  MEM_VOLATILE_P (ref) = TYPE_VOLATILE (type);
+  MEM_VOLATILE_P (ref) |= TYPE_VOLATILE (type);
  MEM_IN_STRUCT_P (ref) = AGGREGATE_TYPE_P (type);
  RTX_UNCHANGING_P (ref)
    |= ((lang_hooks.honor_readonly


There was opened a bug against this problem: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18081


Thanks,
Grigory.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]