From patchwork Tue Jul 12 04:18:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: matthew green X-Patchwork-Id: 104313 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id C2037B6F77 for ; Tue, 12 Jul 2011 14:18:51 +1000 (EST) Received: (qmail 21755 invoked by alias); 12 Jul 2011 04:18:47 -0000 Received: (qmail 21746 invoked by uid 22791); 12 Jul 2011 04:18:45 -0000 X-SWARE-Spam-Status: No, hits=-1.1 required=5.0 tests=BAYES_00,RDNS_NONE X-Spam-Check-By: sourceware.org Received: from Unknown (HELO splode.eterna.com.au) (203.15.111.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 12 Jul 2011 04:18:27 +0000 Received: from splode.eterna.com.au (localhost [127.0.0.1]) by splode.eterna.com.au (Postfix) with ESMTP id DDC0C3752C; Tue, 12 Jul 2011 14:18:17 +1000 (EST) to: "Joseph S. Myers" , gcc-patches@gcc.gnu.org organisation: people's front against (bozotic) www (softwar foundation) x-other-organisation: The NetBSD Foundation. x-message: step back from the shadows of war! seek out the ways of peace subject: re: Fix argument pushes to unaligned stack slots Date: Tue, 12 Jul 2011 14:18:17 +1000 Message-ID: <397.1310444297@splode.eterna.com.au> From: matthew green Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org hi folks. i'm having a problem with GCC 4.5.3 on netbsd-m68k target. i've tracked it down to this change from several years ago: > 2007-02-06 Joseph Myers > > * expr.c (emit_push_insn): If STRICT_ALIGNMENT, copy to an > unaligned stack slot via a suitably aligned slot. the problem is that emit_library_call_value_1() calls emit_push_insn() with TYPE_NULL which ends up triggering a NULL deref when emit_push_insn() calls assign_temp() with type = TYPE_NULL, and assign_temp() crashes. this simple change seems to be sufficient to avoid the crash and the generated code appears to run OK. if it is OK, could someone please commit it? thanks. (feel free to update my log message if it could be clearer or more correct.) .mrg. 2011-07-10 matthew green * expr.c (emit_push_insn): Don't copy a TYPE_NULL expression to the stack for correct alignment. Index: external/gpl3/gcc/dist/gcc/expr.c =================================================================== RCS file: /cvsroot/src/external/gpl3/gcc/dist/gcc/expr.c,v retrieving revision 1.1.1.1 diff -p -u -r1.1.1.1 expr.c --- external/gpl3/gcc/dist/gcc/expr.c 21 Jun 2011 01:20:17 -0000 1.1.1.1 +++ external/gpl3/gcc/dist/gcc/expr.c 12 Jul 2011 04:17:00 -0000 @@ -3764,7 +3764,8 @@ emit_push_insn (rtx x, enum machine_mode xinner = x; if (mode == BLKmode - || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode))) + || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode) + && type != NULL_TREE)) { /* Copy a block into the stack, entirely or partially. */