From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1771 invoked by alias); 13 Jul 2015 17:03:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 1760 invoked by uid 89); 13 Jul 2015 17:03:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-oi0-f45.google.com Received: from mail-oi0-f45.google.com (HELO mail-oi0-f45.google.com) (209.85.218.45) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Mon, 13 Jul 2015 17:03:31 +0000 Received: by oihq81 with SMTP id q81so44697899oih.2 for ; Mon, 13 Jul 2015 10:03:29 -0700 (PDT) MIME-Version: 1.0 X-Received: by 10.60.92.198 with SMTP id co6mr31059996oeb.3.1436807009387; Mon, 13 Jul 2015 10:03:29 -0700 (PDT) Received: by 10.60.231.195 with HTTP; Mon, 13 Jul 2015 10:03:29 -0700 (PDT) Date: Mon, 13 Jul 2015 17:03:00 -0000 Message-ID: Subject: [PATCH 1/2, rtl-optimization]: Fix PR 58066, __tls_get_addr is called with misaligned stack on x86-64 From: Uros Bizjak To: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 X-SW-Source: 2015-07/txt/msg01069.txt.bz2 This is rtl-optimization part of a two-part patch series. As discussed in the PR, we have to prcompute register parameters before stack alignment is performed, otherwise eventual call to __tls_get_addr can be called with unaligned stack. When compiling the testcase from the PR, anti_adjust_stack is called just before precompute starts expanding function parameters. The solution is to move precomputation before stack pointer is adjusted. 2015-07-13 Uros Bizjak PR rtl-optimization/58066 * calls.c (expand_call): Precompute register parameters before stack alignment is performed. Patch was bootstrapped and regression tested on x86_64-linux-gnu {,-m32} for all default languages, obj-c++ and go. OK for mainline? Uros. Index: calls.c =================================================================== --- calls.c (revision 225727) +++ calls.c (working copy) @@ -3144,6 +3144,10 @@ expand_call (tree exp, rtx target, int ignore) compute_argument_addresses (args, argblock, num_actuals); + /* Precompute all register parameters. It isn't safe to compute anything + once we have started filling any specific hard regs. */ + precompute_register_parameters (num_actuals, args, ®_parm_seen); + /* Perform stack alignment before the first push (the last arg). */ if (argblock == 0 && adjusted_args_size.constant > reg_parm_stack_space @@ -3184,10 +3188,6 @@ expand_call (tree exp, rtx target, int ignore) funexp = rtx_for_function_call (fndecl, addr); - /* Precompute all register parameters. It isn't safe to compute anything - once we have started filling any specific hard regs. */ - precompute_register_parameters (num_actuals, args, ®_parm_seen); - if (CALL_EXPR_STATIC_CHAIN (exp)) static_chain_value = expand_normal (CALL_EXPR_STATIC_CHAIN (exp)); else