From patchwork Fri Aug 23 18:12:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 1152328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-507628-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=adacore.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="Ws+R64zJ"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46FTzH4cM6z9s00 for ; Sat, 24 Aug 2019 04:13:13 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=TyFKLLqfw2ke8EKb jQ6D5D2GuDyIeYphBGfyNLbUWPp0mnk3WxpPblykFOv/nsg+pOKwql2AlbwvUw7v em+L4OH80mV78DLtSijFqYnl1f9p4jzv809vOe2AzxshjCJ+QGTvq9RCeoXhOxzm L5JnpjyHs4+iAW9ROg5Ee15ZOSc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=S0hJMElL/Z0sVXN6KaHqia ODmvg=; b=Ws+R64zJ0OUbBuAQeQSKZ4g90xjZAhsTialKf05pqz3ZkbDS68c8yk hwp2kufm1X+Py8VaKOzyVYErXLAXojEPbnJWHUpEnpvCRJvXY4WRmpVzC4aWACWb J30C3pSAK6DoNgFxzvNrGE6H1LRO9uG3R/esd/OQHiriCMhnaqEQ4= Received: (qmail 104100 invoked by alias); 23 Aug 2019 18:13:06 -0000 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 Received: (qmail 104073 invoked by uid 89); 23 Aug 2019 18:13:05 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy=hay, pero, perder, que X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 23 Aug 2019 18:13:03 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 6A24C1165CD; Fri, 23 Aug 2019 14:13:02 -0400 (EDT) X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "Cc" Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id TAkzQWt90CuJ; Fri, 23 Aug 2019 14:13:02 -0400 (EDT) Received: from free.home (tron.gnat.com [IPv6:2620:20:4000:0:46a8:42ff:fe0e:e294]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by rock.gnat.com (Postfix) with ESMTPS id C4C2E11655C; Fri, 23 Aug 2019 14:13:01 -0400 (EDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id x7NICmjI319633 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 23 Aug 2019 15:12:48 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Rainer Orth , Mike Stump Cc: Jan Hubicka , Uros Bizjak Subject: [x86 testsuite] preserve full register across main Date: Fri, 23 Aug 2019 15:12:48 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) MIME-Version: 1.0 This test uses a call-saved register as a global variable. It attempts to preserve its value across main, but only the lower int part is preserved, which is not good enough for x86_64, when the runtime that calls main() happens to hold something in the chosen register that is not a zero-extension from the 32-bit value, and rightfully expects the full register to remain unchanged when main() returns. Tested on x86_64-linux-gnu, both -m64 and -m32. Ok to install? for gcc/testsuite/ChangeLog * gcc.target/i386/20020616-1.c: Preserve full register across main. --- gcc/testsuite/gcc.target/i386/20020616-1.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/gcc/testsuite/gcc.target/i386/20020616-1.c b/gcc/testsuite/gcc.target/i386/20020616-1.c index 5641826b4837..3b8cf8e41783 100644 --- a/gcc/testsuite/gcc.target/i386/20020616-1.c +++ b/gcc/testsuite/gcc.target/i386/20020616-1.c @@ -2,12 +2,16 @@ /* { dg-do run } */ /* { dg-options "-O2" } */ +/* We need this type to be as wide as the register chosen below, so + that, when we preserve it across main, we preserve all of it. */ +typedef long reg_type; + #if !__PIC__ -register int k asm("%ebx"); +register reg_type k asm("%ebx"); #elif __amd64 -register int k asm("%r12"); +register reg_type k asm("%r12"); #else -register int k asm("%esi"); +register reg_type k asm("%esi"); #endif void __attribute__((noinline)) @@ -18,7 +22,7 @@ foo() void test() { - int i; + reg_type i; for (i = 0; i < 10; i += k) { k = 0; @@ -28,7 +32,7 @@ void test() int main() { - int old = k; + reg_type old = k; test(); k = old; return 0;