[PATCH] Fix REE from using freed memory (PR bootstrap/52041)
Hi! find_removable_extensions/add_removable_extensions was storing pointers into the *insn_list vector in def_map array. Unfortunately when the vector is reallocated, this may result in all the pointers pointing into freed memory. Detected by valgrind, fixed by instead just storing the vector indexes (+ 1, so that 0 means former NULL), bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? For 4.8 I think the def_map array could be dropped altogether, now that we keep the UD/DU links, but this change looks smaller and safer. 2012-01-31 Jakub Jelinek ja...@redhat.com PR bootstrap/52041 PR bootstrap/52039 PR target/51974 * ree.c (add_removable_extension): Change def_map argument to unsigned *, store in def_map 1 + offset into *insn_list vector instead of pointers into the vector. (find_removable_extensions): Adjust caller. --- gcc/ree.c.jj2012-01-30 00:10:01.205444366 +0100 +++ gcc/ree.c 2012-01-30 22:54:00.864425203 +0100 @@ -747,10 +747,11 @@ combine_reaching_defs (ext_cand *cand, c static void add_removable_extension (const_rtx expr, rtx insn, VEC (ext_cand, heap) **insn_list, -ext_cand **def_map) +unsigned *def_map) { enum rtx_code code; enum machine_mode mode; + unsigned int idx; rtx src, dest; /* We are looking for SET (REG N) (ANY_EXTEND (REG N)). */ @@ -786,7 +787,8 @@ add_removable_extension (const_rtx expr, /* Second, make sure the reaching definitions don't feed another and different extension. FIXME: this obviously can be improved. */ for (def = defs; def; def = def-next) - if ((cand = def_map[INSN_UID(DF_REF_INSN (def-ref))]) + if ((idx = def_map[INSN_UID(DF_REF_INSN (def-ref))]) +(cand = VEC_index (ext_cand, *insn_list, idx - 1)) (cand-code != code || cand-mode != mode)) { if (dump_file) @@ -805,9 +807,10 @@ add_removable_extension (const_rtx expr, cand-code = code; cand-mode = mode; cand-insn = insn; + idx = VEC_length (ext_cand, *insn_list); for (def = defs; def; def = def-next) - def_map[INSN_UID(DF_REF_INSN (def-ref))] = cand; + def_map[INSN_UID(DF_REF_INSN (def-ref))] = idx; } } @@ -820,7 +823,7 @@ find_removable_extensions (void) VEC (ext_cand, heap) *insn_list = NULL; basic_block bb; rtx insn, set; - ext_cand **def_map = XCNEWVEC (ext_cand *, max_insn_uid); + unsigned *def_map = XCNEWVEC (unsigned, max_insn_uid); FOR_EACH_BB (bb) FOR_BB_INSNS (bb, insn) Jakub
[PATCH] Fix uninitialized memory use from ipa-prop.c (PR bootstrap/52041)
Hi! Another thing discovered by valgrind on the same testcase. The problem was that ao.volatile_p field, added recently, hasn't been initialized in this spot. I think it is safer to use ao_ref_init, so that the next time some field is added the situation won't repeat. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2012-01-31 Jakub Jelinek ja...@redhat.com PR bootstrap/52041 PR bootstrap/52039 PR target/51974 * ipa-prop.c (detect_type_change_1): Call ao_ref_init. --- gcc/ipa-prop.c.jj 2011-12-14 08:11:03.0 +0100 +++ gcc/ipa-prop.c 2012-01-30 23:05:03.270693995 +0100 @@ -442,13 +442,11 @@ detect_type_change_1 (tree arg, tree bas if (!flag_devirtualize || !gimple_vuse (call)) return false; - ao.ref = arg; + ao_ref_init (ao, arg); ao.base = base; ao.offset = offset; ao.size = POINTER_SIZE; ao.max_size = ao.size; - ao.ref_alias_set = -1; - ao.base_alias_set = -1; tci.offset = offset; tci.object = get_base_address (arg); Jakub
[patch libffi]: Add thiscall-closure support for fixing regression PR/51500
Hi, this patch adds missing support of the X86_WIN32 calling-convention for thiscall-closures. As thiscall-convention can be only used in C++ for class-member calls, the assumption that first argument gets passed in register is always valid. As it is either the this pointer, or the structure-aggregate-return-pointer. This patch is necessary to fix on gcc's trunk the PR 51500 completely. ChangeLog 2012-01-31 Kai Tietz kti...@redhat.com * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32 also FFI_THISCALL. * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype. (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code. (ffi_prep_closure_loc): Add FFI_THISCALL support. * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size. * src/x86/win32.S (ffi_closure_THISCALL): New closure code for thiscall-calling convention. * testsuite/libffi.call/closure_thiscall.c: New test. Regression tested for i686-w64-mingw32, i686-pc-cygwin, and x86_64-unknown-linux-gnu. Ok for apply? Regards, Kai Index: gcc/libffi/src/prep_cif.c === --- gcc.orig/libffi/src/prep_cif.c +++ gcc/libffi/src/prep_cif.c @@ -93,7 +93,12 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff ffi_type **ptr; FFI_ASSERT(cif != NULL); +#ifndef X86_WIN32 FFI_ASSERT((abi FFI_FIRST_ABI) (abi = FFI_DEFAULT_ABI)); +#else + FFI_ASSERT(abi FFI_FIRST_ABI abi = FFI_DEFAULT_ABI + || abi == FFI_THISCALL); +#endif cif-abi = abi; cif-arg_types = atypes; Index: gcc/libffi/src/x86/ffi.c === --- gcc.orig/libffi/src/x86/ffi.c +++ gcc/libffi/src/x86/ffi.c @@ -449,6 +449,8 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ff #ifdef X86_WIN32 void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *) __attribute__ ((regparm(1))); +void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *) + __attribute__ ((regparm(1))); #endif #ifdef X86_WIN64 void FFI_HIDDEN ffi_closure_win64 (ffi_closure *); @@ -608,6 +610,24 @@ ffi_prep_incoming_args_SYSV(char *stack, *(unsigned int*) __tramp[6] = __dis; /* jmp __fun */ \ } +#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \ +{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ + unsigned int __ctx = (unsigned int)(CTX); \ + unsigned int __dis = __fun - (__ctx + 22); \ + unsigned short __size = (unsigned short)(SIZE); \ + *(unsigned int *) __tramp[0] = 0x8924048b; /* mov (%esp), %eax */ \ + *(unsigned int *) __tramp[4] = 0xec83240c; /* mov %ecx, (%esp) */ \ + *(unsigned int *) __tramp[8] = 0x24048904; /* sub $4,(%esp) */ \ + /* mov %eax, (%esp) */ \ + *(unsigned char*) __tramp[12] = 0xb8; \ + *(unsigned int*) __tramp[13] = __ctx; /* movl __ctx, %eax */ \ + *(unsigned char *) __tramp[17] = 0xe8; \ + *(unsigned int*) __tramp[18] = __dis; /* call __fun */ \ + *(unsigned char*) __tramp[22] = 0xc2; /* ret */ \ + *(unsigned short*) __tramp[23] = __size; /* ret __size */ \ + } + #define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \ { unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ @@ -650,6 +670,13 @@ ffi_prep_closure_loc (ffi_closure* closu (void*)codeloc); } #ifdef X86_WIN32 + else if (cif-abi == FFI_THISCALL) + { + FFI_INIT_TRAMPOLINE_THISCALL (closure-tramp[0], + ffi_closure_THISCALL, + (void*)codeloc, + cif-bytes); + } else if (cif-abi == FFI_STDCALL) { FFI_INIT_TRAMPOLINE_STDCALL (closure-tramp[0], Index: gcc/libffi/src/x86/ffitarget.h === --- gcc.orig/libffi/src/x86/ffitarget.h +++ gcc/libffi/src/x86/ffitarget.h @@ -103,7 +103,7 @@ typedef enum ffi_abi { #define FFI_NATIVE_RAW_API 0 #else #ifdef X86_WIN32 -#define FFI_TRAMPOLINE_SIZE 13 +#define FFI_TRAMPOLINE_SIZE 25 #else #ifdef X86_WIN64 #define FFI_TRAMPOLINE_SIZE 29 Index: gcc/libffi/src/x86/win32.S === --- gcc.orig/libffi/src/x86/win32.S +++ gcc/libffi/src/x86/win32.S @@ -170,6 +170,16 @@ ca_epilogue: ret ffi_call_win32 ENDP +ffi_closure_THISCALL PROC NEAR FORCEFRAME + push ebp + mov ebp, esp + sub esp, 40 + lea edx, [ebp -24] + mov [ebp - 12], edx /* resp */ + lea edx, [ebp + 12] /* account for stub return address on stack */ + jmp stub +ffi_closure_THISCALL ENDP + ffi_closure_SYSV PROC NEAR FORCEFRAME ;; the ffi_closure ctx is passed in eax by the trampoline. @@ -177,6 +187,7 @@ ffi_closure_SYSV PROC NEAR FORCEFRAME lea edx, [ebp - 24] mov [ebp - 12], edx ;; resp lea edx,
Re: [PATCH] Fix REE from using freed memory (PR bootstrap/52041)
2012-01-31 Jakub Jelinek ja...@redhat.com PR bootstrap/52041 PR bootstrap/52039 PR target/51974 * ree.c (add_removable_extension): Change def_map argument to unsigned *, store in def_map 1 + offset into *insn_list vector instead of pointers into the vector. (find_removable_extensions): Adjust caller. OK, thanks. -- Eric Botcazou
Re: [patch libffi]: Add thiscall-closure support for fixing regression PR/51500
Hello! this patch adds missing support of the X86_WIN32 calling-convention for thiscall-closures. ?As thiscall-convention can be only used in C++ for class-member calls, the assumption that first argument gets passed in register is always valid. ?As it is either the this pointer, or the structure-aggregate-return-pointer. This patch is necessary to fix on gcc's trunk the PR 51500 completely. +#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \ +{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + ? unsigned int ?__fun = (unsigned int)(FUN); \ + ? unsigned int ?__ctx = (unsigned int)(CTX); \ + ? unsigned int ?__dis = __fun - (__ctx + 22); ?\ + ? unsigned short __size = (unsigned short)(SIZE); \ + ? *(unsigned int *) __tramp[0] = 0x8924048b; /* mov (%esp), %eax */ \ + ? *(unsigned int *) __tramp[4] = 0xec83240c; /* mov %ecx, (%esp) */ \ + ? *(unsigned int *) __tramp[8] = 0x24048904; /* sub $4,(%esp) */ \ + ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?/* mov %eax, (%esp) */ \ + ? *(unsigned char*) __tramp[12] = 0xb8; \ + ? *(unsigned int*) ?__tramp[13] = __ctx; /* movl __ctx, %eax */ \ + ? *(unsigned char *) ?__tramp[17] = 0xe8; \ + ? *(unsigned int*) ?__tramp[18] = __dis; /* call __fun ?*/ \ + ? *(unsigned char*) ?__tramp[22] = 0xc2; /* ret ?*/ \ + ? *(unsigned short*) ?__tramp[23] = __size; /* ret __size ?*/ \ + } This code violate 16byte stack alignment assumption at call. Uros.
Re: [patch libffi]: Add thiscall-closure support for fixing regression PR/51500
Ok, this variant keeps 16-byte alignment for thiscall-closure. ChangeLog 2012-01-31 Kai Tietz kti...@redhat.com * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32 also FFI_THISCALL. * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype. (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code. (ffi_prep_closure_loc): Add FFI_THISCALL support. * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size. * src/x86/win32.S (ffi_closure_THISCALL): New closure code for thiscall-calling convention. * testsuite/libffi.call/closure_thiscall.c: New test. Index: gcc/libffi/src/prep_cif.c === --- gcc.orig/libffi/src/prep_cif.c +++ gcc/libffi/src/prep_cif.c @@ -93,7 +93,12 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff ffi_type **ptr; FFI_ASSERT(cif != NULL); +#ifndef X86_WIN32 FFI_ASSERT((abi FFI_FIRST_ABI) (abi = FFI_DEFAULT_ABI)); +#else + FFI_ASSERT(abi FFI_FIRST_ABI abi = FFI_DEFAULT_ABI +|| abi == FFI_THISCALL); +#endif cif-abi = abi; cif-arg_types = atypes; Index: gcc/libffi/src/x86/ffi.c === --- gcc.orig/libffi/src/x86/ffi.c +++ gcc/libffi/src/x86/ffi.c @@ -449,6 +449,8 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ff #ifdef X86_WIN32 void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *) __attribute__ ((regparm(1))); +void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *) + __attribute__ ((regparm(1))); #endif #ifdef X86_WIN64 void FFI_HIDDEN ffi_closure_win64 (ffi_closure *); @@ -608,6 +610,33 @@ ffi_prep_incoming_args_SYSV(char *stack, *(unsigned int*) __tramp[6] = __dis; /* jmp __fun */ \ } +#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \ +{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ + unsigned int __ctx = (unsigned int)(CTX); \ + unsigned int __dis = __fun - (__ctx + 22); \ + unsigned short __size = (unsigned short)(SIZE); \ + *(unsigned int *) __tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \ + *(unsigned int *) __tramp[4] = 0x4c8910ec; /* sub $16, %esp */ \ + *(unsigned int *) __tramp[8] = 0x04890424; /* mov %ecx, 4(%esp) */ \ + *(unsigned char*) __tramp[12] = 0x24; /* mov %eax, (%esp) */ \ + *(unsigned char*) __tramp[13] = 0xb8; \ + *(unsigned int *) __tramp[14] = __size;/* mov __size, %eax */ \ + *(unsigned int *) __tramp[18] = 0x08244c8d;/* lea 8(%esp), %ecx */ \ + *(unsigned int *) __tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \ + *(unsigned short*) __tramp[26] = 0x0b74; /* jz 1f */ \ + *(unsigned int *) __tramp[28] = 0x890c518b;/* 2b: mov 12(%eax), %edx */ \ + *(unsigned int *) __tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %edx */ \ + *(unsigned char*) __tramp[36] = 0x48; /* dec %eax */ \ + *(unsigned short*) __tramp[37] = 0xf575; /* jnz 2b ; 1f: */ \ + *(unsigned char*) __tramp[39] = 0xb8; \ + *(unsigned int*) __tramp[40] = __ctx; /* movl __ctx, %eax */ \ + *(unsigned char *) __tramp[44] = 0xe8; \ + *(unsigned int*) __tramp[45] = __dis; /* call __fun */ \ + *(unsigned char*) __tramp[49] = 0xc2; /* ret */ \ + *(unsigned short*) __tramp[50] = (__size + 12); /* ret (__size + 12) */ \ + } + #define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \ { unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ @@ -650,6 +679,13 @@ ffi_prep_closure_loc (ffi_closure* closu (void*)codeloc); } #ifdef X86_WIN32 + else if (cif-abi == FFI_THISCALL) +{ + FFI_INIT_TRAMPOLINE_THISCALL (closure-tramp[0], + ffi_closure_THISCALL, + (void*)codeloc, + cif-bytes); +} else if (cif-abi == FFI_STDCALL) { FFI_INIT_TRAMPOLINE_STDCALL (closure-tramp[0], Index: gcc/libffi/src/x86/ffitarget.h === --- gcc.orig/libffi/src/x86/ffitarget.h +++ gcc/libffi/src/x86/ffitarget.h @@ -103,7 +103,7 @@ typedef enum ffi_abi { #define FFI_NATIVE_RAW_API 0 #else #ifdef X86_WIN32 -#define FFI_TRAMPOLINE_SIZE 13 +#define FFI_TRAMPOLINE_SIZE 52 #else #ifdef X86_WIN64 #define FFI_TRAMPOLINE_SIZE 29 Index: gcc/libffi/src/x86/win32.S === --- gcc.orig/libffi/src/x86/win32.S +++ gcc/libffi/src/x86/win32.S @@ -170,6 +170,16 @@ ca_epilogue: ret ffi_call_win32 ENDP +ffi_closure_THISCALL PROC NEAR FORCEFRAME + pushebp + mov ebp, esp + sub esp, 40 + lea edx, [ebp -24] + mov [ebp - 12], edx /* resp */ + lea edx, [ebp + 12] /* account for stub return address on stack */ + jmp stub +ffi_closure_THISCALL ENDP +
Re: [PATCH] Fix uninitialized memory use from ipa-prop.c (PR bootstrap/52041)
On Tue, 31 Jan 2012, Jakub Jelinek wrote: Hi! Another thing discovered by valgrind on the same testcase. The problem was that ao.volatile_p field, added recently, hasn't been initialized in this spot. I think it is safer to use ao_ref_init, so that the next time some field is added the situation won't repeat. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? Ok. Thanks, Richard. 2012-01-31 Jakub Jelinek ja...@redhat.com PR bootstrap/52041 PR bootstrap/52039 PR target/51974 * ipa-prop.c (detect_type_change_1): Call ao_ref_init. --- gcc/ipa-prop.c.jj 2011-12-14 08:11:03.0 +0100 +++ gcc/ipa-prop.c2012-01-30 23:05:03.270693995 +0100 @@ -442,13 +442,11 @@ detect_type_change_1 (tree arg, tree bas if (!flag_devirtualize || !gimple_vuse (call)) return false; - ao.ref = arg; + ao_ref_init (ao, arg); ao.base = base; ao.offset = offset; ao.size = POINTER_SIZE; ao.max_size = ao.size; - ao.ref_alias_set = -1; - ao.base_alias_set = -1; tci.offset = offset; tci.object = get_base_address (arg); Jakub -- Richard Guenther rguent...@suse.de SUSE / SUSE Labs SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746 GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer
Re: [patch libffi]: Add thiscall-closure support for fixing regression PR/51500
On Tue, Jan 31, 2012 at 10:51 AM, Kai Tietz ktiet...@googlemail.com wrote: Ok, this variant keeps 16-byte alignment for thiscall-closure. It doesn't. You have to account for the fact that caller pushed return address to the stack, so %esp was already decreased by 4 behind your back. To maintain alignment, you have to decrease %esp by $12, not by $16. Uros.
Re: [patch libffi]: Add thiscall-closure support for fixing regression PR/51500
Revised version of thiscall-trampoline code. ChangeLog 2012-01-31 Kai Tietz kti...@redhat.com * src/prep_cif.c (ffi_prep_cif): Allow for X86_WIN32 also FFI_THISCALL. * src/x86/ffi.c (ffi_closure_THISCALL): Add prototype. (FFI_INIT_TRAMPOLINE_THISCALL): New trampoline code. (ffi_prep_closure_loc): Add FFI_THISCALL support. * src/x86/ffitarget.h (FFI_TRAMPOLINE_SIZE): Adjust size. * src/x86/win32.S (ffi_closure_THISCALL): New closure code for thiscall-calling convention. * testsuite/libffi.call/closure_thiscall.c: New test. Index: gcc/libffi/src/prep_cif.c === --- gcc.orig/libffi/src/prep_cif.c +++ gcc/libffi/src/prep_cif.c @@ -93,7 +93,12 @@ ffi_status ffi_prep_cif(ffi_cif *cif, ff ffi_type **ptr; FFI_ASSERT(cif != NULL); +#ifndef X86_WIN32 FFI_ASSERT((abi FFI_FIRST_ABI) (abi = FFI_DEFAULT_ABI)); +#else + FFI_ASSERT(abi FFI_FIRST_ABI abi = FFI_DEFAULT_ABI +|| abi == FFI_THISCALL); +#endif cif-abi = abi; cif-arg_types = atypes; Index: gcc/libffi/src/x86/ffi.c === --- gcc.orig/libffi/src/x86/ffi.c +++ gcc/libffi/src/x86/ffi.c @@ -449,6 +449,8 @@ void FFI_HIDDEN ffi_closure_raw_SYSV (ff #ifdef X86_WIN32 void FFI_HIDDEN ffi_closure_STDCALL (ffi_closure *) __attribute__ ((regparm(1))); +void FFI_HIDDEN ffi_closure_THISCALL (ffi_closure *) + __attribute__ ((regparm(1))); #endif #ifdef X86_WIN64 void FFI_HIDDEN ffi_closure_win64 (ffi_closure *); @@ -608,6 +610,33 @@ ffi_prep_incoming_args_SYSV(char *stack, *(unsigned int*) __tramp[6] = __dis; /* jmp __fun */ \ } +#define FFI_INIT_TRAMPOLINE_THISCALL(TRAMP,FUN,CTX,SIZE) \ +{ unsigned char *__tramp = (unsigned char*)(TRAMP); \ + unsigned int __fun = (unsigned int)(FUN); \ + unsigned int __ctx = (unsigned int)(CTX); \ + unsigned int __dis = __fun - (__ctx + 22); \ + unsigned short __size = (unsigned short)(SIZE); \ + *(unsigned int *) __tramp[0] = 0x8324048b; /* mov (%esp), %eax */ \ + *(unsigned int *) __tramp[4] = 0x4c890cec; /* sub $12, %esp */ \ + *(unsigned int *) __tramp[8] = 0x04890424; /* mov %ecx, 4(%esp) */ \ + *(unsigned char*) __tramp[12] = 0x24; /* mov %eax, (%esp) */ \ + *(unsigned char*) __tramp[13] = 0xb8; \ + *(unsigned int *) __tramp[14] = __size;/* mov __size, %eax */ \ + *(unsigned int *) __tramp[18] = 0x08244c8d;/* lea 8(%esp), %ecx */ \ + *(unsigned int *) __tramp[22] = 0x4802e8c1; /* shr $2, %eax ; dec %eax */ \ + *(unsigned short*) __tramp[26] = 0x0b74; /* jz 1f */ \ + *(unsigned int *) __tramp[28] = 0x8908518b;/* 2b: mov 8(%ecx), %edx */ \ + *(unsigned int *) __tramp[32] = 0x04c18311; /* mov %edx, (%ecx) ; add $4, %ecx */ \ + *(unsigned char*) __tramp[36] = 0x48; /* dec %eax */ \ + *(unsigned short*) __tramp[37] = 0xf575; /* jnz 2b ; 1f: */ \ + *(unsigned char*) __tramp[39] = 0xb8; \ + *(unsigned int*) __tramp[40] = __ctx; /* movl __ctx, %eax */ \ + *(unsigned char *) __tramp[44] = 0xe8; \ + *(unsigned int*) __tramp[45] = __dis; /* call __fun */ \ + *(unsigned char*) __tramp[49] = 0xc2; /* ret */ \ + *(unsigned short*) __tramp[50] = (__size + 8); /* ret (__size + 8) */ \ + } + #define FFI_INIT_TRAMPOLINE_STDCALL(TRAMP,FUN,CTX,SIZE) \ { unsigned char *__tramp = (unsigned char*)(TRAMP); \ unsigned int __fun = (unsigned int)(FUN); \ @@ -650,6 +679,13 @@ ffi_prep_closure_loc (ffi_closure* closu (void*)codeloc); } #ifdef X86_WIN32 + else if (cif-abi == FFI_THISCALL) +{ + FFI_INIT_TRAMPOLINE_THISCALL (closure-tramp[0], + ffi_closure_THISCALL, + (void*)codeloc, + cif-bytes); +} else if (cif-abi == FFI_STDCALL) { FFI_INIT_TRAMPOLINE_STDCALL (closure-tramp[0], Index: gcc/libffi/src/x86/ffitarget.h === --- gcc.orig/libffi/src/x86/ffitarget.h +++ gcc/libffi/src/x86/ffitarget.h @@ -103,7 +103,7 @@ typedef enum ffi_abi { #define FFI_NATIVE_RAW_API 0 #else #ifdef X86_WIN32 -#define FFI_TRAMPOLINE_SIZE 13 +#define FFI_TRAMPOLINE_SIZE 52 #else #ifdef X86_WIN64 #define FFI_TRAMPOLINE_SIZE 29 Index: gcc/libffi/src/x86/win32.S === --- gcc.orig/libffi/src/x86/win32.S +++ gcc/libffi/src/x86/win32.S @@ -170,6 +170,16 @@ ca_epilogue: ret ffi_call_win32 ENDP +ffi_closure_THISCALL PROC NEAR FORCEFRAME + pushebp + mov ebp, esp + sub esp, 40 + lea edx, [ebp -24] + mov [ebp - 12], edx /* resp */ + lea edx, [ebp + 12] /* account for stub return address on stack */ + jmp stub +ffi_closure_THISCALL ENDP + ffi_closure_SYSV PROC NEAR
[PATCH] Clarify inline flag documentation
Thus, the following tries to clarify the documentation of -fno-inline and -finline-functions. Does that help? Thanks, Richard. 2012-01-31 Richard Guenther rguent...@suse.de * doc/invoke.texi (fno-inline): Clarify documentation. (finline-small-functions): Likewise. (finline-functions): Likewise. Index: gcc/doc/invoke.texi === *** gcc/doc/invoke.texi (revision 183751) --- gcc/doc/invoke.texi (working copy) *** Enabled at levels @option{-O2}, @option{ *** 6335,6350 @item -fno-inline @opindex fno-inline ! Don't pay attention to the @code{inline} keyword. Normally this option ! is used to keep the compiler from expanding any functions inline. ! Note that if you are not optimizing, no functions can be expanded inline. @item -finline-small-functions @opindex finline-small-functions Integrate functions into their callers when their body is smaller than expected function call code (so overall size of program gets smaller). The compiler heuristically decides which functions are simple enough to be worth integrating ! in this way. Enabled at level @option{-O2}. --- 6335,6354 @item -fno-inline @opindex fno-inline ! Do not expand any functions inline apart from those marked with ! the @code{always_inline} attribute. This is the default when not ! optimizing. ! ! Single functions can be exempted from inlining by marking them ! with the @code{noinline} attribute. @item -finline-small-functions @opindex finline-small-functions Integrate functions into their callers when their body is smaller than expected function call code (so overall size of program gets smaller). The compiler heuristically decides which functions are simple enough to be worth integrating ! in this way. This inlining applies to all functions, even those not declared ! inline. Enabled at level @option{-O2}. *** Enabled at level @option{-O2}. *** 6359,6367 @item -finline-functions @opindex finline-functions ! Integrate all simple functions into their callers. The compiler ! heuristically decides which functions are simple enough to be worth ! integrating in this way. If all calls to a given function are integrated, and the function is declared @code{static}, then the function is normally not output as --- 6363,6371 @item -finline-functions @opindex finline-functions ! Consider all functions for inlining, even if they are not declared inline. ! The compiler heuristically decides which functions are worth integrating ! in this way. If all calls to a given function are integrated, and the function is declared @code{static}, then the function is normally not output as
Re: [Patch, Fortran] PR 52024 - Fix ambiguity check for type-bound GENERICs
Hi Tobias, Build and regtested on x86-64-linux. OK for the trunk? That looks like a neat way to solve the problem. OK for trunk. Thanks for the patch. Paul
Re: [Patch,AVR]: avr.c code clean-up
2012/1/31 Georg-Johann Lay a...@gjlay.de: Denis Chertykov wrote: * config/avr/avr.md: Resolve all AS1 and AS2 macros. Transform all * quoted-c-code to { c-code }. Remove redundant test for optimize in combine patterns. Move (include avr-dimode.md) to end of file. Please apply. Denis. Applied. And is now a bulk edit patch that removes AS1 and AS2 from the avr backend altogether. The change to avr.c is easily performed with the help of the script. There is no need for that stuff nowadays, so get rid of the defines in avr.h. There is no additional code clean-up so that parts are still in a mess with respect to coding rules like : at end of lines. This patch is just about removing AS1 and AS2. Ok, too? Johann * config/avr/avr.c: Resolve all AS1 and AS2 macros. * config/avr/avr.h (AS1, AS2, AS2C, AS3): Remove. (OUT_AS1, OUT_AS2): Remove. Ok. Denis.
Re: [Patch, fortran] PR52012 - [4.6/4.7 Regression] Wrong-code with realloc on assignment and RESHAPE w/ ORDER=
Dear Paul, thanks for fixing the offset calculation. Regarding: If variable is an allocated allocatable variable, it is deallocated if expr is an array of different shape or any of the corresponding length type parameter values of variable and expr differ. If variable is or becomes an unallocated allocatable variable, then it is allocated with each deferred type parameter equal to the corresponding type parameters of expr , with the shape of expr , and with each lower bound equal to the corresponding element of LBOUND(expr ). In this case, 'expr' is reshape(b,shape(a),order=[3,2,1]), so the question is what should the lower bounds of this expression be? One. For *nearly* all array expression, the lower bound is one. Including arrays returned by functions, even if one has a result variable with different bonds - and also for variables with array spec. Thus for interface function f() integer :: f(-10:5) end function end interface integer :: array(0:10) one always has: lbound ( array(4:6), dim=1) == 1 lbound ( array(:), dim=1) == 1 lbound ( array([1,6,8]), dim=1) == 1 lbound ( f(),dim=1) == 1 lbound ( array * 2.0,dim=1) == 1 However, for the variable itself without array specs (whole array), one has - in this case - lbound (array, dim=1) == 0 From the standard (13.7.90 LBOUND (ARRAY [, DIM, KIND], F2008): If ARRAY is a whole array and either ARRAY is an assumed-size array of rank DIM or dimension DIM of ARRAY has nonzero extent, LBOUND (ARRAY, DIM) has a value equal to the lower bound for subscript DIM of ARRAY. Otherwise the result value is 1. I would say that if 'variable' is already allocated, the existing lower bounds should be used, in order to be fortran-95 compatable. Yes, exactly. Fortran 95 (and Fortran 2003/2008 if the LHS is not allocatable) require that the LHS has the same shape as the RHS. Thus, to be backward compatible, if an allocatable LHS has the same shape as the RHS, no reallocation happens and the LHS bounds are the same as before the intrinsic assignment. In practical terms, this means that the lbounds should be unity, No. While most arrays do have a lower bound of unity, that's just a default setting. One can declare or allocate or associate arrays with whatever lower (co)bounds one would like to have: integer, target :: a(-1:5), b(-1:2), c(n:4,4:7), d[55:*] integer, allocatable :: e(:), f(:,:)[:,:] integer, pointer :: ptr allocate (e(44:99), f(-99:99, 0:5)[0:n, 4:*]) ptr(44:) = b For all those seven variables, none of the l(co)bounds is unity. which is what is implemented. I think - I have not tested the trunk after your commit (Rev. 183757) - that it still mishandles integer, allocatable :: a(:), b(:) allocate(b(3)) b = [1,2,3] allocate (a(7:9)) a = reshape( b, shape=[size(b)]) print *, lbound(a), ubound(a) ! Expected: 7 9 end As the LHS (a) and the RHS (reshape(b, shape=[3]) has the same shape - namely [ 3 ], no reallocation is required and, thus, the bounds of a remain as allocated, namely a(7:9). That happens with 4.1 to 4.5 and with -fno-realloc-lhs with GCC 4.6 and 4.7. I think that even with your patch (and -frealloc-lhs), the result will be 1:3 instead of 7:9. Unless I missed something when testing, the bound handling is otherwise correct for external functions, whole arrays, intrinsic array operations and those interinsic functions which are implemented inline instead of (directly) invoking a libgfortran function. Tobias
libgo patch committed: Don't use PtraceRegs if not defined
The libgo library only defines PtraceRegs on a few systems. However, it was using PtraceRegs on every GNU/Linux system. This patch fix this taking the easy way out, by moving a copy of the two small functions which use PtraceRegs into the processor-specific files which define PtraceRegs. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 8942226864dd libgo/go/syscall/libcall_linux.go --- a/libgo/go/syscall/libcall_linux.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/libcall_linux.go Tue Jan 31 06:20:56 2012 -0800 @@ -139,14 +139,6 @@ return ptracePoke(PTRACE_POKEDATA, PTRACE_PEEKDATA, pid, addr, data) } -func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { - return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) -} - -func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { - return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) -} - func PtraceSetOptions(pid int, options int) (err error) { return ptrace(PTRACE_SETOPTIONS, pid, 0, uintptr(options)) } diff -r 8942226864dd libgo/go/syscall/syscall_linux_386.go --- a/libgo/go/syscall/syscall_linux_386.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/syscall_linux_386.go Tue Jan 31 06:20:56 2012 -0800 @@ -6,10 +6,20 @@ package syscall +import unsafe + func (r *PtraceRegs) PC() uint64 { - return uint64(uint32(r.Eip)); + return uint64(uint32(r.Eip)) } func (r *PtraceRegs) SetPC(pc uint64) { - r.Eip = int32(pc); + r.Eip = int32(pc) } + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +} diff -r 8942226864dd libgo/go/syscall/syscall_linux_alpha.go --- a/libgo/go/syscall/syscall_linux_alpha.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/syscall_linux_alpha.go Tue Jan 31 06:20:56 2012 -0800 @@ -6,42 +6,52 @@ package syscall +import unsafe + type PtraceRegs struct { - R0 uint64 - R1 uint64 - R2 uint64 - R3 uint64 - R4 uint64 - R5 uint64 - R6 uint64 - R7 uint64 - R8 uint64 - R19 uint64 - R20 uint64 - R21 uint64 - R22 uint64 - R23 uint64 - R24 uint64 - R25 uint64 - R26 uint64 - R27 uint64 - R28 uint64 - Hae uint64 + R0 uint64 + R1 uint64 + R2 uint64 + R3 uint64 + R4 uint64 + R5 uint64 + R6 uint64 + R7 uint64 + R8 uint64 + R19 uint64 + R20 uint64 + R21 uint64 + R22 uint64 + R23 uint64 + R24 uint64 + R25 uint64 + R26 uint64 + R27 uint64 + R28 uint64 + Hae uint64 Trap_a0 uint64 Trap_a1 uint64 Trap_a2 uint64 - Ps uint64 - Pc uint64 - Gp uint64 - R16 uint64 - R17 uint64 - R18 uint64 + Ps uint64 + Pc uint64 + Gp uint64 + R16 uint64 + R17 uint64 + R18 uint64 } func (r *PtraceRegs) PC() uint64 { - return r.Pc; + return r.Pc } func (r *PtraceRegs) SetPC(pc uint64) { - r.Pc = pc; + r.Pc = pc } + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +} diff -r 8942226864dd libgo/go/syscall/syscall_linux_amd64.go --- a/libgo/go/syscall/syscall_linux_amd64.go Mon Jan 30 15:51:16 2012 -0800 +++ b/libgo/go/syscall/syscall_linux_amd64.go Tue Jan 31 06:20:56 2012 -0800 @@ -6,10 +6,20 @@ package syscall +import unsafe + func (r *PtraceRegs) PC() uint64 { - return r.Rip; + return r.Rip } func (r *PtraceRegs) SetPC(pc uint64) { - r.Rip = pc; + r.Rip = pc } + +func PtraceGetRegs(pid int, regsout *PtraceRegs) (err error) { + return ptrace(PTRACE_GETREGS, pid, 0, uintptr(unsafe.Pointer(regsout))) +} + +func PtraceSetRegs(pid int, regs *PtraceRegs) (err error) { + return ptrace(PTRACE_SETREGS, pid, 0, uintptr(unsafe.Pointer(regs))) +}
Re: [PATCH][ARM] Improve 64-bit shifts (non-NEON)
On 30/01/12 15:25, Richard Earnshaw wrote: What's the impact of this on -Os? At present we fall back to the libcalls, but I can't immediately see how the new code would do that. Gut feeling is that shift by a constant is always worth inlining at -Os, but shift by a register isn't. Ah, I hadn't considered that. Good point! This updated patch causes it to fall back to the old behaviour in optimize_size mode. This should do what you want. OK? Andrew 2012-01-31 Andrew Stubbs a...@codesourcery.com * config/arm/arm-protos.h (arm_emit_coreregs_64bit_shift): New prototype. * config/arm/arm.c (arm_emit_coreregs_64bit_shift): New function. * config/arm/arm.md (ashldi3): Use arm_emit_coreregs_64bit_shift. (ashrdi3,lshrdi3): Likewise. --- gcc/config/arm/arm-protos.h |3 + gcc/config/arm/arm.c| 198 +++ gcc/config/arm/arm.md | 102 -- 3 files changed, 276 insertions(+), 27 deletions(-) diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 296550a..df8d7a9 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -242,6 +242,9 @@ struct tune_params extern const struct tune_params *current_tune; extern int vfp3_const_double_for_fract_bits (rtx); + +extern void arm_emit_coreregs_64bit_shift (enum rtx_code, rtx, rtx, rtx, rtx, + rtx); #endif /* RTX_CODE */ #endif /* ! GCC_ARM_PROTOS_H */ diff --git a/gcc/config/arm/arm.c b/gcc/config/arm/arm.c index 0bded8d..eefc45c 100644 --- a/gcc/config/arm/arm.c +++ b/gcc/config/arm/arm.c @@ -25139,5 +25139,203 @@ vfp3_const_double_for_fract_bits (rtx operand) return 0; } +/* The default expansion of general 64-bit shifts in core-regs is suboptimal + on ARM, since we know that shifts by negative amounts are no-ops. + + It's safe for the input and output to be the same register, but + early-clobber rules apply for the shift amount and scratch registers. + + Shift by register requires both scratch registers. Shift by a constant + less than 32 in Thumb2 mode requires SCRATCH1 only. In all other cases + the scratch registers may be NULL. + + Additionally, ashiftrt by a register also clobbers the CC register. */ +void +arm_emit_coreregs_64bit_shift (enum rtx_code code, rtx out, rtx in, + rtx amount, rtx scratch1, rtx scratch2) +{ + rtx out_high = gen_highpart (SImode, out); + rtx out_low = gen_lowpart (SImode, out); + rtx in_high = gen_highpart (SImode, in); + rtx in_low = gen_lowpart (SImode, in); + + /* Bits flow from up-stream to down-stream. */ + rtx out_up = code == ASHIFT ? out_low : out_high; + rtx out_down = code == ASHIFT ? out_high : out_low; + rtx in_up = code == ASHIFT ? in_low : in_high; + rtx in_down = code == ASHIFT ? in_high : in_low; + + gcc_assert (code == ASHIFT || code == ASHIFTRT || code == LSHIFTRT); + gcc_assert (out + (REG_P (out) || GET_CODE (out) == SUBREG) + GET_MODE (out) == DImode); + gcc_assert (in + (REG_P (in) || GET_CODE (in) == SUBREG) + GET_MODE (in) == DImode); + gcc_assert (amount + (((REG_P (amount) || GET_CODE (amount) == SUBREG) + GET_MODE (amount) == SImode) + || CONST_INT_P (amount))); + gcc_assert (scratch1 == NULL + || (GET_CODE (scratch1) == SCRATCH) + || (GET_MODE (scratch1) == SImode + REG_P (scratch1))); + gcc_assert (scratch2 == NULL + || (GET_CODE (scratch2) == SCRATCH) + || (GET_MODE (scratch2) == SImode + REG_P (scratch2))); + gcc_assert (!REG_P (out) || !REG_P (amount) + || !HARD_REGISTER_P (out) + || (REGNO (out) != REGNO (amount) + REGNO (out) + 1 != REGNO (amount))); + + /* Macros to make following code more readable. */ + #define SUB_32(DEST,SRC) \ + gen_addsi3 ((DEST), (SRC), gen_rtx_CONST_INT (VOIDmode, -32)) + #define RSB_32(DEST,SRC) \ + gen_subsi3 ((DEST), gen_rtx_CONST_INT (VOIDmode, 32), (SRC)) + #define SUB_S_32(DEST,SRC) \ + gen_addsi3_compare0 ((DEST), (SRC), \ + gen_rtx_CONST_INT (VOIDmode, -32)) + #define SET(DEST,SRC) \ + gen_rtx_SET (SImode, (DEST), (SRC)) + #define SHIFT(CODE,SRC,AMOUNT) \ + gen_rtx_fmt_ee ((CODE), SImode, (SRC), (AMOUNT)) + #define LSHIFT(CODE,SRC,AMOUNT) \ + gen_rtx_fmt_ee ((CODE) == ASHIFT ? ASHIFT : LSHIFTRT, \ + SImode, (SRC), (AMOUNT)) + #define REV_LSHIFT(CODE,SRC,AMOUNT) \ + gen_rtx_fmt_ee ((CODE) == ASHIFT ? LSHIFTRT : ASHIFT, \ + SImode, (SRC), (AMOUNT)) + #define ORR(A,B) \ + gen_rtx_IOR (SImode, (A), (B)) + #define IF(COND,RTX) \ + gen_rtx_COND_EXEC (VOIDmode, \ + gen_rtx_ ## COND (CCmode, cc_reg, \ + const0_rtx), \ + (RTX)) + + if (CONST_INT_P (amount)) +{ + /* Shifts by a constant amount. */ + if (INTVAL (amount) = 0) + /* Match what shift-by-register would do. */ + emit_insn (gen_movdi (out, in)); + else if (INTVAL (amount) = 64) + { + /* Match what shift-by-register would do.
New Spanish PO file for 'gcc' (version 4.7-b20120128)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'gcc' has been submitted by the Spanish team of translators. The file is available at: http://translationproject.org/latest/gcc/es.po (This file, 'gcc-4.7-b20120128.es.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: http://translationproject.org/latest/gcc/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: http://translationproject.org/domain/gcc.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator. coordina...@translationproject.org
New Spanish PO file for 'cpplib' (version 4.7-b20120128)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'cpplib' has been submitted by the Spanish team of translators. The file is available at: http://translationproject.org/latest/cpplib/es.po (This file, 'cpplib-4.7-b20120128.es.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: http://translationproject.org/latest/cpplib/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: http://translationproject.org/domain/cpplib.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator. coordina...@translationproject.org
Contents of PO file 'cpplib-4.7-b20120128.es.po'
cpplib-4.7-b20120128.es.po.gz Description: Binary data The Translation Project robot, in the name of your translation coordinator. coordina...@translationproject.org
Re: [PATCH, rs6000] Fix PR16458, eliminate redudant compares
On Mon, 2012-01-30 at 10:46 +0100, Richard Guenther wrote: On Fri, Jan 27, 2012 at 5:56 PM, Peter Bergner berg...@vnet.ibm.com wrote: This patch fixes PR16458 by using the type expression attached to a reg rtx to detect its signedness and generating unsigned compares when appropriate. However, we continue to use signed compares for the special case of when we compare an unsigned reg against the constant 0. This is because signed and unsigned compares give the same results for equality and (unsigned)x 0) is equivalent to x != 0. Using a signed compare in this special case allows us to continue to generate record form instructions (ie, instructions that implicitly set cr0). I'll note that for the moment, I have XFAILed pr16458-4.c, since this test case isn't working yet, but it is due to a problem in expand not attaching any type expression information on *index's reg rtx like it does for *a and *b in pr16458-2.c. We're tracking that down for 4.8. I asked Bill to have a look at this one and he emailed the gcc mailing list regarding the issue. It looks like micha has a working answer: http://gcc.gnu.org/ml/gcc/2012-01/msg00349.html This has passed bootstrap and regtesting with no regressions. Ok for mainline? This does not sound suitable for stage4. Since this has been around for a while, I'm fine with waiting until stage1. rs6000_unsigned_reg_p looks suspiciously non-rs6000 specific, and if we really can rely on the way it is implemented should find its way to general RTL helper routines. If other ports like avr can make use of it too, I have no problems moving it somewhere else. The question is - do we ever coalesce signed and unsigned variables to the same pseudo? What is it you are worried about? The patch is only attempting to emit unsigned compares for operands we know to be unsigned. The fact that the compares are equality compares means we can use either signed or unsigned compares. It's just that the signed versions don't CSE with any following non-equality unsigned compares with the same unsigned operands. IIRC avr people recently have come across the same idea. Do you have a pointer for this? Peter
Re: adjust installation docs to discourage installing GMP, MPFR and MPC separately
On 30 January 2012 09:52, Richard Guenther wrote: If we discourage from separately installing these libraries, who will do the required in-tree-bootstrap testing before a release on the Hosts we care for? My patch doesn't actually discourage it (although my new wiki page does, as it's meant for the less experienced who are installing or building gcc for the first time.) My patch just reorders the options so that the method that is almost guaranteed to work comes before the suggestion that requires reading and understanding complete sentences. People who don't read the paragraph to the end will find what they need and will stop reporting bugs and asking for help on the gcc-help list because they can't RTFM. I don't think the people who fail to bootstrap because they don't understand the runtime linker are the same people who provide useful feedback about build issues and incompatibilities with new versions of the support libs. Can we at least recommend using the OS vendors versions of the libraries in case they match our minimum (not recommended) version requirements? Is our in-tree build support robust enough against newer/older OS vendor installed copies? Arguably the minimum versions are recommended by Newer versions may work in some cases, but it's safer to use the exact versions documented. I will revise the patch to suggest vendor-supplied versions first, then in-tree, then finally using --with-gmp (which is the method that causes the most frequently asked questions)
[Committed] S/390: Add z196 flag to srak instruction
Applied to mainline and 4.6 branch. 2012-01-31 Andreas Krebbel andreas.kreb...@de.ibm.com * config/s390/s390.md (*ashrmode3_and): Add missing z196 flag to srak instruction. Index: gcc/config/s390/s390.md === --- gcc/config/s390/s390.md (revision 183758) +++ gcc/config/s390/s390.md (working copy) @@ -7650,6 +7650,7 @@ sragk\t%0,%1,%Y2 [(set_attr op_type RSE,RSY) (set_attr atypereg,reg) + (set_attr cpu_facility *,z196) (set_attr z10prop z10_super_E1,*)])
[committed] Fix HAVE_cc0 compilation of combine.c (PR bootstrap/52058)
Hi! SUBST_LINK is only used in code guarded with #ifdef HAVE_cc0, so this patch guards that function and macro with the same to avoid warnings. Committed to trunk as obvious. 2012-01-31 Jakub Jelinek ja...@redhat.com PR bootstrap/52058 * combine.c (do_SUBST_LINK, SUBST_LINK): Guard with #ifndef HAVE_cc0. --- gcc/combine.c.jj2012-01-26 09:22:21.0 +0100 +++ gcc/combine.c 2012-01-31 17:06:31.505978890 +0100 @@ -790,6 +790,7 @@ do_SUBST_MODE (rtx *into, enum machine_m #define SUBST_MODE(INTO, NEWVAL) do_SUBST_MODE((INTO), (NEWVAL)) +#ifndef HAVE_cc0 /* Similar to SUBST, but NEWVAL is a LOG_LINKS expression. */ static void @@ -815,7 +816,7 @@ do_SUBST_LINK (struct insn_link **into, } #define SUBST_LINK(oldval, newval) do_SUBST_LINK (oldval, newval) - +#endif /* Subroutine of try_combine. Determine whether the replacement patterns NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_rtx_cost Jakub
Re: [Patch, fortran] PR52012 - [4.6/4.7 Regression] Wrong-code with realloc on assignment and RESHAPE w/ ORDER=
Dear Tobias, integer, allocatable :: a(:), b(:) allocate(b(3)) b = [1,2,3] allocate (a(7:9)) a = reshape( b, shape=[size(b)]) print *, lbound(a), ubound(a) ! Expected: 7 9 end I tried briefly to generate such a case... I'll fix it. Cheers Paul
Re: [committed] Fix HAVE_cc0 compilation of combine.c (PR bootstrap/52058)
On 31 January 2012 16:10, Jakub Jelinek ja...@redhat.com wrote: Hi! SUBST_LINK is only used in code guarded with #ifdef HAVE_cc0, so this patch guards that function and macro with the same to avoid warnings. Committed to trunk as obvious. Thanks for fixing this. I was out for a while this morning and was getting around to fix this a few minutes back but you beat me to it. Sorry about the breakage in the first place. Ramana 2012-01-31 Jakub Jelinek ja...@redhat.com PR bootstrap/52058 * combine.c (do_SUBST_LINK, SUBST_LINK): Guard with #ifndef HAVE_cc0. --- gcc/combine.c.jj 2012-01-26 09:22:21.0 +0100 +++ gcc/combine.c 2012-01-31 17:06:31.505978890 +0100 @@ -790,6 +790,7 @@ do_SUBST_MODE (rtx *into, enum machine_m #define SUBST_MODE(INTO, NEWVAL) do_SUBST_MODE((INTO), (NEWVAL)) +#ifndef HAVE_cc0 /* Similar to SUBST, but NEWVAL is a LOG_LINKS expression. */ static void @@ -815,7 +816,7 @@ do_SUBST_LINK (struct insn_link **into, } #define SUBST_LINK(oldval, newval) do_SUBST_LINK (oldval, newval) - +#endif /* Subroutine of try_combine. Determine whether the replacement patterns NEWPAT, NEWI2PAT and NEWOTHERPAT are cheaper according to insn_rtx_cost Jakub
Re: [wwwdocs] Add section on diagnostics conventions
On Mon, 30 Jan 2012, Gabriel Dos Reis wrote: On Mon, Jan 30, 2012 at 9:21 AM, Joseph S. Myers jos...@codesourcery.com wrote: On Sun, 29 Jan 2012, Diego Novillo wrote: +licodeinternal_error/code is used for conditions that should not +be triggered by any user input whether valid or invalid and including +invalid asms and LTO binary data (sometimes, as an exception, there is +a call to codeerror/code before further information is printed and +an ICE is triggered)./li + +liAssertion failures should not be triggered by invalid input. +codeinform/code is for informative notes accompanying errors and +warnings. All diagnostics should be full sentences without English +fragments substituted in them, to facilitate translation./li The three sentences in this last list item are actually three independent and unrelated points. I think the first one about assertion failures should be moved up into the previous list item, while the remaining two sentences should each be a list item on its own. Agreed. Thanks. What do you think of the substance of the proposed additions? We're hoping that you can review whether the principles being documented for how to use diagnostic facilities are an accurate description of the coding standards that should be followed - and in general, we hope that maintainers of parts of the compiler will review documentation we add for previously undocumented coding standards relating to those parts. -- Joseph S. Myers jos...@codesourcery.com
[trans-mem, PATCH] do not dereference node if null in expand_call_tm (PR middle-end/52047)
In the PR testcase, a call to __builtin_prefetch is done. When this function call comes into expand_call_tm, there is no cgraph_node associated for this builtin and thus node-local fails. trans-mem.c (expand_call_tm): ... node = cgraph_get_node (fn_decl); if (node-local.tm_may_enter_irr) transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); ... The attached patch adds a check for non-NULL node. I have added the testcase but I don't know if it is relevant. Currently bootstrapping on i686-pc-linux-gnu. Tested on i686-pc-linux-gnu. OK? (I am almost sure I already proposed this modification few time ago but it have been lost somewhere.) -- Patrick. 2012-01-31 Patrick Marlier patrick.marl...@gmail.com PR middle-end/52047 * trans-mem.c (expand_call_tm): Dereference node only if non-NULL. Index: trans-mem.c === --- trans-mem.c (revision 183736) +++ trans-mem.c (working copy) @@ -1,5 +1,5 @@ /* Passes for transactional memory support. - Copyright (C) 2008, 2009, 2010, 2011 Free Software Foundation, Inc. + Copyright (C) 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. This file is part of GCC. @@ -2267,7 +2267,7 @@ expand_call_tm (struct tm_region *region, } node = cgraph_get_node (fn_decl); - if (node-local.tm_may_enter_irr) + if (node node-local.tm_may_enter_irr) transaction_subcode_ior (region, GTMA_MAY_ENTER_IRREVOCABLE); if (is_tm_abort (fn_decl)) Index: testsuite/gcc.dg/tm/pr52047.c === --- testsuite/gcc.dg/tm/pr52047.c (revision 0) +++ testsuite/gcc.dg/tm/pr52047.c (revision 0) @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options -O -fgnu-tm -fprefetch-loop-arrays -w } */ + +int test2 (int x[]) +{ + return x[12]; +} + +int test1 (void) +{ + int x[1000], i; + for (i = 0; i 1000; i++) +x[i] = i; + return test2 (x); +} + +int +main () +{ + __transaction_atomic + { +if (test1 ()) + __transaction_cancel; + } + return 0; +}
C++ PATCH for c++/52043 (ICE with pack expansion)
The problem here is with tsubst_pack_expansion trying to decide whether or not to look at local_specializations. Previously we checked cp_unevaluated_context, but that was wrong because some uses in trailing-return-types have the pack expansion outside the decltype. Then we checked at_function_scope_p(), but that turns out not to be right either, because we might be in a different function, or have already discarded local_specializations. This patch fixes the check to use whether we were in a function when we parsed the expansion, which is more stable. Tested x86_64-pc-linux-gnu, applying to trunk. commit 480a0ab1c458357a701b7ae604b88c058b22d237 Author: Jason Merrill ja...@redhat.com Date: Tue Jan 31 11:10:21 2012 -0500 PR c++/52043 * cp-tree.h (PACK_EXPANSION_LOCAL_P): New. * pt.c (make_pack_expansion, tsubst_initializer_list): Set it. (tsubst_pack_expansion): Check it. diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index f27755e..d435dbd 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -76,6 +76,7 @@ c-common.h, not after. TRANSACTION_EXPR_IS_STMT (in TRANSACTION_EXPR) CONVERT_EXPR_VBASE_PATH (in CONVERT_EXPR) OVL_ARG_DEPENDENT (in OVERLOAD) + PACK_EXPANSION_LOCAL_P (in *_PACK_EXPANSION) 1: IDENTIFIER_VIRTUAL_P (in IDENTIFIER_NODE) TI_PENDING_TEMPLATE_FLAG. TEMPLATE_PARMS_FOR_INLINE. @@ -2839,6 +2840,9 @@ extern void decl_shadowed_for_var_insert (tree, tree); ? TYPE_MAXVAL (NODE) \ : TREE_OPERAND ((NODE), 2)) +/* True iff this pack expansion is within a function context. */ +#define PACK_EXPANSION_LOCAL_P(NODE) TREE_LANG_FLAG_0 (NODE) + /* Determine if this is an argument pack. */ #define ARGUMENT_PACK_P(NODE) \ (TREE_CODE (NODE) == TYPE_ARGUMENT_PACK \ diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index ad2b4df..4c93b31 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -3238,6 +3238,8 @@ make_pack_expansion (tree arg) } PACK_EXPANSION_PARAMETER_PACKS (result) = parameter_packs; + PACK_EXPANSION_LOCAL_P (result) = at_function_scope_p (); + return result; } @@ -9340,7 +9342,7 @@ tsubst_pack_expansion (tree t, tree args, tsubst_flags_t complain, } if (TREE_CODE (parm_pack) == PARM_DECL) { - if (at_function_scope_p ()) + if (PACK_EXPANSION_LOCAL_P (t)) arg_pack = retrieve_local_specialization (parm_pack); else { @@ -18905,6 +18907,7 @@ tsubst_initializer_list (tree t, tree argvec) /* Build a dummy EXPR_PACK_EXPANSION that will be used to expand each argument in the TREE_VALUE of t. */ expr = make_node (EXPR_PACK_EXPANSION); + PACK_EXPANSION_LOCAL_P (expr) = true; PACK_EXPANSION_PARAMETER_PACKS (expr) = PACK_EXPANSION_PARAMETER_PACKS (TREE_PURPOSE (t)); diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic122.C b/gcc/testsuite/g++.dg/cpp0x/variadic122.C new file mode 100644 index 000..6a1fb08 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic122.C @@ -0,0 +1,22 @@ +// PR c++/52043 +// { dg-options -std=c++11 -Wreturn-type } + +template class T struct Container +{ + T f (); +}; + +template class T +T deref (T) +{}// { dg-warning no return } + +template class T, class ... Args +auto deref (T u, int, Args ... args)-decltype (deref (u.f (), args ...)) +{}// { dg-warning no return } + +void +foo () +{ + Container Container int v; + deref (v, 2); +}
Contents of PO file 'cpplib-4.7-b20120128.uk.po'
cpplib-4.7-b20120128.uk.po.gz Description: Binary data The Translation Project robot, in the name of your translation coordinator. coordina...@translationproject.org
New Ukrainian PO file for 'cpplib' (version 4.7-b20120128)
Hello, gentle maintainer. This is a message from the Translation Project robot. A revised PO file for textual domain 'cpplib' has been submitted by the Ukrainian team of translators. The file is available at: http://translationproject.org/latest/cpplib/uk.po (This file, 'cpplib-4.7-b20120128.uk.po', has just now been sent to you in a separate email.) All other PO files for your package are available in: http://translationproject.org/latest/cpplib/ Please consider including all of these in your next release, whether official or a pretest. Whenever you have a new distribution with a new version number ready, containing a newer POT file, please send the URL of that distribution tarball to the address below. The tarball may be just a pretest or a snapshot, it does not even have to compile. It is just used by the translators when they need some extra translation context. The following HTML page has been updated: http://translationproject.org/domain/cpplib.html If any question arises, please contact the translation coordinator. Thank you for all your work, The Translation Project robot, in the name of your translation coordinator. coordina...@translationproject.org
Re: [Patch,AVR]: avr.c code clean-up
2012/1/31 Georg-Johann Lay a...@gjlay.de: Denis Chertykov wrote: * config/avr/avr.md: Resolve all AS1 and AS2 macros. Transform all * quoted-c-code to { c-code }. Remove redundant test for optimize in combine patterns. Move (include avr-dimode.md) to end of file. Please apply. Denis. Applied. And is now a bulk edit patch that removes AS1 and AS2 from the avr backend altogether. The change to avr.c is easily performed with the help of the script. There is no need for that stuff nowadays, so get rid of the defines in avr.h. There is no additional code clean-up so that parts are still in a mess with respect to coding rules like : at end of lines. This patch is just about removing AS1 and AS2. Ok, too? Johann * config/avr/avr.c: Resolve all AS1 and AS2 macros. * config/avr/avr.h (AS1, AS2, AS2C, AS3): Remove. (OUT_AS1, OUT_AS2): Remove. Ok. Denis.
Re: [PATCH] Fix g++.dg/cpp0x/constexpr-rom.C failure
On Jan 27, 2012, at 11:47 AM, Andreas Schwab wrote: Ok, the option is only recognized when it is mentioned in the specs, and neither darwin nor aix configurations have %{G*} in their CC1_SPEC, same for osf or vms on alpha. Checked in the following as obvious. Thanks.
Re: [wwwdocs] Link from gcc-4.{6,7}/changes.html to porting_to.html
On Fri, 13 Jan 2012, Tobias Burnus wrote: I believe Benjamin committed this yesterday, right? Thanks for raising the issue, these links are good to have. Yes - albeit as last item of Caveats which I think makes it harder to find. But at least there is now a link. Would you like to suggest a patch moving that / highlighting it more? I don't think Benjamin is welded to the current position and look, and I know I'm not. Open for improvements. :-) Gerald
Re: [PATCH, go]: Do not panic in test/nilptr.go
Uros Bizjak ubiz...@gmail.com writes: There is no need for a panic in test/nilptr.go if array doesn't get allocated in first 256 meg of memory. The compiler has nothing to do with this. This is true but this does not seem like the right patch. Index: test/nilptr.go === --- test/nilptr.go (revision 183732) +++ test/nilptr.go (working copy) @@ -22,7 +22,8 @@ // at the address that might be accidentally // dereferenced below. if uintptr(unsafe.Pointer(dummy)) 25620 { - panic(dummy too far out) + println(dummy too far out) + return } shouldPanic(p1) This patch makes this test pretty much useless: if the linker changes, the test will always pass, and nobody will ever notice that the test is no longer being run. I think I would prefer to just change go-test.exp to mark this test as xfail on Alpha. A patch to do that is preapproved. Ian
libgo patch committed: Add gettid on GNU/Linux
This patch to libgo adds support for syscall.Gettid on GNU/Linux. The function is different becase it is not in libc, but must be invoked via Syscall. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r 351201702211 libgo/go/syscall/libcall_linux.go --- a/libgo/go/syscall/libcall_linux.go Tue Jan 31 06:21:32 2012 -0800 +++ b/libgo/go/syscall/libcall_linux.go Tue Jan 31 11:49:40 2012 -0800 @@ -195,9 +195,10 @@ // //sys Fstatfs(fd int, buf *Statfs_t) (err error) // //fstatfs(fd int, buf *Statfs_t) int -// FIXME: Only available as a syscall. -// //sysnb Gettid() (tid int) -// //gettid() Pid_t +func Gettid() (tid int) { + r1, _, _ := Syscall(SYS_GETTID, 0, 0, 0) + return int(r1) +} // FIXME: mksysinfo linux_dirent //Or just abandon this function.
[PATCH] Fix for PR52009 - Another missed tail merging opportunity
Richard, this patch fixes PR52009. Consider this test-case: ... int z; void foo (int y) { if (y == 6) z = 5; else z = 5; } ... Currently, compiling with -O2 gives us this representation at pr51879-7.c.094t.pre: ... # BLOCK 3 freq:1991 # PRED: 2 [19.9%] (true,exec) # .MEMD.1710_4 = VDEF .MEMD.1710_3(D) zD.1702 = 5; goto bb 5; # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 4 freq:8009 # PRED: 2 [80.1%] (false,exec) # .MEMD.1710_5 = VDEF .MEMD.1710_3(D) zD.1702 = 5; # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 5 freq:1 # PRED: 3 [100.0%] (fallthru,exec) 4 [100.0%] (fallthru,exec) # .MEMD.1710_2 = PHI .MEMD.1710_4(3), .MEMD.1710_5(4) # VUSE .MEMD.1710_2 return; ... Blocks 3 and 4 are not tail-merged. The patch allows the example to be tail-merged by: - value numbering .MEMD.1710_4 and .MEMD.1710_5 equal - comparing gimple_vdef value numbers for assignments during tail-merge Bootstrapped and reg-tested on x86_64. OK for stage1? Thanks, - Tom 2012-01-31 Tom de Vries t...@codesourcery.com PR tree-optimization/52009 * tree-ssa-tail-merge.c (gimple_equal_p): For GIMPLE_ASSIGN, compare value numbers of gimple_vdef. * tree-ssa-sccvn.h (struct vn_reference_s): Add vdef field. (vn_reference_insert): Add vdef parameter to prototype. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle MODIFY_EXPR. (vn_reference_insert): Add and handle vdef parameter. (visit_reference_op_load): Add argument to vn_reference_insert call. (visit_reference_op_store): Find value number of vdef of store. Insert value number of vdef of store. * gcc.dg/pr51879-7.c: New test.
Re: [PATCH] Fix for PR52009 - Another missed tail merging opportunity
On 31/01/12 22:05, Tom de Vries wrote: Richard, Sorry, with patch this time. this patch fixes PR52009. Consider this test-case: ... int z; void foo (int y) { if (y == 6) z = 5; else z = 5; } ... Currently, compiling with -O2 gives us this representation at pr51879-7.c.094t.pre: ... # BLOCK 3 freq:1991 # PRED: 2 [19.9%] (true,exec) # .MEMD.1710_4 = VDEF .MEMD.1710_3(D) zD.1702 = 5; goto bb 5; # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 4 freq:8009 # PRED: 2 [80.1%] (false,exec) # .MEMD.1710_5 = VDEF .MEMD.1710_3(D) zD.1702 = 5; # SUCC: 5 [100.0%] (fallthru,exec) # BLOCK 5 freq:1 # PRED: 3 [100.0%] (fallthru,exec) 4 [100.0%] (fallthru,exec) # .MEMD.1710_2 = PHI .MEMD.1710_4(3), .MEMD.1710_5(4) # VUSE .MEMD.1710_2 return; ... Blocks 3 and 4 are not tail-merged. The patch allows the example to be tail-merged by: - value numbering .MEMD.1710_4 and .MEMD.1710_5 equal - comparing gimple_vdef value numbers for assignments during tail-merge Bootstrapped and reg-tested on x86_64. OK for stage1? Thanks, - Tom 2012-01-31 Tom de Vries t...@codesourcery.com PR tree-optimization/52009 * tree-ssa-tail-merge.c (gimple_equal_p): For GIMPLE_ASSIGN, compare value numbers of gimple_vdef. * tree-ssa-sccvn.h (struct vn_reference_s): Add vdef field. (vn_reference_insert): Add vdef parameter to prototype. * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle MODIFY_EXPR. (vn_reference_insert): Add and handle vdef parameter. (visit_reference_op_load): Add argument to vn_reference_insert call. (visit_reference_op_store): Find value number of vdef of store. Insert value number of vdef of store. * gcc.dg/pr51879-7.c: New test. Index: gcc/tree-ssa-tail-merge.c === --- gcc/tree-ssa-tail-merge.c (revision 183325) +++ gcc/tree-ssa-tail-merge.c (working copy) @@ -1087,6 +1087,14 @@ gimple_equal_p (same_succ same_succ, gim case GIMPLE_ASSIGN: lhs1 = gimple_get_lhs (s1); lhs2 = gimple_get_lhs (s2); + if (gimple_vdef (s1)) + { + if (vn_valueize (gimple_vdef (s1)) != vn_valueize (gimple_vdef (s2))) + return false; + if (TREE_CODE (lhs1) != SSA_NAME + TREE_CODE (lhs2) != SSA_NAME) + return true; + } return (TREE_CODE (lhs1) == SSA_NAME TREE_CODE (lhs2) == SSA_NAME vn_valueize (lhs1) == vn_valueize (lhs2)); Index: gcc/tree-ssa-sccvn.c === --- gcc/tree-ssa-sccvn.c (revision 183325) +++ gcc/tree-ssa-sccvn.c (working copy) @@ -624,6 +624,9 @@ copy_reference_ops_from_ref (tree ref, V switch (temp.opcode) { + case MODIFY_EXPR: + temp.op0 = TREE_OPERAND (ref, 1); + break; case MEM_REF: /* The base address gets its own vn_reference_op_s structure. */ temp.op0 = TREE_OPERAND (ref, 1); @@ -740,6 +743,7 @@ copy_reference_ops_from_ref (tree ref, V VEC_safe_push (vn_reference_op_s, heap, *result, temp); if (REFERENCE_CLASS_P (ref) + || TREE_CODE (ref) == MODIFY_EXPR || (TREE_CODE (ref) == ADDR_EXPR !is_gimple_min_invariant (ref))) ref = TREE_OPERAND (ref, 0); @@ -1928,7 +1932,7 @@ vn_reference_lookup (tree op, tree vuse, RESULT, and return the resulting reference structure we created. */ vn_reference_t -vn_reference_insert (tree op, tree result, tree vuse) +vn_reference_insert (tree op, tree result, tree vuse, tree vdef) { void **slot; vn_reference_t vr1; @@ -1944,6 +1948,7 @@ vn_reference_insert (tree op, tree resul vr1-set = get_alias_set (op); vr1-hashcode = vn_reference_compute_hash (vr1); vr1-result = TREE_CODE (result) == SSA_NAME ? SSA_VAL (result) : result; + vr1-vdef = vdef; slot = htab_find_slot_with_hash (current_info-references, vr1, vr1-hashcode, INSERT); @@ -2725,7 +2730,7 @@ visit_reference_op_load (tree lhs, tree else { changed = set_ssa_val_to (lhs, lhs); - vn_reference_insert (op, lhs, last_vuse); + vn_reference_insert (op, lhs, last_vuse, NULL_TREE); } return changed; @@ -2739,8 +2744,11 @@ static bool visit_reference_op_store (tree lhs, tree op, gimple stmt) { bool changed = false; - tree result; + vn_reference_t vnresult = NULL; + tree result, assign; bool resultsame = false; + tree vuse = gimple_vuse (stmt); + tree vdef = gimple_vdef (stmt); /* First we want to lookup using the *vuses* from the store and see if there the last store to this location with the same address @@ -2758,7 +2766,7 @@ visit_reference_op_store (tree lhs, tree Otherwise, the vdefs for the store are used when inserting into the table, since the store generates a new memory state. */ - result = vn_reference_lookup (lhs, gimple_vuse (stmt), VN_NOWALK, NULL); + result = vn_reference_lookup (lhs,
[Patch, Fortran] PR52059 - Scalarizing fix - only add array ref to a variable
Dear all, I have no idea about the scalarizer, but the attached patch fixes the test case and somehow adding an array ref to a scalar looks odd to me ... (Before the regression-causing patch, only the else branch existed.) Build and regtested on x86-64-linux. OK for the trunk? Tobias 2012-01-31 Tobias Burnus PR fortran/52059 * trans-expr.c (gfc_conv_procedure_call): Add array ref only to variables. 2012-01-31 Tobias Burnus PR fortran/52059 * gfortran.dg/elemental_function_1.f90: New. Index: gcc/fortran/trans-expr.c === --- gcc/fortran/trans-expr.c (Revision 183775) +++ gcc/fortran/trans-expr.c @@ -3519,21 +3519,21 @@ gfc_conv_procedure_call (gfc_se * se, gf CLASS object. */ gfc_init_se (parmse, se); gfc_conv_derived_to_class (parmse, e, fsym-ts); } else if (se-ss se-ss-info-useflags) { /* An elemental function inside a scalarized loop. */ gfc_init_se (parmse, se); parm_kind = ELEMENTAL; - if (se-ss-dimen 0 + if (se-ss-dimen 0 e-expr_type == EXPR_VARIABLE se-ss-info-data.array.ref == NULL) { gfc_conv_tmp_array_ref (parmse); if (e-ts.type == BT_CHARACTER) gfc_conv_string_parameter (parmse); else parmse.expr = gfc_build_addr_expr (NULL_TREE, parmse.expr); } else gfc_conv_expr_reference (parmse, e); Index: gcc/testsuite/gfortran.dg/elemental_function_1.f90 === --- gcc/testsuite/gfortran.dg/elemental_function_1.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/elemental_function_1.f90 @@ -0,0 +1,22 @@ +! { dg-do compile } +! +! PR fortran/52059 +! +! + +subroutine baz + real(kind=8) :: a(99), b + interface bar +function bar (x, y) + integer, intent(in) :: x, y + real(kind=8), dimension((y-x)) :: bar +end function bar + end interface + b = 1.0_8 + a = foo (bar(0,35) / dble(34), b) +contains + elemental real(kind=8) function foo(x, y) +real(kind=8), intent(in) :: x, y +foo = 1 + end function foo +end subroutine baz
[Patch, Fortran] PR 52024 - fix .mod issue with type-bound operator check
Dear all, my just committed patch which checks type-bound operators for ambiguity missed a handling of module files. The attached patch adds one. Unfortunately, it turns out that the check does not handle inheritance well. At least I would expect that the attached test case is valid (and it compiles with NAG 5.1), but it is rejected with GCC 4.6 and 4.7. Thus, I will keep the PR open such that we can deal with that issue later. Build and regtested on x86-64. OK for the trunk? Tobias 2012-01-31 Tobias Burnus bur...@net-b.de PR fortran/52024 * module.c (MOD_VERSION): Bump. (mio_typebound_proc): Read/write is_operator from/to the .mod file. 2012-01-31 Tobias Burnus bur...@net-b.de PR fortran/52024 * gfortran.dg/typebound_operator_14.f90: New. Index: gcc/fortran/module.c === --- gcc/fortran/module.c (Revision 183775) +++ gcc/fortran/module.c (Arbeitskopie) @@ -74,21 +74,21 @@ along with GCC; see the file COPYING3. #include parse.h /* FIXME */ #include md5.h #include constructor.h #include cpp.h #include tree.h #define MODULE_EXTENSION .mod /* Don't put any single quote (') in MOD_VERSION, if yout want it to be recognized. */ -#define MOD_VERSION 8 +#define MOD_VERSION 9 /* Structure that describes a position within a module file. */ typedef struct { int column, line; fpos_t pos; } module_locus; @@ -3571,36 +3571,44 @@ mio_typebound_proc (gfc_typebound_proc** mio_pool_string (((*proc)-pass_arg)); flag = (int) (*proc)-pass_arg_num; mio_integer (flag); (*proc)-pass_arg_num = (unsigned) flag; if ((*proc)-is_generic) { gfc_tbp_generic* g; + int iop; mio_lparen (); if (iomode == IO_OUTPUT) for (g = (*proc)-u.generic; g; g = g-next) - mio_allocated_string (g-specific_st-name); + { + iop = (int) g-is_operator; + mio_integer (iop); + mio_allocated_string (g-specific_st-name); + } else { (*proc)-u.generic = NULL; while (peek_atom () != ATOM_RPAREN) { gfc_symtree** sym_root; g = gfc_get_tbp_generic (); g-specific = NULL; + mio_integer (iop); + g-is_operator = (bool) iop; + require_atom (ATOM_STRING); sym_root = current_f2k_derived-tb_sym_root; g-specific_st = gfc_get_tbp_symtree (sym_root, atom_string); free (atom_string); g-next = (*proc)-u.generic; (*proc)-u.generic = g; } } Index: gcc/testsuite/gfortran.dg/typebound_operator_14.f90 === --- gcc/testsuite/gfortran.dg/typebound_operator_14.f90 (Revision 0) +++ gcc/testsuite/gfortran.dg/typebound_operator_14.f90 (Arbeitskopie) @@ -0,0 +1,46 @@ +! { dg-do compile } +! +! PR fortran/52024 +! +! Contributed by Dominique d'Humieres +! +! FIXME: The following test case is valid but it is currently rejected. +! +! The test case was segfaulting before +! + +module m_sort + implicit none + type, abstract :: sort_t + contains +generic :: operator(.gt.) = gt_cmp +procedure :: gt_cmp +end type sort_t +contains + logical function gt_cmp(a,b) +class(sort_t), intent(in) :: a, b +gt_cmp = .true. + end function gt_cmp +end module + +module test + use m_sort + implicit none + type, extends(sort_t) :: sort_int_t +integer :: i + contains ! FIXME: The following is actually not true: +generic :: operator(.gt.) = gt_cmp_int ! { dg-error are ambiguous } +procedure :: gt_cmp_int + end type +contains + logical function gt_cmp_int(a,b) result(cmp) +class(sort_int_t), intent(in) :: a, b +if (a%i b%i) then + cmp = .true. + else + cmp = .false. + end if + end function gt_cmp_int +end module + +! { dg-final { cleanup-tree-dump m_sort test } }
Re: [PATCH] disable __size_t macro on GNU/kFreeBSD
On Sun, 29 Jan 2012, Robert Millan wrote: Please consider this patch to stddef.h. GNU/kFreeBSD has the same problem with __size_t as FreeBSD does, since it inherits many kernel headers from FreeBSD. The patch looks obvious to me, and I'll be happy to apply for Robert if approved. Any taker? Gerald 2012-01-29 Robert Millan r...@gnu.org * ginclude/stddef.h [__FreeBSD_kernel__] (__size_t): Do not define. Index: ginclude/stddef.h === --- ginclude/stddef.h (revision 183670) +++ ginclude/stddef.h (working copy) @@ -200,7 +200,7 @@ #define ___int_size_t_h #define _GCC_SIZE_T #define _SIZET_ -#if defined (__FreeBSD__) (__FreeBSD__ = 5) +#if (defined (__FreeBSD__) (__FreeBSD__ = 5)) || defined(__FreeBSD_kernel__) /* __size_t is a typedef on FreeBSD 5!, must not trash it. */ #else #define __size_t
Re: [Patch, Fortran] PR 52024 - fix .mod issue with type-bound operator check
Tobias Burnus wrote: Unfortunately, it turns out that the check does not handle inheritance well. At least I would expect that the attached test case is valid (and it compiles with NAG 5.1), but it is rejected with GCC 4.6 and 4.7. Actually, I withdraw that comment. I now believe that gt_cmp and gt_cmp_int are ambiguous in + generic :: operator(.gt.) = gt_cmp + generic :: operator(.gt.) = gt_cmp_int as an actual argument of declared type class(sort_t) is type compatible to a dummy of declared type class(sort_int_t). The fix is to do the following. One keeps for the first type: +generic :: operator(.gt.) = gt_cmp +procedure :: gt_cmp +end type sort_t And then later just has: +procedure :: gt_cmp = gt_cmp_int + end type That is: One overrides the specific function, one does not add a new generic interface. Tobias
Re: [patch, fortran] Fix PR 51958, wrong-code regression with function elimination
Hi Tobias, here is an updated version of the patch, with a more extensive test case. Also regression-tested. OK for trunk? Thomas 2012-01-31 Thomas König tkoe...@gcc.gnu.org PR fortran/51958 * frontend-passes.c (convert_elseif): New function. (optimize_namespace): Call it. 2012-01-31 Thomas König tkoe...@gcc.gnu.org PR fortran/51958 * gfortran.dg/function_optimize_10.f90: New test. ! { do-do run } ! PR 51958 - this used to generate wrong code. ! Original test case by Don Simons. program main implicit none logical :: test1_ok logical :: test2_ok logical :: test3_ok character(len=1):: charq charq = 'c' test1_ok = .true. test2_ok = .false. if (charq .eq. ' ') then test1_ok = .false. else if ((my_ichar(charq).ge.97 .and. my_ichar(charq).le.103)) then test2_OK = .true. end if if ((.not. test1_ok) .or. (.not. test2_ok)) call abort test1_ok = .true. test2_ok = .true. test3_ok = .false. if (charq .eq. ' ') then test1_ok = .false. else if ((my_ichar(charq).lt.97 .or. my_ichar(charq).gt.103)) then test2_ok = .false. else if ((my_ichar(charq).ge.97 .and. my_ichar(charq).le.103)) then test3_ok = .true. end if if ((.not. test1_ok) .or. (.not. test2_ok) .or. (.not. test3_ok)) call abort test1_ok = .true. test2_ok = .true. test3_ok = .false. if (charq .eq. ' ') then test1_ok = .false. else if ((my_ichar(charq).lt.97 .or. my_ichar(charq).gt.103)) then test2_ok = .false. else test3_ok = .true. end if if ((.not. test1_ok) .or. (.not. test2_ok) .or. (.not. test3_ok)) call abort contains pure function my_ichar(c) integer :: my_ichar character(len=1), intent(in) :: c my_ichar = ichar(c) end function my_ichar end program main Index: frontend-passes.c === --- frontend-passes.c (Revision 183449) +++ frontend-passes.c (Arbeitskopie) @@ -509,6 +509,70 @@ convert_do_while (gfc_code **c, int *walk_subtrees return 0; } +/* Code callback function for converting + if (a) then + ... + else if (b) then + end if + + into + if (a) then + else + if (b) then + end if + end if + + because otherwise common function elimination would place the BLOCKs + into the wrong place. */ + +static int +convert_elseif (gfc_code **c, int *walk_subtrees ATTRIBUTE_UNUSED, + void *data ATTRIBUTE_UNUSED) +{ + gfc_code *co = *c; + gfc_code *c_if1, *c_if2, *else_stmt; + + if (co-op != EXEC_IF) +return 0; + + /* This loop starts out with the first ELSE statement. */ + else_stmt = co-block-block; + + while (else_stmt != NULL) +{ + gfc_code *next_else; + + /* If there is no condition, we're done. */ + if (else_stmt-expr1 == NULL) + break; + + next_else = else_stmt-block; + + /* Generate the new IF statement. */ + c_if2 = XCNEW (gfc_code); + c_if2-op = EXEC_IF; + c_if2-expr1 = else_stmt-expr1; + c_if2-next = else_stmt-next; + c_if2-loc = else_stmt-loc; + c_if2-block = next_else; + + /* ... plus the one to chain it to. */ + c_if1 = XCNEW (gfc_code); + c_if1-op = EXEC_IF; + c_if1-block = c_if2; + c_if1-loc = else_stmt-loc; + + /* Insert the new IF after the ELSE. */ + else_stmt-expr1 = NULL; + else_stmt-next = c_if1; + else_stmt-block = NULL; + else_stmt-next = c_if1; + + else_stmt = next_else; +} + /* Don't walk subtrees. */ + return 0; +} /* Optimize a namespace, including all contained namespaces. */ static void @@ -520,6 +584,7 @@ optimize_namespace (gfc_namespace *ns) in_omp_workshare = false; gfc_code_walker (ns-code, convert_do_while, dummy_expr_callback, NULL); + gfc_code_walker (ns-code, convert_elseif, dummy_expr_callback, NULL); gfc_code_walker (ns-code, cfe_code, cfe_expr_0, NULL); gfc_code_walker (ns-code, optimize_code, optimize_expr, NULL);
Re: [patch, fortran] Fix PR 51958, wrong-code regression with function elimination
On Wed, Feb 01, 2012 at 12:07:35AM +0100, Thomas Koenig wrote: Hi Tobias, here is an updated version of the patch, with a more extensive test case. Also regression-tested. OK for trunk? + /* Insert the new IF after the ELSE. */ + else_stmt-expr1 = NULL; + else_stmt-next = c_if1; + else_stmt-block = NULL; + else_stmt-next = c_if1; Is one of the else_stmt-next = c_if1; redundant? -- Steve
Re: [patch, fortran] Fix PR 51958, wrong-code regression with function elimination
Hi Steve, + else_stmt-expr1 = NULL; + else_stmt-next = c_if1; + else_stmt-block = NULL; + else_stmt-next = c_if1; Is one of the else_stmt-next = c_if1; redundant? Definitely. I'll take it out when I commit the patch. Thomas
Go patch committed: Don't crash on case nil
I discovered that gccgo crashes on a test case like: package p type S struct { f interface{} } func F(p *S) bool { v := p.f switch a := v.(type) { case nil: _ = a return true } return true } The case nil in the type switch causes the find_methods traversal to try to get the type of v, but that is invalid before lowering. This patch fixes the problem. I've added the test case to the master Go testsuite. Bootstrapped and ran Go testsuite on x86_64-unknown-linux-gnu. Committed to mainline. Ian diff -r a767ab0415d3 go/gogo.cc --- a/go/gogo.cc Tue Jan 31 12:47:10 2012 -0800 +++ b/go/gogo.cc Tue Jan 31 15:59:40 2012 -0800 @@ -3848,6 +3848,24 @@ b-set_end_location(s-location()); } +// Whether this variable has a type. + +bool +Variable::has_type() const +{ + if (this-type_ == NULL) +return false; + + // A variable created in a type switch case nil does not actually + // have a type yet. It will be changed to use the initializer's + // type in determine_type. + if (this-is_type_switch_var_ + this-type_-is_nil_constant_as_type()) +return false; + + return true; +} + // In an assignment which sets a variable to a tuple of EXPR, return // the type of the first element of the tuple. diff -r a767ab0415d3 go/gogo.h --- a/go/gogo.h Tue Jan 31 12:47:10 2012 -0800 +++ b/go/gogo.h Tue Jan 31 15:59:40 2012 -0800 @@ -1154,8 +1154,7 @@ // Return whether the type is defined yet. bool - has_type() const - { return this-type_ != NULL; } + has_type() const; // Get the initial value. Expression*
Re: [v3] proposed fix for libstdc++/49204 causes abi_check failure
A bit later than I originally planned, but this is now committed, as attached. 2012-02-01 Jonathan Wakely jwakely@gmail.com PR libstdc++/49204 * include/std/future (__future_base::_State_base::wait()): Use lambda expression for predicate and remove redundant test. (__future_base::_State_base::wait_for()): Return future_status and use lambda expression for predicate. (__future_base::_State_base::wait_until()): Likewise. (__basic_future::wait_for(), __basic_future::wait_until()): Likewise. (__future_base::_Async_state): Replace with _Async_state_common class for non-dependent functionality and _Async_state_impl class template for dependent functionality. (__future_base::_Async_state_common::_M_join): Serialize attempts to join thread. (__future_base::_Async_state_common::_M_run_deferred): Join. (__future_base::_Async_state::_M_do_run): Replace with lambda. * src/c++11/future.cc (__future_base::_Async_state_common): Define destructor, so key function is in the library. * config/abi/pre/gnu.ver: Add exports for ~_Async_state_common. * testsuite/30_threads/packaged_task/members/get_future.cc: Expect future_status return instead of bool. * testsuite/30_threads/shared_future/members/wait_until.cc: Likewise. * testsuite/30_threads/shared_future/members/wait_for.cc: Likewise. * testsuite/30_threads/future/members/wait_until.cc: Likewise. * testsuite/30_threads/future/members/wait_for.cc: Likewise. * testsuite/30_threads/promise/members/set_value2.cc: Likewise. * testsuite/30_threads/promise/members/set_value3.cc: Likewise. * testsuite/30_threads/promise/members/swap.cc: Likewise. Tested x86_64-linux. diff --git a/libstdc++-v3/config/abi/pre/gnu.ver b/libstdc++-v3/config/abi/pre/gnu.ver index ce56120..41d38a7 100644 --- a/libstdc++-v3/config/abi/pre/gnu.ver +++ b/libstdc++-v3/config/abi/pre/gnu.ver @@ -1307,6 +1307,14 @@ GLIBCXX_3.4.17 { # std::wstring::pop_back() _ZNSbIwSt11char_traitsIwESaIwEE8pop_backEv; +# std::_Async_state_common::~_Async_state_common +_ZTINSt13__future_base19_Async_state_commonE; +_ZTSNSt13__future_base19_Async_state_commonE; +_ZTVNSt13__future_base19_Async_state_commonE; +_ZNSt13__future_base19_Async_state_commonD0Ev; +_ZNSt13__future_base19_Async_state_commonD1Ev; +_ZNSt13__future_base19_Async_state_commonD2Ev; + } GLIBCXX_3.4.16; # Symbols in the support library (libsupc++) have their own tag. diff --git a/libstdc++-v3/include/std/future b/libstdc++-v3/include/std/future index d3180e9..1093e3f 100644 --- a/libstdc++-v3/include/std/future +++ b/libstdc++-v3/include/std/future @@ -1,6 +1,6 @@ // future -*- C++ -*- -// Copyright (C) 2009, 2010, 2011 Free Software Foundation, Inc. +// Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the @@ -328,27 +328,28 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { _M_run_deferred(); unique_lockmutex __lock(_M_mutex); - if (!_M_ready()) - _M_cond.wait(__lock, std::bindbool(_State_base::_M_ready, this)); + _M_cond.wait(__lock, [] { return _M_ready(); }); return *_M_result; } templatetypename _Rep, typename _Period -bool +future_status wait_for(const chrono::duration_Rep, _Period __rel) { unique_lockmutex __lock(_M_mutex); - auto __bound = std::bindbool(_State_base::_M_ready, this); - return _M_ready() || _M_cond.wait_for(__lock, __rel, __bound); + if (_M_cond.wait_for(__lock, __rel, [] { return _M_ready(); })) + return future_status::ready; + return future_status::timeout; } templatetypename _Clock, typename _Duration -bool +future_status wait_until(const chrono::time_point_Clock, _Duration __abs) { unique_lockmutex __lock(_M_mutex); - auto __bound = std::bindbool(_State_base::_M_ready, this); - return _M_ready() || _M_cond.wait_until(__lock, __abs, __bound); + if (_M_cond.wait_until(__lock, __abs, [] { return _M_ready(); })) + return future_status::ready; + return future_status::timeout; } void @@ -480,14 +481,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION bool _M_ready() const noexcept { return static_castbool(_M_result); } + // Misnamed: waits for completion of async function. virtual void _M_run_deferred() { } }; templatetypename _BoundFn, typename = typename _BoundFn::result_type class _Deferred_state; +class _Async_state_common; + templatetypename _BoundFn, typename = typename _BoundFn::result_type - class _Async_state; +
Re: [PATCH] disable __size_t macro on GNU/kFreeBSD
On Jan 31, 2012, at 2:29 PM, Gerald Pfeifer wrote: On Sun, 29 Jan 2012, Robert Millan wrote: Please consider this patch to stddef.h. GNU/kFreeBSD has the same problem with __size_t as FreeBSD does, since it inherits many kernel headers from FreeBSD. The patch looks obvious to me, and I'll be happy to apply for Robert if approved. Any taker? Looks obvious to me as well. I'd say let's put it in...
Re: [patch, fortran] Fix PR 51958, wrong-code regression with function elimination
On Wed, Feb 01, 2012 at 12:47:28AM +0100, Thomas Koenig wrote: Hi Steve, + else_stmt-expr1 = NULL; + else_stmt-next = c_if1; + else_stmt-block = NULL; + else_stmt-next = c_if1; Is one of the else_stmt-next = c_if1; redundant? Definitely. I'll take it out when I commit the patch. Patch looks fine, then. OK to commit. -- Steve
Merge from mainline to gccgo branch
I've merged mainline revision 183782 to the gccgo branch. Ian
[pph] Fix streaming of structures inside shared structures (issue5607045)
This patch fixes a problem with streaming of symbols and types that have mutated from one PPH to another. --- parent.h - #include child.h struct C1 { int field1; float field2; }; - --- child.h - struct C1; - When we read child.pph from parent.pph, we will notice that struct C1 has mutated, so we read its body again (which fills in the fields, etc). However, the TYPE_LANG_DECL structure for C1 is also present in the pickle cache for child.pph, and we were using it unmodified. In this case, one of the fields in TYPE_LANG_DECL was CLASSTYPE_LAZY_DEFAULT_CTOR, which had not been set in child.pph, so when we tried to use the default ctor from struct C1 during code generation, we were never finding it. This was causing the failure in x1namespace-alias2.cc and two other ICEs in the dynarray tests. What the patch does is to never insert in the pickle cache any structures that are embedded in structures that are already inside other structures that get put in the cache. We now always write out the contents of these structures (using the PPH_RECORD_START_NO_CACHE marker). This includes the structures: PPH_binding_table, PPH_function, PPH_lang_decl, PPH_lang_type, PPH_language_function and PPH_sorted_fields_type. Since these structures are always embedded in structures that are already shared, they are never read and allocated more than once, unless the parent structure is pickled. Additionally, this simplifies the logic in the reader, since it never needs to worry about adding these structures to the cache. cp/ChangeLog.pph * name-lookup.c (pph_out_binding_table): Use PPH_RECORD_START_NO_CACHE records. (pph_in_binding_table): Likewise. * pph-in.c (pph_in_language_function): Remove caching code, assume that the structure is always in a PPH_RECORD_START_NO_CACHE. (pph_in_struct_function): Likewise. (pph_in_lang_decl): Likewise. (pph_in_sorted_fields_type): Likewise. (pph_in_lang_type_class): Likewise. (pph_in_lang_type): Likewise. (pph_in_lang_decl_start): Remove. * pph-out.c (pph_get_marker_for): Always return PPH_RECORD_START_NO_CACHE for PPH_binding_table, PPH_function, PPH_lang_decl, PPH_lang_type, PPH_language_function and PPH_sorted_fields_type. (pph_out_start_record): Do not write IX for PPH_RECORD_START_NO_CACHE. (pph_out_language_function): Only support PPH_RECORD_START_NO_CACHE or PPH_RECORD_END. (pph_out_struct_function): Likewise. (pph_out_lang_decl): Likewise. (pph_out_sorted_fields_type): Likewise. (pph_out_lang_type_class): Likewise. (pph_out_lang_type): Likewise. testsuite/ChangeLog.pph * g++.dg/pph/x1namespace-alias2.cc: Mark fixed. * g++.dg/pph/x6dynarray4.cc: Remove expected ICE. * g++.dg/pph/x7dynarray5.cc: Remove expected ICE. diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index 463b14d..cbc8ee9 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -6057,7 +6057,7 @@ pph_out_binding_table (pph_stream *stream, binding_table bt) { if (bt-chain[i]) { - pph_out_record_marker (stream, PPH_RECORD_START, PPH_binding_entry); + pph_out_record_marker (stream, PPH_RECORD_START_NO_CACHE, PPH_binding_entry); pph_out_tree (stream, bt-chain[i]-name); pph_out_tree (stream, bt-chain[i]-type); } @@ -6083,7 +6083,7 @@ pph_in_binding_table (pph_stream *stream) enum pph_tag tag; enum pph_record_marker marker = pph_in_record_marker (stream, tag); gcc_assert (tag == PPH_binding_entry); - if (marker == PPH_RECORD_START) + if (marker == PPH_RECORD_START_NO_CACHE) { tree name = pph_in_tree (stream); tree type = pph_in_tree (stream); diff --git a/gcc/cp/pph-in.c b/gcc/cp/pph-in.c index 52d21ae..114ceda 100644 --- a/gcc/cp/pph-in.c +++ b/gcc/cp/pph-in.c @@ -1300,16 +1300,10 @@ pph_in_language_function (pph_stream *stream) marker = pph_in_start_record (stream, image_ix, ix, PPH_language_function); if (marker == PPH_RECORD_END) return NULL; - else if (pph_is_reference_marker (marker)) -return (struct language_function *) pph_cache_find (stream, marker, - image_ix, ix, - PPH_language_function); - /* Remove if we start emitting merge keys for this structure. */ - gcc_assert (marker == PPH_RECORD_START); + gcc_assert (marker == PPH_RECORD_START_NO_CACHE); - ALLOC_AND_REGISTER (stream-cache, ix, PPH_language_function, lf, -
[google] Propagate profile information to RTL level during switch expansion
This patch propagates profile information to RTL level when expanding switch statements using jump table or a binary tree of branches. Ok for google/gcc-4_6 branch? I would like the patch to be considered for trunk when stage 1 opens again. -Easwaran 2012-01-31 Easwaran Raman era...@google.com * expr.c (do_tablejump): Add default_probability as the sixth parameter and use it to generate REG_BR_PROB note. (try_tablejump): Add default_probability as a parameter. * cfgbuild.c (non_zero_profile_counts): New function. (compute_outgoing_frequencies): If edges have profile counts set, don't replace them with guessed values. * expr.h (try_tablejump): Add additional parameter to the declaration. * stmt.c (tree-flow.h): Include. (case_node): Add new fields count and subtree_count. (add_case_node): Pass count as a paramater and initialize count field of case_node. (case_probability): New macro. (expand_case): Propagate profile information from the tree level to RTL during switch case expansion. (balance_case_nodes): Compute subtree_count for case nodes. (emit_case_nodes): Set branch probabilities for generated branches. testsuite/ChengeLog.google-4_6: 2012-01-31 Easwaran Raman era...@google.com * tree-prof/switch-case-1.c: New test. * tree-prof/switch-case-2.c: New test. Index: gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c === --- gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-prof/switch-case-1.c (revision 0) @@ -0,0 +1,40 @@ +/* { dg-options -O2 -fdump-rtl-expand-blocks -fdump-tree-optimized-blocks } */ +int g; + +__attribute__((noinline)) void foo (int n) +{ + switch (n) +{ +case 1: + g++; break; +case 2: + g += 2; break; +case 3: + g += 1; break; +case 4: + g += 3; break; +case 5: + g += 4; break; +case 6: + g += 5; break; +case 7: + g += 6; break; +case 8: + g += 7; break; +case 9: + g += 8; break; +default: + g += 8; break; + } +} + +int main () +{ + int i; + for (i = 0; i 1; i++) + foo ((i * i) % 5); + return 0; +} +/* { dg-final-use { scan-rtl-dump-times Succ edge\[^\\n\]*count:4000 4 expand} } */ +/* { dg-final-use { scan-rtl-dump-times Succ edge\[^\\n\]*count:2000 1 expand} } */ +/* { dg-final-use { cleanup-rtl-dump expand } } */ Index: gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c === --- gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c (revision 0) +++ gcc/testsuite/gcc.dg/tree-prof/switch-case-2.c (revision 0) @@ -0,0 +1,40 @@ +/* { dg-options -O2 -fdump-rtl-expand-blocks } */ +int g; + +__attribute__((noinline)) void foo (int n) +{ + switch (n) +{ +case 99: + g += 2; break; +case 1: + g++; break; +case 100: + g += 1; break; +case 4: + g += 3; break; +case 5: + g += 4; break; +case 6: + g += 5; break; +case 7: + g += 6; break; +case 8: + g += 7; break; +case 9: + g += 8; break; +default: + g += 8; break; + } +} + +int main () +{ + int i; + for (i = 0; i 1; i++) + foo ((i * i) % 5); + return 0; +} +/* { dg-final-use { scan-rtl-dump-times Succ edge\[^\\n\]*count:4000 4 expand} } */ +/* { dg-final-use { scan-rtl-dump-times Succ edge\[^\\n\]*count:2000 1 expand} } */ +/* { dg-final-use { cleanup-rtl-dump expand } } */ Index: gcc/expr.c === --- gcc/expr.c (revision 183262) +++ gcc/expr.c (working copy) @@ -155,7 +155,7 @@ static rtx do_store_flag (sepops, rtx, enum machin #ifdef PUSH_ROUNDING static void emit_single_push_insn (enum machine_mode, rtx, tree); #endif -static void do_tablejump (rtx, enum machine_mode, rtx, rtx, rtx); +static void do_tablejump (rtx, enum machine_mode, rtx, rtx, rtx, int); static rtx const_vector_from_tree (tree); static void write_complex_part (rtx, rtx, bool); @@ -10245,7 +10245,7 @@ try_casesi (tree index_type, tree index_expr, tree static void do_tablejump (rtx index, enum machine_mode mode, rtx range, rtx table_label, - rtx default_label) + rtx default_label, int default_probability) { rtx temp, vector; @@ -10261,9 +10261,17 @@ do_tablejump (rtx index, enum machine_mode mode, r the maximum value of the range. */ if (default_label) -emit_cmp_and_jump_insns (index, range, GTU, NULL_RTX, mode, 1, - default_label); +{ + emit_cmp_and_jump_insns (index, range, GTU, NULL_RTX, mode, 1, + default_label); + if (default_probability != -1) +{ + rtx jump_insn = get_last_insn(); + add_reg_note (jump_insn, REG_BR_PROB, GEN_INT (default_probability)); +} +} + /* If index
Re: [wwwdocs] Add section on diagnostics conventions
On Mon, Jan 30, 2012 at 15:21, Joseph S. Myers jos...@codesourcery.com wrote: On Sun, 29 Jan 2012, Diego Novillo wrote: +licodeinternal_error/code is used for conditions that should not +be triggered by any user input whether valid or invalid and including +invalid asms and LTO binary data (sometimes, as an exception, there is +a call to codeerror/code before further information is printed and +an ICE is triggered)./li + +liAssertion failures should not be triggered by invalid input. +codeinform/code is for informative notes accompanying errors and +warnings. All diagnostics should be full sentences without English +fragments substituted in them, to facilitate translation./li The three sentences in this last list item are actually three independent and unrelated points. I think the first one about assertion failures should be moved up into the previous list item, while the remaining two sentences should each be a list item on its own. Thanks. Fixed with the patch below. Index: codingconventions.html === RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v retrieving revision 1.63 diff -u -d -u -p -r1.63 codingconventions.html --- codingconventions.html 12 Feb 2011 15:49:51 - 1.63 +++ codingconventions.html 1 Feb 2012 01:47:55 - @@ -157,6 +157,47 @@ regression-checkers distinguish a true r to the test suite./p +h2Diagnostics Conventions/h2 +ul + +liUse of the codeinput_location/code global, and of the +diagnostic functions that implicitly use codeinput_location/code, +is deprecated; the preferred technique is to pass around locations +ultimately derived from the location of some explicitly chosen source +code token./li + +liDiagnostics using the GCC diagnostic functions should generally +use the GCC-specific formats such as code%qs/code or +code%lt;/code and code%gt;/code for quoting and +code%m/code for codeerrno/code numbers./li + +liIdentifiers should generally be formatted with code%E/code or +code%qE/code; use of codeidentifier_to_locale/code is needed +if the identifier text is used directly./li + +liFormats such as code%wd/code should be used with types such as +codeHOST_WIDE_INT/code (codeHOST_WIDE_INT_PRINT_DEC/code is a +format for the host codeprintf/code functions, not for the GCC +diagnostic functions)./li + +licodeerror/code is for defects in the user's code./li + +licodeinternal_error/code is used for conditions that should not +be triggered by any user input whether valid or invalid and including +invalid asms and LTO binary data (sometimes, as an exception, there is +a call to codeerror/code before further information is printed and +an ICE is triggered). Assertion failures should not be triggered by +invalid input./li + +licodeinform/code is for informative notes accompanying errors +and warnings./li + +liAll diagnostics should be full sentences without English +fragments substituted in them, to facilitate translation./li + +/ul + + h2Miscellaneous Conventions/h2 pCode should use codegcc_assert(EXPR)/code to check invariants.
Re: [google] Propagate profile information to RTL level during switch expansion
Ok for google branch with minor changes below. thanks, David +static bool non_zero_profile_counts ( VEC(edge,gc) *edges) { static bool non_zero_profile_counts(...) Please also provide function documentation. + edge e; + edge_iterator ei; + FOR_EACH_EDGE(e, ei, edges) + { + if (e-count 0) + return true; + } + return false; +} +#define case_probability(x, y) ((y) ? ((x) * REG_BR_PROB_BASE / (y)) : -1) + Using upper case for macro? + int default_count = 0; int -- gcov_type + int count = bb-count; int -- gcov_type table_label = gen_label_rtx (); if (! try_casesi (index_type, index_expr, minval, range, table_label, default_label, fallback_label)) { bool ok; + int default_probability; + if (has_gaps) + { + /* There is at least one entry in the jump table that jumps + to default label. The default label can either be reached + through the indirect jump or the direct conditional jump + before that. Split the probability of reaching the + default label among these two jumps. */ + default_probability = case_probability (default_count/2, + bb-count); Some heuristics can probably be developed to make better split of the default probability and value range information can be used. For instance, if the case values are from an enum and the gaps between two enumerators are defined, then the preceding conditional jump should have get 100% of the default probability. This can be enhanced later. + count -= default_count; + default_count = 0; Why resetting it to 0? + +static void +add_prob_note_to_last_insn(int probability) +{ Missing document.