From b5411fea202bb08dc6a9bb3204e52b96af0733a5 Mon Sep 17 00:00:00 2001 From: James E Wilson Date: Thu, 15 Jul 2004 00:35:28 +0000 Subject: [PATCH] Fix MIPS SPEC95 FP 146.wave5 -fprofile-generate failure. PR target/16325 * config/mips/mips.h (STARTING_FRAME_OFFSET): When flag_profile_value and ! TARGET_64BIT, include REG_PARM_STACK_SPACE. * gcc.dg/profile-generate-1.c: New. From-SVN: r84727 --- gcc/ChangeLog | 6 +++++ gcc/config/mips/mips.h | 16 +++++++++-- gcc/testsuite/ChangeLog | 5 ++++ gcc/testsuite/gcc.dg/profile-generate-1.c | 33 +++++++++++++++++++++++ 4 files changed, 58 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/profile-generate-1.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 675e22b5a6b..e9f8b71bc62 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2004-07-14 James E Wilson + + PR target/16325 + * config/mips/mips.h (STARTING_FRAME_OFFSET): When flag_profile_value + and ! TARGET_64BIT, include REG_PARM_STACK_SPACE. + 2004-07-15 Jakub Jelinek * expr.c (expand_assignment): Reenable bitfield += optimizations. diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h index a4c7be938f1..c3c58278153 100644 --- a/gcc/config/mips/mips.h +++ b/gcc/config/mips/mips.h @@ -2132,9 +2132,21 @@ extern enum reg_class mips_char_to_class[256]; #define STACK_GROWS_DOWNWARD /* The offset of the first local variable from the beginning of the frame. - See compute_frame_size for details about the frame layout. */ + See compute_frame_size for details about the frame layout. + + ??? If flag_profile_values is true, and we are generating 32-bit code, then + we assume that we will need 16 bytes of argument space. This is because + the value profiling code may emit calls to cmpdi2 in leaf functions. + Without this hack, the local variables will start at sp+8 and the gp save + area will be at sp+16, and thus they will overlap. compute_frame_size is + OK because it uses STARTING_FRAME_OFFSET to compute cprestore_size, which + will end up as 24 instead of 8. This won't be needed if profiling code is + inserted before virtual register instantiation. */ + #define STARTING_FRAME_OFFSET \ - (current_function_outgoing_args_size \ + ((flag_profile_values && ! TARGET_64BIT \ + ? MAX (REG_PARM_STACK_SPACE(NULL), current_function_outgoing_args_size) \ + : current_function_outgoing_args_size) \ + (TARGET_ABICALLS && !TARGET_NEWABI \ ? MIPS_STACK_ALIGN (UNITS_PER_WORD) : 0)) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index caec9d27bf0..b98486d19ae 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2004-07-14 James E Wilson + + PR target/16325 + * gcc.dg/profile-generate-1.c: New. + 2004-07-15 Jakub Jelinek * gcc.c-torture/execute/20040709-1.c: New test. diff --git a/gcc/testsuite/gcc.dg/profile-generate-1.c b/gcc/testsuite/gcc.dg/profile-generate-1.c new file mode 100644 index 00000000000..64ebb0e3a5e --- /dev/null +++ b/gcc/testsuite/gcc.dg/profile-generate-1.c @@ -0,0 +1,33 @@ +/* Bug 16325. */ +/* { dg-options "-O -fprofile-generate" } */ + +int *p1; +int *p2; +int *p3; + +int ga = 100; + +int +sub (int i, int j) +{ + int k; + int l; + int m; + int n; + p1 = &k; + p2 = &l; + p3 = &m; + k = 20; + l = 30; + m = 40; + n = i / j; + return n + ga; +} + +int +main(void) +{ + if (sub (99, 33) != 103) + abort (); + return 0; +} -- 2.30.2