Bug 32522 - [4.3 Regression] Bootstrap failure on Alpha due to pointer-plus changes
Summary: [4.3 Regression] Bootstrap failure on Alpha due to pointer-plus changes
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.3.0
: P1 normal
Target Milestone: 4.3.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: build, ice-on-valid-code, patch, wrong-code
: 32744 32930 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-06-27 15:46 UTC by Falk Hueffner
Modified: 2007-08-20 06:53 UTC (History)
6 users (show)

See Also:
Host: alphaev68-unknown-linux-gnu
Target: alphaev68-unknown-linux-gnu
Build: alphaev68-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2007-07-05 18:48:49


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Falk Hueffner 2007-06-27 15:46:12 UTC
src/gcc-2007.06.27/build/./gcc/xgcc -B/src/gcc-2007.06.27/build/./gcc/
-B/usr/local/alphaev68-unknown-linux-gnu/bin/
-B/usr/local/alphaev68-unknown-linux-gnu/lib/ -isystem
/usr/local/alphaev68-unknown-linux-gnu/include -isystem
/usr/local/alphaev68-unknown-linux-gnu/sys-include -g -fkeep-inline-functions
-O2  -O2 -g -O2  -mieee -DIN_GCC    -W -Wall -Wwrite-strings
-Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem
./include  -fPIC -mieee -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2
-D__GCC_FLOAT_NOT_NEEDED   -I. -I. -I../.././gcc -I../../../libgcc
-I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include  -o
_gcov_execl.o -MT _gcov_execl.o -MD -MP -MF _gcov_execl.dep -DL_gcov_execl -c
../../../libgcc/../gcc/libgcov.c
../../../libgcc/../gcc/libgcov.c: In function '__gcov_execl':
../../../libgcc/../gcc/libgcov.c:838: internal compiler error: in build2_stat,
at tree.c:3074
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[3]: *** [_gcov_execl.o] Error 1
make[3]: Leaving directory
`/src/gcc-2007.06.27/build/alphaev68-unknown-linux-gnu/libgcc'

This happens as soon as varargs are used:

$ cat test.c                                                                   
void f(int x, ...) {
    __builtin_va_list ap;
    __builtin_va_start(ap, x);
}
$ /src/gcc-2007.06.27/build/gcc/xgcc -B/src/gcc-2007.06.27/build/gcc/ -c test.c
test.c: In function 'f':
test.c:3: internal compiler error: in build2_stat, at tree.c:3074
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

Apparently, the Alpha backend needs to adapt to the pointer-plus changes.
Comment 1 Andrew Pinski 2007-06-27 22:57:11 UTC
I already gave Falk a patch to try.
Comment 2 Falk Hueffner 2007-07-05 13:01:26 UTC
I tried this patch from Andrew Pinski:

Index: gcc/config/alpha/alpha.c
===================================================================
--- gcc/config/alpha/alpha.c    (revision 126053)
+++ gcc/config/alpha/alpha.c    (working copy)
@@ -6111,8 +6111,8 @@
                             valist, offset_field, NULL_TREE);
 
       t = make_tree (ptr_type_node, virtual_incoming_args_rtx);
-      t = build2 (PLUS_EXPR, ptr_type_node, t,
-                 build_int_cst (NULL_TREE, offset));
+      t = build2 (POINTER_PLUS_EXPR, ptr_type_node, t,
+                 size_int (offset));
       t = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (base_field), base_field, t);
       TREE_SIDE_EFFECTS (t) = 1;
       expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
@@ -6172,8 +6173,8 @@
     }
 
   /* Build the final address and force that value into a temporary.  */
-  addr = build2 (PLUS_EXPR, ptr_type, fold_convert (ptr_type, base),
-                fold_convert (ptr_type, addend));
+  addr = build2 (POINTER_PLUS_EXPR, ptr_type, fold_convert (ptr_type, base),
+                fold_convert (sizetype, addend));
   internal_post = NULL;
   gimplify_expr (&addr, pre_p, &internal_post, is_gimple_val, fb_rvalue);
   append_to_statement_list (internal_post, pre_p);

which allows bootstrap to continue, but it still fails:

checking for alphaev68-unknown-linux-gnu-gcc... /src/gcc-2007.07.05/build/./gcc/xgcc -B/src/gcc-2007.07.05/build/./gcc/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -B/usr/local/alphaev68-unknown-linux-gnu/lib/ -isystem /usr/local/alphaev68-unknown-linux-gnu/include -isystem /usr/local/alphaev68-unknown-linux-gnu/sys-include
checking for suffix of object files... configure: error: cannot compute suffix of object files: cannot compile
See `config.log' for more details.
make[2]: *** [configure-stage2-target-libgcc] Error 1
make[2]: Leaving directory `/src/gcc-2007.07.05/build'
make[1]: *** [stage2-bubble] Error 2
make[1]: Leaving directory `/src/gcc-2007.07.05/build'
make: *** [all] Error 2

libgcc/config.log says:

configure:2566: checking for suffix of object files
configure:2587: /src/gcc-2007.07.05/build/./gcc/xgcc -B/src/gcc-2007.07.05/build/./gcc/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -B/usr/loc
al/alphaev68-unknown-linux-gnu/lib/ -isystem /usr/local/alphaev68-unknown-linux-gnu/include -isystem /usr/local/alphaev68-unknown-linux-gnu/sys-
include -c -g -O2  conftest.c >&5
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)
<built-in>:0: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
configure:2590: $? = 1
configure: failed program was:
| /* confdefs.h.  */
| 
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
| 
| int
| main ()
| {
| 
|   ;
|   return 0;
| }
configure:2604: error: cannot compute suffix of object files: cannot compile
Comment 3 Andrew Pinski 2007-07-05 18:48:49 UTC
><built-in>:0: error: nonnull argument references non-pointer operand (argument 1, operand 1)

That means we are miscompiling some part of cc1 somewhere.  Which I doubt is a pointer plus issue because I have gotten no bug reports of wrong code yet.  It might be a df issue.  Can roll back, right before pointer plus and try bootstrapping there?
Comment 4 Andrew Pinski 2007-07-12 21:01:32 UTC
*** Bug 32744 has been marked as a duplicate of this bug. ***
Comment 5 Rainer Orth 2007-07-16 16:41:29 UTC
I've just tried bootstrapping alpha-dec-osf5.1b (C only): all is fine before the 
ptrplus patch (r125754), but after the patch (r125755) building libgcc fails in
stage 1.  With Andrew's patch, I get into stage 2, but building the stage 2
libgcc fails again as Falk described.

  Rainer
Comment 6 Serge Belyshev 2007-07-16 17:30:43 UTC
(In reply to comment #5)

You need the following patch to fix this bug (but bootstrap on alpha is still broken for other reasons, see bug 32747):

---
 gcc/config/alpha/alpha.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Index: gcc43/gcc/config/alpha/alpha.c
===================================================================
--- gcc43.orig/gcc/config/alpha/alpha.c
+++ gcc43/gcc/config/alpha/alpha.c
@@ -5835,7 +5835,8 @@ va_list_skip_additions (tree lhs)
 
       if ((TREE_CODE (rhs) != NOP_EXPR
 	   && TREE_CODE (rhs) != CONVERT_EXPR
-	   && (TREE_CODE (rhs) != PLUS_EXPR
+	   && ((TREE_CODE (rhs) != PLUS_EXPR
+		&& TREE_CODE (rhs) != POINTER_PLUS_EXPR)
 	       || TREE_CODE (TREE_OPERAND (rhs, 1)) != INTEGER_CST
 	       || !host_integerp (TREE_OPERAND (rhs, 1), 1)))
 	  || TREE_CODE (TREE_OPERAND (rhs, 0)) != SSA_NAME)
@@ -5877,7 +5878,7 @@ alpha_stdarg_optimize_hook (struct stdar
 
   lhs = va_list_skip_additions (TREE_OPERAND (rhs, 0));
   if (lhs == NULL_TREE
-      || TREE_CODE (lhs) != PLUS_EXPR)
+      || TREE_CODE (lhs) != POINTER_PLUS_EXPR)
     return false;
 
   base = TREE_OPERAND (lhs, 0);
@@ -6111,8 +6112,8 @@ alpha_va_start (tree valist, rtx nextarg
 			     valist, offset_field, NULL_TREE);
 
       t = make_tree (ptr_type_node, virtual_incoming_args_rtx);
-      t = build2 (PLUS_EXPR, ptr_type_node, t,
-		  build_int_cst (NULL_TREE, offset));
+      t = build2 (POINTER_PLUS_EXPR, ptr_type_node, t,
+		  size_int (offset));
       t = build2 (GIMPLE_MODIFY_STMT, TREE_TYPE (base_field), base_field, t);
       TREE_SIDE_EFFECTS (t) = 1;
       expand_expr (t, const0_rtx, VOIDmode, EXPAND_NORMAL);
@@ -6172,8 +6173,8 @@ alpha_gimplify_va_arg_1 (tree type, tree
     }
 
   /* Build the final address and force that value into a temporary.  */
-  addr = build2 (PLUS_EXPR, ptr_type, fold_convert (ptr_type, base),
-	         fold_convert (ptr_type, addend));
+  addr = build2 (POINTER_PLUS_EXPR, ptr_type, fold_convert (ptr_type, base),
+	         fold_convert (sizetype, addend));
   internal_post = NULL;
   gimplify_expr (&addr, pre_p, &internal_post, is_gimple_val, fb_rvalue);
   append_to_statement_list (internal_post, pre_p);
Comment 7 Rainer Orth 2007-07-17 11:28:05 UTC
Subject: Re:  [4.3 Regression] Bootstrap failure on Alpha due to pointer-plus changes

belyshev at depni dot sinp dot msu dot ru writes:

> You need the following patch to fix this bug (but bootstrap on alpha is still
> broken for other reasons, see bug 32747):

Thanks.  A C-only bootstrap (alpha-dec-osf5.1b and alpha-dec-osf4.0f)
completes with this patch, but if I build with all languages, cc1 segfaults
in malloc building the stage 2 libdecnumber:

$ source='/vol/gcc/src/gcc-dist/libdecnumber/decNumber.c' object='decNumber.o' libtool=no /vol/gccsrc/obj/gcc-4.3.0-20070712/4.0f-gcc/./prev-gcc/xgcc -B/vol/gccsrc/obj/gcc-4.3.0-20070712/4.0f-gcc/./prev-gcc/ -B/vol/gcc/alpha-dec-osf4.0f/bin/  -I/vol/gcc/src/gcc-dist/libdecnumber -I.  -g -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wmissing-format-attribute -Wcast-qual -pedantic -Wno-long-long -Werror -I/vol/gcc/src/gcc-dist/libdecnumber -I.  -c /vol/gcc/src/gcc-dist/libdecnumber/decNumber.c      
/vol/gcc/src/gcc-dist/libdecnumber/decNumber.c: In function 'decNumberPower':
/vol/gcc/src/gcc-dist/libdecnumber/decNumber.c:1242: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.

I cannot get a proper stack trace, though.  The file compiles at -O.

	Rainer
Comment 8 Serge Belyshev 2007-07-26 19:48:55 UTC
Bug 32747 fixed, so I successfully bootstrapped r126943 (all languages minus java) with patch from comment #6 on alphaev56-unknown-linux-gnu.
Comment 9 Falk Hueffner 2007-07-26 22:49:52 UTC
(In reply to comment #8)
> Bug 32747 fixed, so I successfully bootstrapped r126943 (all languages minus
> java) with patch from comment #6 on alphaev56-unknown-linux-gnu.
> 

So, are you going to post the patch to gcc-patches?
Comment 10 Serge Belyshev 2007-07-27 06:18:39 UTC
(In reply to comment #9)
Patch posted.

Comment 11 patchapp@dberlin.org 2007-07-27 06:22:08 UTC
Subject: Bug number PR32522

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-07/msg01962.html
Comment 12 Andrew Pinski 2007-07-29 02:00:03 UTC
*** Bug 32930 has been marked as a duplicate of this bug. ***
Comment 13 Andrew Pinski 2007-08-20 06:53:16 UTC
Fixed.
Comment 14 Andrew Pinski 2007-08-20 06:53:18 UTC
Subject: Bug 32522

Author: pinskia
Date: Mon Aug 20 06:53:05 2007
New Revision: 127637

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127637
Log:
2007-08-19  Andrew Pinski  <andrew_pinski@playstation.sony.com>
           Serge Belyshev  <belyshev@depni.sinp.msu.ru>

        PR target/32522
        * config/alpha/alpha.c (va_list_skip_additions): Check for
        POINTER_PLUS_EXPR in addition to PLUS_EXPR.
        (alpha_stdarg_optimize_hook): Look for POINTER_PLUS_EXPR instead of
        PLUS_EXPR when checking ap.__base.
        (alpha_va_start): Create POINTER_PLUS_EXPR instead of PLUS_EXPR
        when doing addition on pointer types.  Use size_int instead of
        build_int_cst.
        (alpha_gimplify_va_arg_1): Likewise, but use sizetype instead of
        ptr_type in the second operand.



Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/alpha/alpha.c