This commit is contained in:
Jakub Jelinek 2009-06-12 10:08:19 +00:00
parent 473419c647
commit 23f7769aa4
9 changed files with 6 additions and 11986 deletions

View File

@ -1,2 +1,2 @@
fastjar-0.97.tar.gz fastjar-0.97.tar.gz
gcc-4.4.0-20090609.tar.bz2 gcc-4.4.0-20090612.tar.bz2

View File

@ -480,6 +480,10 @@ tar xjf %{SOURCE10}
sed -i -e 's/4\.4\.1/4.4.0/' gcc/BASE-VER sed -i -e 's/4\.4\.1/4.4.0/' gcc/BASE-VER
echo 'Red Hat %{version}-%{gcc_release}' > gcc/DEV-PHASE echo 'Red Hat %{version}-%{gcc_release}' > gcc/DEV-PHASE
# Default to -gdwarf-3 rather than -gdwarf-2
sed -i '/UInteger Var(dwarf_version)/s/Init(2)/Init(3)/' gcc/common.opt
sed -i 's/\(may be either 2 or 3; the default version is \)2\./\13./' gcc/doc/invoke.texi
cp -a libstdc++-v3/config/cpu/i{4,3}86/atomicity.h cp -a libstdc++-v3/config/cpu/i{4,3}86/atomicity.h
# Hack to avoid building multilib libjava # Hack to avoid building multilib libjava

View File

@ -1,43 +0,0 @@
2009-05-20 H.J. Lu <hongjiu.lu@intel.com>
* config/i386/driver-i386.c (host_detect_local_cpu): Check
extended family and model for Intel processors. Support Intel
Atom.
--- gcc/config/i386/driver-i386.c (revision 147735)
+++ gcc/config/i386/driver-i386.c (revision 147736)
@@ -395,9 +395,22 @@ const char *host_detect_local_cpu (int a
__cpuid (1, eax, ebx, ecx, edx);
- /* We don't care for extended family. */
model = (eax >> 4) & 0x0f;
family = (eax >> 8) & 0x0f;
+ if (vendor == SIG_INTEL)
+ {
+ unsigned int extended_model, extended_family;
+
+ extended_model = (eax >> 12) & 0xf0;
+ extended_family = (eax >> 20) & 0xff;
+ if (family == 0x0f)
+ {
+ family += extended_family;
+ model += extended_model;
+ }
+ else if (family == 0x06)
+ model += extended_model;
+ }
has_sse3 = ecx & bit_SSE3;
has_ssse3 = ecx & bit_SSSE3;
@@ -496,8 +509,8 @@ const char *host_detect_local_cpu (int a
break;
case PROCESSOR_PENTIUMPRO:
if (has_longmode)
- /* It is Core 2 Duo. */
- cpu = "core2";
+ /* It is Core 2 or Atom. */
+ cpu = (model == 28) ? "atom" : "core2";
else if (arch)
{
if (has_sse3)

View File

@ -1,301 +0,0 @@
2009-05-21 H.J. Lu <hongjiu.lu@intel.com>
Uros Bizjak <ubizjak@gmail.com>
* config/i386/cpuid.h (bit_MOVBE): New.
* config/i386/driver-i386.c (host_detect_local_cpu): Check movbe.
* config/i386/i386.c (OPTION_MASK_ISA_MOVBE_SET): New.
(OPTION_MASK_ISA_MOVBE_UNSET): Likewise.
(ix86_handle_option): Handle OPT_mmovbe.
(ix86_target_string): Add -mmovbe.
(pta_flags): Add PTA_MOVBE.
(processor_alias_table): Add PTA_MOVBE to "atom".
(override_options): Handle PTA_MOVBE.
* config/i386/i386.h (TARGET_MOVBE): New.
* config/i386/i386.md (bswapsi2): Check TARGET_MOVBE.
(*bswapsi_movbe): New.
(*bswapdi_movbe): Likewise.
(bswapdi2): Renamed to ...
(*bswapdi_1): This.
(bswapdi2): New expander.
* config/i386/i386.opt (mmovbe): New.
* doc/invoke.texi: Document -mmovbe.
* gcc.target/i386/movbe-1.c: New.
* gcc.target/i386/movbe-2.c: Likewise.
--- gcc/doc/invoke.texi (revision 147772)
+++ gcc/doc/invoke.texi (revision 147773)
@@ -577,7 +577,7 @@ Objective-C and Objective-C++ Dialects}.
-mno-wide-multiply -mrtd -malign-double @gol
-mpreferred-stack-boundary=@var{num}
-mincoming-stack-boundary=@var{num}
--mcld -mcx16 -msahf -mrecip @gol
+-mcld -mcx16 -msahf -mmovbe -mrecip @gol
-mmmx -msse -msse2 -msse3 -mssse3 -msse4.1 -msse4.2 -msse4 -mavx @gol
-maes -mpclmul @gol
-msse4a -m3dnow -mpopcnt -mabm -msse5 @gol
@@ -11458,6 +11458,11 @@ SAHF are load and store instructions, re
In 64-bit mode, SAHF instruction is used to optimize @code{fmod}, @code{drem}
or @code{remainder} built-in functions: see @ref{Other Builtins} for details.
+@item -mmovbe
+@opindex mmovbe
+This option will enable GCC to use movbe instruction to implement
+@code{__builtin_bswap32} and @code{__builtin_bswap64}.
+
@item -mrecip
@opindex mrecip
This option will enable GCC to use RCPSS and RSQRTSS instructions (and their
--- gcc/testsuite/gcc.target/i386/movbe-1.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/movbe-1.c (revision 147773)
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mmovbe" } */
+
+extern int x;
+
+void
+foo (int i)
+{
+ x = __builtin_bswap32 (i);
+}
+
+int
+bar ()
+{
+ return __builtin_bswap32 (x);
+}
+
+/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 } } */
--- gcc/testsuite/gcc.target/i386/movbe-2.c (revision 0)
+++ gcc/testsuite/gcc.target/i386/movbe-2.c (revision 147773)
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -mmovbe" } */
+
+extern long long x;
+
+void
+foo (long long i)
+{
+ x = __builtin_bswap64 (i);
+}
+
+long long
+bar ()
+{
+ return __builtin_bswap64 (x);
+}
+
+/* { dg-final { scan-assembler-times "movbe\[ \t\]" 4 { target ilp32 } } } */
+/* { dg-final { scan-assembler-times "movbe\[ \t\]" 2 { target lp64 } } } */
--- gcc/config/i386/i386.h (revision 147772)
+++ gcc/config/i386/i386.h (revision 147773)
@@ -59,6 +59,7 @@ see the files COPYING3 and COPYING.RUNTI
#define TARGET_ABM OPTION_ISA_ABM
#define TARGET_POPCNT OPTION_ISA_POPCNT
#define TARGET_SAHF OPTION_ISA_SAHF
+#define TARGET_MOVBE OPTION_ISA_MOVBE
#define TARGET_AES OPTION_ISA_AES
#define TARGET_PCLMUL OPTION_ISA_PCLMUL
#define TARGET_CMPXCHG16B OPTION_ISA_CX16
--- gcc/config/i386/i386.md (revision 147772)
+++ gcc/config/i386/i386.md (revision 147773)
@@ -16105,7 +16105,7 @@ (define_expand "bswapsi2"
(bswap:SI (match_operand:SI 1 "register_operand" "")))]
""
{
- if (!TARGET_BSWAP)
+ if (!(TARGET_BSWAP || TARGET_MOVBE))
{
rtx x = operands[0];
@@ -16117,6 +16117,21 @@ (define_expand "bswapsi2"
}
})
+(define_insn "*bswapsi_movbe"
+ [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,m")
+ (bswap:SI (match_operand:SI 1 "nonimmediate_operand" "0,m,r")))]
+ "TARGET_MOVBE && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
+ "@
+ bswap\t%0
+ movbe\t{%1, %0|%0, %1}
+ movbe\t{%1, %0|%0, %1}"
+ [(set_attr "type" "*,imov,imov")
+ (set_attr "modrm" "*,1,1")
+ (set_attr "prefix_0f" "1")
+ (set_attr "prefix_extra" "*,1,1")
+ (set_attr "length" "2,*,*")
+ (set_attr "mode" "SI")])
+
(define_insn "*bswapsi_1"
[(set (match_operand:SI 0 "register_operand" "=r")
(bswap:SI (match_operand:SI 1 "register_operand" "0")))]
@@ -16145,7 +16160,29 @@ (define_insn "bswaphi_lowpart"
[(set_attr "length" "4")
(set_attr "mode" "HI")])
-(define_insn "bswapdi2"
+(define_expand "bswapdi2"
+ [(set (match_operand:DI 0 "register_operand" "")
+ (bswap:DI (match_operand:DI 1 "register_operand" "")))]
+ "TARGET_64BIT"
+ "")
+
+(define_insn "*bswapdi_movbe"
+ [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,m")
+ (bswap:DI (match_operand:DI 1 "nonimmediate_operand" "0,m,r")))]
+ "TARGET_64BIT && TARGET_MOVBE
+ && !(MEM_P (operands[0]) && MEM_P (operands[1]))"
+ "@
+ bswap\t%0
+ movbe\t{%1, %0|%0, %1}
+ movbe\t{%1, %0|%0, %1}"
+ [(set_attr "type" "*,imov,imov")
+ (set_attr "modrm" "*,1,1")
+ (set_attr "prefix_0f" "1")
+ (set_attr "prefix_extra" "*,1,1")
+ (set_attr "length" "3,*,*")
+ (set_attr "mode" "DI")])
+
+(define_insn "*bswapdi_1"
[(set (match_operand:DI 0 "register_operand" "=r")
(bswap:DI (match_operand:DI 1 "register_operand" "0")))]
"TARGET_64BIT"
--- gcc/config/i386/cpuid.h (revision 147772)
+++ gcc/config/i386/cpuid.h (revision 147773)
@@ -29,6 +29,7 @@
#define bit_CMPXCHG16B (1 << 13)
#define bit_SSE4_1 (1 << 19)
#define bit_SSE4_2 (1 << 20)
+#define bit_MOVBE (1 << 22)
#define bit_POPCNT (1 << 23)
#define bit_AES (1 << 25)
#define bit_XSAVE (1 << 26)
--- gcc/config/i386/i386.opt (revision 147772)
+++ gcc/config/i386/i386.opt (revision 147773)
@@ -339,6 +339,10 @@ msahf
Target Report Mask(ISA_SAHF) Var(ix86_isa_flags) VarExists Save
Support code generation of sahf instruction in 64bit x86-64 code.
+mmovbe
+Target Report Mask(ISA_MOVBE) Var(ix86_isa_flags) VarExists Save
+Support code generation of movbe instruction.
+
maes
Target Report Mask(ISA_AES) Var(ix86_isa_flags) VarExists Save
Support AES built-in functions and code generation
--- gcc/config/i386/driver-i386.c (revision 147772)
+++ gcc/config/i386/driver-i386.c (revision 147773)
@@ -378,7 +378,7 @@ const char *host_detect_local_cpu (int a
/* Extended features */
unsigned int has_lahf_lm = 0, has_sse4a = 0;
unsigned int has_longmode = 0, has_3dnowp = 0, has_3dnow = 0;
- unsigned int has_sse4_1 = 0, has_sse4_2 = 0;
+ unsigned int has_movbe = 0, has_sse4_1 = 0, has_sse4_2 = 0;
unsigned int has_popcnt = 0, has_aes = 0, has_avx = 0;
unsigned int has_pclmul = 0;
@@ -408,6 +408,7 @@ const char *host_detect_local_cpu (int a
has_sse4_2 = ecx & bit_SSE4_2;
has_avx = ecx & bit_AVX;
has_cmpxchg16b = ecx & bit_CMPXCHG16B;
+ has_movbe = ecx & bit_MOVBE;
has_popcnt = ecx & bit_POPCNT;
has_aes = ecx & bit_AES;
has_pclmul = ecx & bit_PCLMUL;
@@ -597,6 +598,8 @@ const char *host_detect_local_cpu (int a
options = concat (options, "-mcx16 ", NULL);
if (has_lahf_lm)
options = concat (options, "-msahf ", NULL);
+ if (has_movbe)
+ options = concat (options, "-mmovbe ", NULL);
if (has_aes)
options = concat (options, "-maes ", NULL);
if (has_pclmul)
--- gcc/config/i386/i386.c (revision 147772)
+++ gcc/config/i386/i386.c (revision 147773)
@@ -1965,9 +1965,11 @@ static int ix86_isa_flags_explicit;
#define OPTION_MASK_ISA_ABM_SET \
(OPTION_MASK_ISA_ABM | OPTION_MASK_ISA_POPCNT)
+
#define OPTION_MASK_ISA_POPCNT_SET OPTION_MASK_ISA_POPCNT
#define OPTION_MASK_ISA_CX16_SET OPTION_MASK_ISA_CX16
#define OPTION_MASK_ISA_SAHF_SET OPTION_MASK_ISA_SAHF
+#define OPTION_MASK_ISA_MOVBE_SET OPTION_MASK_ISA_MOVBE
/* Define a set of ISAs which aren't available when a given ISA is
disabled. MMX and SSE ISAs are handled separately. */
@@ -2009,6 +2011,7 @@ static int ix86_isa_flags_explicit;
#define OPTION_MASK_ISA_POPCNT_UNSET OPTION_MASK_ISA_POPCNT
#define OPTION_MASK_ISA_CX16_UNSET OPTION_MASK_ISA_CX16
#define OPTION_MASK_ISA_SAHF_UNSET OPTION_MASK_ISA_SAHF
+#define OPTION_MASK_ISA_MOVBE_UNSET OPTION_MASK_ISA_MOVBE
/* Vectorization library interface and handlers. */
tree (*ix86_veclib_handler)(enum built_in_function, tree, tree) = NULL;
@@ -2299,6 +2302,19 @@ ix86_handle_option (size_t code, const c
}
return true;
+ case OPT_mmovbe:
+ if (value)
+ {
+ ix86_isa_flags |= OPTION_MASK_ISA_MOVBE_SET;
+ ix86_isa_flags_explicit |= OPTION_MASK_ISA_MOVBE_SET;
+ }
+ else
+ {
+ ix86_isa_flags &= ~OPTION_MASK_ISA_MOVBE_UNSET;
+ ix86_isa_flags_explicit |= OPTION_MASK_ISA_MOVBE_UNSET;
+ }
+ return true;
+
case OPT_maes:
if (value)
{
@@ -2361,6 +2377,7 @@ ix86_target_string (int isa, int flags,
{ "-mmmx", OPTION_MASK_ISA_MMX },
{ "-mabm", OPTION_MASK_ISA_ABM },
{ "-mpopcnt", OPTION_MASK_ISA_POPCNT },
+ { "-mmovbe", OPTION_MASK_ISA_MOVBE },
{ "-maes", OPTION_MASK_ISA_AES },
{ "-mpclmul", OPTION_MASK_ISA_PCLMUL },
};
@@ -2577,7 +2594,8 @@ override_options (bool main_args_p)
PTA_AES = 1 << 17,
PTA_PCLMUL = 1 << 18,
PTA_AVX = 1 << 19,
- PTA_FMA = 1 << 20
+ PTA_FMA = 1 << 20,
+ PTA_MOVBE = 1 << 21
};
static struct pta
@@ -2621,7 +2639,7 @@ override_options (bool main_args_p)
| PTA_SSSE3 | PTA_CX16},
{"atom", PROCESSOR_ATOM, CPU_ATOM,
PTA_64BIT | PTA_MMX | PTA_SSE | PTA_SSE2 | PTA_SSE3
- | PTA_SSSE3 | PTA_CX16},
+ | PTA_SSSE3 | PTA_CX16 | PTA_MOVBE},
{"geode", PROCESSOR_GEODE, CPU_GEODE,
PTA_MMX | PTA_3DNOW | PTA_3DNOW_A |PTA_PREFETCH_SSE},
{"k6", PROCESSOR_K6, CPU_K6, PTA_MMX},
@@ -2935,6 +2953,9 @@ override_options (bool main_args_p)
if (!(TARGET_64BIT && (processor_alias_table[i].flags & PTA_NO_SAHF))
&& !(ix86_isa_flags_explicit & OPTION_MASK_ISA_SAHF))
ix86_isa_flags |= OPTION_MASK_ISA_SAHF;
+ if (processor_alias_table[i].flags & PTA_MOVBE
+ && !(ix86_isa_flags_explicit & OPTION_MASK_ISA_MOVBE))
+ ix86_isa_flags |= OPTION_MASK_ISA_MOVBE;
if (processor_alias_table[i].flags & PTA_AES
&& !(ix86_isa_flags_explicit & OPTION_MASK_ISA_AES))
ix86_isa_flags |= OPTION_MASK_ISA_AES;

File diff suppressed because it is too large Load Diff

View File

@ -1,764 +0,0 @@
2009-06-08 Jakub Jelinek <jakub@redhat.com>
* tree-object-size.c (addr_object_size): Add OSI argument.
Handle also INDIRECT_REF with SSA_NAME inside of it as base address.
(compute_builtin_object_size, expr_object_size): Adjust callers.
(plus_stmt_object_size): Call addr_object_size instead of
compute_builtin_object_size.
* gcc.dg/builtin-object-size-2.c (test1): Adjust expected results.
* gcc.dg/builtin-object-size-4.c (test1): Adjust expected results.
* gcc.dg/builtin-object-size-6.c: New test.
--- gcc/testsuite/gcc.dg/builtin-object-size-4.c (revision 148278)
+++ gcc/testsuite/gcc.dg/builtin-object-size-4.c (revision 148279)
@@ -130,15 +130,15 @@ test1 (void *q, int x)
abort ();
if (__builtin_object_size (&vara[5], 3) != 0)
abort ();
- if (__builtin_object_size (&vara[0].a, 3) != 0)
+ if (__builtin_object_size (&vara[0].a, 3) != sizeof (vara[0].a))
abort ();
- if (__builtin_object_size (&vara[10].a[0], 3) != 0)
+ if (__builtin_object_size (&vara[10].a[0], 3) != sizeof (vara[0].a))
abort ();
- if (__builtin_object_size (&vara[5].a[4], 3) != 0)
+ if (__builtin_object_size (&vara[5].a[4], 3) != sizeof (vara[0].a) - 4)
abort ();
- if (__builtin_object_size (&vara[5].b, 3) != 0)
+ if (__builtin_object_size (&vara[5].b, 3) != sizeof (vara[0].b))
abort ();
- if (__builtin_object_size (&vara[7].c[7], 3) != 0)
+ if (__builtin_object_size (&vara[7].c[7], 3) != sizeof (vara[0].c) - 7)
abort ();
if (__builtin_object_size (zerol, 3) != 0)
abort ();
--- gcc/testsuite/gcc.dg/builtin-object-size-2.c (revision 148278)
+++ gcc/testsuite/gcc.dg/builtin-object-size-2.c (revision 148279)
@@ -130,15 +130,15 @@ test1 (void *q, int x)
abort ();
if (__builtin_object_size (&vara[5], 1) != (size_t) -1)
abort ();
- if (__builtin_object_size (&vara[0].a, 1) != (size_t) -1)
+ if (__builtin_object_size (&vara[0].a, 1) != sizeof (vara[0].a))
abort ();
- if (__builtin_object_size (&vara[10].a[0], 1) != (size_t) -1)
+ if (__builtin_object_size (&vara[10].a[0], 1) != sizeof (vara[0].a))
abort ();
- if (__builtin_object_size (&vara[5].a[4], 1) != (size_t) -1)
+ if (__builtin_object_size (&vara[5].a[4], 1) != sizeof (vara[0].a) - 4)
abort ();
- if (__builtin_object_size (&vara[5].b, 1) != (size_t) -1)
+ if (__builtin_object_size (&vara[5].b, 1) != sizeof (vara[0].b))
abort ();
- if (__builtin_object_size (&vara[7].c[7], 1) != (size_t) -1)
+ if (__builtin_object_size (&vara[7].c[7], 1) != sizeof (vara[0].c) - 7)
abort ();
if (__builtin_object_size (zerol, 1) != 0)
abort ();
--- gcc/testsuite/gcc.dg/builtin-object-size-6.c (revision 0)
+++ gcc/testsuite/gcc.dg/builtin-object-size-6.c (revision 148279)
@@ -0,0 +1,435 @@
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+typedef __SIZE_TYPE__ size_t;
+extern void abort (void);
+extern void exit (int);
+extern void *malloc (size_t);
+extern void free (void *);
+
+struct A
+{
+ char a[10];
+ int b;
+ char c[10];
+};
+
+void
+__attribute__ ((noinline))
+test1 (struct A *p)
+{
+ char *c;
+ if (__builtin_object_size (&p->a, 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&p->b, 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&p->c, 0) != (size_t) -1)
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 0) != (size_t) -1)
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 0) != (size_t) -1)
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 0) != (size_t) -1)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 0) != (size_t) -1)
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
+ abort ();
+ if (__builtin_object_size (&p->c, 1) != (size_t) -1)
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 1) != sizeof (p->a))
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 1) != sizeof (p->a))
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 1) != sizeof (p->b))
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 1) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&p->a, 2) != 0)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 2) != 0)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 2) != 0)
+ abort ();
+ if (__builtin_object_size (&p->b, 2) != 0)
+ abort ();
+ if (__builtin_object_size (&p->c, 2) != 0)
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 2) != 0)
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 2) != 0)
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 2) != 0)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 2) != 0)
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 2) != 0)
+ abort ();
+ if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
+ abort ();
+ if (__builtin_object_size (&p->c, 3) != 0)
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 3) != sizeof (p->a))
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 3) != sizeof (p->a))
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 3) != sizeof (p->b))
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 3) != 0)
+ abort ();
+}
+
+void
+__attribute__ ((noinline))
+test2 (void)
+{
+ char *c;
+ size_t s = 2 * sizeof (struct A);
+ struct A *p = malloc (2 * sizeof (struct A));
+ if (__builtin_object_size (&p->a, 0) != s)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 0) != s)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 0) != s - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b))
+ abort ();
+ if (__builtin_object_size (&p->c, 0) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 0) != s)
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 0) != s)
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 0) != s - 3)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, b))
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 0) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
+ abort ();
+ if (__builtin_object_size (&p->c, 1) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 1) != sizeof (p->a))
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 1) != sizeof (p->a))
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 1) != sizeof (p->a) - 3)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 1) != sizeof (p->b))
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 1) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ if (__builtin_object_size (&p->a, 2) != s)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 2) != s)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 2) != s - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 2) != s - __builtin_offsetof (struct A, b))
+ abort ();
+ if (__builtin_object_size (&p->c, 2) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 2) != s)
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 2) != s)
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 2) != s - 3)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, b))
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 2) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ if (__builtin_object_size (&p->a, 3) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[0], 3) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[3], 3) != sizeof (p->a) - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 3) != sizeof (p->b))
+ abort ();
+ if (__builtin_object_size (&p->c, 3) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ c = p->a;
+ if (__builtin_object_size (c, 3) != sizeof (p->a))
+ abort ();
+ c = &p->a[0];
+ if (__builtin_object_size (c, 3) != sizeof (p->a))
+ abort ();
+ c = &p->a[3];
+ if (__builtin_object_size (c, 3) != sizeof (p->a) - 3)
+ abort ();
+ c = (char *) &p->b;
+ if (__builtin_object_size (c, 3) != sizeof (p->b))
+ abort ();
+ c = (char *) &p->c;
+ if (__builtin_object_size (c, 3) != s - __builtin_offsetof (struct A, c))
+ abort ();
+ free (p);
+}
+
+void
+__attribute__ ((noinline))
+test3 (void)
+{
+ char *c;
+ size_t s;
+ struct A *p = malloc (4);
+ if (__builtin_object_size (&p->a, 0) != 4)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 0) != 4)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 0) != 1)
+ abort ();
+ if (__builtin_object_size (&p->b, 0) != 0)
+ abort ();
+ if (__builtin_object_size (&p->c, 0) != 0)
+ abort ();
+ if (__builtin_object_size (&p->a, 1) != 4)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 1) != 4)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 1) != 1)
+ abort ();
+ if (__builtin_object_size (&p->b, 1) != 0)
+ abort ();
+ if (__builtin_object_size (&p->c, 1) != 0)
+ abort ();
+ free (p);
+ s = __builtin_offsetof (struct A, c) + 4;
+ p = malloc (s);
+ if (__builtin_object_size (&p->a, 0) != s)
+ abort ();
+ if (__builtin_object_size (&p->a[0], 0) != s)
+ abort ();
+ if (__builtin_object_size (&p->a[3], 0) != s - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 0) != s - __builtin_offsetof (struct A, b))
+ abort ();
+ if (__builtin_object_size (&p->c, 0) != 4)
+ abort ();
+ if (__builtin_object_size (&p->a, 1) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[0], 1) != sizeof (p->a))
+ abort ();
+ if (__builtin_object_size (&p->a[3], 1) != sizeof (p->a) - 3)
+ abort ();
+ if (__builtin_object_size (&p->b, 1) != sizeof (p->b))
+ abort ();
+ if (__builtin_object_size (&p->c, 1) != 4)
+ abort ();
+ free (p);
+}
+
+struct B
+{
+ struct A a[4];
+};
+
+void
+__attribute__ ((noinline))
+test4 (struct B *q, int i)
+{
+ if (__builtin_object_size (&q->a[2].a[2], 1) != sizeof (q->a[0].a) - 2)
+ abort ();
+ if (__builtin_object_size (&q->a[2].c[2], 1) != sizeof (q->a[0].c) - 2)
+ abort ();
+ if (__builtin_object_size (&q->a[3].a[2], 1) != sizeof (q->a[0].a) - 2)
+ abort ();
+ if (__builtin_object_size (&q->a[3].c[2], 1) != sizeof (q->a[0].c) - 2)
+ abort ();
+ if (__builtin_object_size (&q->a[i].a[2], 1) != sizeof (q->a[0].a) - 2)
+ abort ();
+ if (__builtin_object_size (&q->a[i].c[2], 1) != sizeof (q->a[0].c) - 2)
+ abort ();
+}
+
+struct C
+{
+ char a[10];
+ char b;
+};
+
+void
+__attribute__ ((noinline))
+test5 (struct C *c)
+{
+ if (__builtin_object_size (&c->b, 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&c->b, 1) != 1)
+ abort ();
+ if (__builtin_object_size (&c->b, 2) != 0)
+ abort ();
+ if (__builtin_object_size (&c->b, 3) != 1)
+ abort ();
+}
+
+struct D
+{
+ int i;
+ struct D1
+ {
+ char b;
+ char a[10];
+ } j;
+};
+
+void
+__attribute__ ((noinline))
+test6 (struct D *d)
+{
+ if (__builtin_object_size (&d->j.a[3], 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&d->j.a[3], 1) != sizeof (d->j.a) - 3)
+ abort ();
+ if (__builtin_object_size (&d->j.a[3], 2) != 0)
+ abort ();
+ if (__builtin_object_size (&d->j.a[3], 3) != sizeof (d->j.a) - 3)
+ abort ();
+}
+
+struct E
+{
+ int i;
+ struct E1
+ {
+ char b;
+ char a[10];
+ } j[1];
+};
+
+void
+__attribute__ ((noinline))
+test7 (struct E *e)
+{
+ if (__builtin_object_size (&e->j[0].a[3], 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&e->j[0].a[3], 1) != sizeof (e->j[0].a) - 3)
+ abort ();
+ if (__builtin_object_size (&e->j[0].a[3], 2) != 0)
+ abort ();
+ if (__builtin_object_size (&e->j[0].a[3], 3) != sizeof (e->j[0].a) - 3)
+ abort ();
+ if (__builtin_object_size ((char *) &e->j[0], 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size ((char *) &e->j[0], 1) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size ((char *) &e->j[0], 2) != 0)
+ abort ();
+ if (__builtin_object_size ((char *) &e->j[0], 3) != 0)
+ abort ();
+}
+
+union F
+{
+ char a[1];
+ struct F1
+ {
+ char b;
+ char c[10];
+ } d;
+};
+
+void
+__attribute__ ((noinline))
+test8 (union F *f)
+{
+ if (__builtin_object_size (&f->d.c[3], 0) != (size_t) -1)
+ abort ();
+ if (__builtin_object_size (&f->d.c[3], 1) != sizeof (f->d.c) - 3)
+ abort ();
+ if (__builtin_object_size (&f->d.c[3], 2) != 0)
+ abort ();
+ if (__builtin_object_size (&f->d.c[3], 3) != sizeof (f->d.c) - 3)
+ abort ();
+}
+
+int
+main (void)
+{
+ struct A a, *p = &a;
+ int i = 1;
+ __asm ("" : "+r" (p));
+ test1 (p);
+ test2 ();
+ test3 ();
+ struct B b, *q = &b;
+ __asm ("" : "+r" (q), "+r" (i));
+ test4 (q, i);
+ struct C c, *cp = &c;
+ __asm ("" : "+r" (cp));
+ test5 (cp);
+ struct D d, *dp = &d;
+ __asm ("" : "+r" (dp));
+ test6 (dp);
+ struct E e, *ep = &e;
+ __asm ("" : "+r" (ep));
+ test7 (ep);
+ union F f, *fp = &f;
+ __asm ("" : "+r" (fp));
+ test8 (fp);
+ exit (0);
+}
--- gcc/tree-object-size.c (revision 148278)
+++ gcc/tree-object-size.c (revision 148279)
@@ -43,7 +43,8 @@ struct object_size_info
static unsigned HOST_WIDE_INT unknown[4] = { -1, -1, 0, 0 };
static tree compute_object_offset (const_tree, const_tree);
-static unsigned HOST_WIDE_INT addr_object_size (const_tree, int);
+static unsigned HOST_WIDE_INT addr_object_size (struct object_size_info *,
+ const_tree, int);
static unsigned HOST_WIDE_INT alloc_object_size (const_gimple, int);
static tree pass_through_call (const_gimple);
static void collect_object_sizes_for (struct object_size_info *, tree);
@@ -152,9 +153,10 @@ compute_object_offset (const_tree expr,
If unknown, return unknown[object_size_type]. */
static unsigned HOST_WIDE_INT
-addr_object_size (const_tree ptr, int object_size_type)
+addr_object_size (struct object_size_info *osi, const_tree ptr,
+ int object_size_type)
{
- tree pt_var;
+ tree pt_var, pt_var_size = NULL_TREE, var_size, bytes;
gcc_assert (TREE_CODE (ptr) == ADDR_EXPR);
@@ -163,58 +165,170 @@ addr_object_size (const_tree ptr, int ob
pt_var = get_base_address (pt_var);
if (pt_var
- && (SSA_VAR_P (pt_var) || TREE_CODE (pt_var) == STRING_CST)
- && TYPE_SIZE_UNIT (TREE_TYPE (pt_var))
- && host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)), 1)
- && (unsigned HOST_WIDE_INT)
- tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)), 1) < offset_limit)
+ && TREE_CODE (pt_var) == INDIRECT_REF
+ && TREE_CODE (TREE_OPERAND (pt_var, 0)) == SSA_NAME
+ && POINTER_TYPE_P (TREE_TYPE (TREE_OPERAND (pt_var, 0))))
+ {
+ unsigned HOST_WIDE_INT sz;
+
+ if (!osi)
+ sz = compute_builtin_object_size (TREE_OPERAND (pt_var, 0),
+ object_size_type);
+ else
+ {
+ tree var = TREE_OPERAND (pt_var, 0);
+ if (osi->pass == 0)
+ collect_object_sizes_for (osi, var);
+ if (bitmap_bit_p (computed[object_size_type],
+ SSA_NAME_VERSION (var)))
+ sz = object_sizes[object_size_type][SSA_NAME_VERSION (var)];
+ else
+ sz = unknown[object_size_type];
+ }
+
+ if (sz != unknown[object_size_type] && sz < offset_limit)
+ pt_var_size = size_int (sz);
+ }
+ else if (pt_var
+ && (SSA_VAR_P (pt_var) || TREE_CODE (pt_var) == STRING_CST)
+ && TYPE_SIZE_UNIT (TREE_TYPE (pt_var))
+ && host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)), 1)
+ && (unsigned HOST_WIDE_INT)
+ tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)), 1)
+ < offset_limit)
+ pt_var_size = TYPE_SIZE_UNIT (TREE_TYPE (pt_var));
+ else
+ return unknown[object_size_type];
+
+ if (pt_var != TREE_OPERAND (ptr, 0))
{
- tree bytes;
+ tree var;
- if (pt_var != TREE_OPERAND (ptr, 0))
+ if (object_size_type & 1)
{
- tree var;
+ var = TREE_OPERAND (ptr, 0);
- if (object_size_type & 1)
+ while (var != pt_var
+ && TREE_CODE (var) != BIT_FIELD_REF
+ && TREE_CODE (var) != COMPONENT_REF
+ && TREE_CODE (var) != ARRAY_REF
+ && TREE_CODE (var) != ARRAY_RANGE_REF
+ && TREE_CODE (var) != REALPART_EXPR
+ && TREE_CODE (var) != IMAGPART_EXPR)
+ var = TREE_OPERAND (var, 0);
+ if (var != pt_var && TREE_CODE (var) == ARRAY_REF)
+ var = TREE_OPERAND (var, 0);
+ if (! TYPE_SIZE_UNIT (TREE_TYPE (var))
+ || ! host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (var)), 1)
+ || (pt_var_size
+ && tree_int_cst_lt (pt_var_size,
+ TYPE_SIZE_UNIT (TREE_TYPE (var)))))
+ var = pt_var;
+ else if (var != pt_var && TREE_CODE (pt_var) == INDIRECT_REF)
{
- var = TREE_OPERAND (ptr, 0);
-
- while (var != pt_var
- && TREE_CODE (var) != BIT_FIELD_REF
- && TREE_CODE (var) != COMPONENT_REF
- && TREE_CODE (var) != ARRAY_REF
- && TREE_CODE (var) != ARRAY_RANGE_REF
- && TREE_CODE (var) != REALPART_EXPR
- && TREE_CODE (var) != IMAGPART_EXPR)
- var = TREE_OPERAND (var, 0);
- if (var != pt_var && TREE_CODE (var) == ARRAY_REF)
- var = TREE_OPERAND (var, 0);
- if (! TYPE_SIZE_UNIT (TREE_TYPE (var))
- || ! host_integerp (TYPE_SIZE_UNIT (TREE_TYPE (var)), 1)
- || tree_int_cst_lt (TYPE_SIZE_UNIT (TREE_TYPE (pt_var)),
- TYPE_SIZE_UNIT (TREE_TYPE (var))))
+ tree v = var;
+ /* For &X->fld, compute object size only if fld isn't the last
+ field, as struct { int i; char c[1]; } is often used instead
+ of flexible array member. */
+ while (v && v != pt_var)
+ switch (TREE_CODE (v))
+ {
+ case ARRAY_REF:
+ if (TYPE_SIZE_UNIT (TREE_TYPE (TREE_OPERAND (v, 0)))
+ && TREE_CODE (TREE_OPERAND (v, 1)) == INTEGER_CST)
+ {
+ tree domain
+ = TYPE_DOMAIN (TREE_TYPE (TREE_OPERAND (v, 0)));
+ if (domain
+ && TYPE_MAX_VALUE (domain)
+ && TREE_CODE (TYPE_MAX_VALUE (domain))
+ == INTEGER_CST
+ && tree_int_cst_lt (TREE_OPERAND (v, 1),
+ TYPE_MAX_VALUE (domain)))
+ {
+ v = NULL_TREE;
+ break;
+ }
+ }
+ v = TREE_OPERAND (v, 0);
+ break;
+ case REALPART_EXPR:
+ case IMAGPART_EXPR:
+ v = NULL_TREE;
+ break;
+ case COMPONENT_REF:
+ if ((TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0)))
+ == RECORD_TYPE
+ && TREE_CHAIN (TREE_OPERAND (v, 1)))
+ || TREE_CODE (TREE_TYPE (v)) != ARRAY_TYPE)
+ v = NULL_TREE;
+ else
+ {
+ if (TREE_CODE (TREE_TYPE (TREE_OPERAND (v, 0)))
+ == RECORD_TYPE)
+ v = TREE_OPERAND (v, 0);
+ while (v && v != pt_var && TREE_CODE (v) == COMPONENT_REF)
+ if (TREE_CODE (TREE_TYPE (v)) != UNION_TYPE
+ && TREE_CODE (TREE_TYPE (v)) != QUAL_UNION_TYPE)
+ break;
+ else
+ v = TREE_OPERAND (v, 0);
+ if (v && v != pt_var)
+ v = NULL_TREE;
+ else
+ v = pt_var;
+ }
+ break;
+ default:
+ v = pt_var;
+ break;
+ }
+ if (v == pt_var)
var = pt_var;
}
- else
- var = pt_var;
+ }
+ else
+ var = pt_var;
- bytes = compute_object_offset (TREE_OPERAND (ptr, 0), var);
- if (bytes != error_mark_node)
+ if (var != pt_var)
+ var_size = TYPE_SIZE_UNIT (TREE_TYPE (var));
+ else if (!pt_var_size)
+ return unknown[object_size_type];
+ else
+ var_size = pt_var_size;
+ bytes = compute_object_offset (TREE_OPERAND (ptr, 0), var);
+ if (bytes != error_mark_node)
+ {
+ if (TREE_CODE (bytes) == INTEGER_CST
+ && tree_int_cst_lt (var_size, bytes))
+ bytes = size_zero_node;
+ else
+ bytes = size_binop (MINUS_EXPR, var_size, bytes);
+ }
+ if (var != pt_var
+ && pt_var_size
+ && TREE_CODE (pt_var) == INDIRECT_REF
+ && bytes != error_mark_node)
+ {
+ tree bytes2 = compute_object_offset (TREE_OPERAND (ptr, 0), pt_var);
+ if (bytes2 != error_mark_node)
{
- if (TREE_CODE (bytes) == INTEGER_CST
- && tree_int_cst_lt (TYPE_SIZE_UNIT (TREE_TYPE (var)), bytes))
- bytes = size_zero_node;
+ if (TREE_CODE (bytes2) == INTEGER_CST
+ && tree_int_cst_lt (pt_var_size, bytes2))
+ bytes2 = size_zero_node;
else
- bytes = size_binop (MINUS_EXPR,
- TYPE_SIZE_UNIT (TREE_TYPE (var)), bytes);
+ bytes2 = size_binop (MINUS_EXPR, var_size, bytes2);
+ bytes = size_binop (MIN_EXPR, bytes, bytes2);
}
}
- else
- bytes = TYPE_SIZE_UNIT (TREE_TYPE (pt_var));
-
- if (host_integerp (bytes, 1))
- return tree_low_cst (bytes, 1);
}
+ else if (!pt_var_size)
+ return unknown[object_size_type];
+ else
+ bytes = pt_var_size;
+
+ if (host_integerp (bytes, 1))
+ return tree_low_cst (bytes, 1);
return unknown[object_size_type];
}
@@ -332,11 +446,11 @@ compute_builtin_object_size (tree ptr, i
init_offset_limit ();
if (TREE_CODE (ptr) == ADDR_EXPR)
- return addr_object_size (ptr, object_size_type);
+ return addr_object_size (NULL, ptr, object_size_type);
if (TREE_CODE (ptr) == SSA_NAME
- && POINTER_TYPE_P (TREE_TYPE (ptr))
- && object_sizes[object_size_type] != NULL)
+ && POINTER_TYPE_P (TREE_TYPE (ptr))
+ && object_sizes[object_size_type] != NULL)
{
if (!bitmap_bit_p (computed[object_size_type], SSA_NAME_VERSION (ptr)))
{
@@ -477,7 +591,7 @@ expr_object_size (struct object_size_inf
|| !POINTER_TYPE_P (TREE_TYPE (value)));
if (TREE_CODE (value) == ADDR_EXPR)
- bytes = addr_object_size (value, object_size_type);
+ bytes = addr_object_size (osi, value, object_size_type);
else
bytes = unknown[object_size_type];
@@ -633,7 +747,7 @@ plus_stmt_object_size (struct object_siz
unsigned HOST_WIDE_INT off = tree_low_cst (op1, 1);
/* op0 will be ADDR_EXPR here. */
- bytes = compute_builtin_object_size (op0, object_size_type);
+ bytes = addr_object_size (osi, op0, object_size_type);
if (bytes == unknown[object_size_type])
;
else if (off > offset_limit)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
2659f09c2e43ef8b7d4406321753f1b2 fastjar-0.97.tar.gz 2659f09c2e43ef8b7d4406321753f1b2 fastjar-0.97.tar.gz
aa85080477b7f1f5b6c526d2ad48bbf7 gcc-4.4.0-20090609.tar.bz2 9b6443f7aa04f21c690998cce516b648 gcc-4.4.0-20090612.tar.bz2