From patchwork Wed Sep 6 16:37:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 810725 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-461632-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="FRLOBWTz"; 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 3xnTlM3pQTz9s9Y for ; Thu, 7 Sep 2017 02:37:34 +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:subject:date:message-id:content-type :content-transfer-encoding:mime-version; q=dns; s=default; b=O4O psIf8s6026tlp54tm7s6HSHzWzt2/a99lG6l8SeKYM4HPUF8nWiUPgdU8eUeNljK 1j4FHJnqnERiYeQfdi+Mmbgrpf1DvxF9FRn7o0QdySrvPf5YvV00VE2XZ9SLDBst V5KEH2hgfmkopQXBgmXXgDJNHmTeWOb5Pty7TLMQ= 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:subject:date:message-id:content-type :content-transfer-encoding:mime-version; s=default; bh=mmTxRIUlG erWtoPvMVji+8kpn+A=; b=FRLOBWTzd7e8B3Isuoe3LBfBKKeUCp+oBcHfCXSRG 34YGy+w/DSHmBDySewVpMXdkCl9jMqO/BhJKZrcbxBUFj0F/Utd8pAQq2ANuGD/L 3gW8fIZDe4tu55lbz4ZHZhn2X41c5rBWJPn+ucjc+mVb5qtmosFzMGdnkZPyn5dI Tw= Received: (qmail 33409 invoked by alias); 6 Sep 2017 16:37:25 -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 33395 invoked by uid 89); 6 Sep 2017 16:37:25 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: EUR01-VE1-obe.outbound.protection.outlook.com Received: from mail-ve1eur01on0081.outbound.protection.outlook.com (HELO EUR01-VE1-obe.outbound.protection.outlook.com) (104.47.1.81) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 06 Sep 2017 16:37:19 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com (10.168.86.22) by DB6SPR00MB11.eurprd08.prod.outlook.com (10.169.210.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.35.12; Wed, 6 Sep 2017 16:37:15 +0000 Received: from DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a]) by DB6PR0801MB2053.eurprd08.prod.outlook.com ([fe80::2d78:6ac0:142:cc9a%18]) with mapi id 15.20.0013.018; Wed, 6 Sep 2017 16:37:15 +0000 From: Wilco Dijkstra To: GCC Patches CC: nd Subject: [committed][Testsuite] PR78468 - add alloca alignment test Date: Wed, 6 Sep 2017 16:37:15 +0000 Message-ID: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Wilco.Dijkstra@arm.com; x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; DB6SPR00MB11; 6:XytoUy8RS4rvxx9fjE9teBpIWYvpfj0Zay+/oShL4HUzY+n6VIzkw1roeLlmP1mzNzPKV890ttw4ZSwqaR509aOUmNTT4G/XAlvcCM2k3xYUdTH6wgIuzlNtPY/+vNtt+trsNpAOy41mde3iNkNI6PJocQ8Cox8SR25JIZ8xe4dVXl8wgUwMmg82JIV6heYmTvnDH98KsybDvrBdAvs7XljhgcTMP8DgeDe4wVAjEXjSRbUw4ZxWVciV8jexpxC1p8MYP6GnvtgAK8AYAzgw5joQd4McxmUf9jIjAUvRjFk9JjfjgcZ9BF6+Di6GJJoQ06slkTrcMqIxQ5XEP2ZK2Q==; 5:PD/oS2YZFyulQHq9FpU1FyqAX/ZvqnwUklDKX8luq2XFD/NJx1lGsENOd4S517t2f1VcmCs+IlbbnVCY65TFx6GvwEOTPolAEIN4W5B3dnskyNK6x/dcrIGi7cSQi/kHUDXRH/YFZHTCUNAxRU4nvw==; 24:Uhjjy0W2tpfg69H5DT6dUIxc3ITlV8YMd6QAvusopwM61gRHzmRjYECR+0/TmR7DDB8/4hSKVt/Rw6/Hcds3S6R9Oc29yKPr/S2MQb/sD+I=; 7:S4L4cpmVEf53cQdvvqBPBi2dx3AMh3ngSh4622NJOC3EDNoE7UmphLjeMr2XxCgMyx/r9sMr+HIKAhH8QUsrCoK2WJ1r9kKVjCTTqhsIV8xXtX5TYeg9NM8Rr/G/Cv8elC+jV7lqDCldEnssblQYCH+yjBYHwih+eqKvwBiNtegofAJytezEbN9rvTd6PwXfgXqXFJNDP90M3dz7Qt9pPDCNTSBKtbFrUO9s/CCfGx0= x-ms-exchange-antispam-srfa-diagnostics: SSOS; x-ms-office365-filtering-correlation-id: d4cd2424-9f0a-4f01-5c74-08d4f5458877 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(48565401081)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DB6SPR00MB11; x-ms-traffictypediagnostic: DB6SPR00MB11: nodisclaimer: True x-exchange-antispam-report-test: UriScan:(180628864354917); x-microsoft-antispam-prvs: x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(93001095)(3002001)(10201501046)(6055026)(6041248)(20161123564025)(20161123558100)(20161123560025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DB6SPR00MB11; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DB6SPR00MB11; x-forefront-prvs: 0422860ED4 x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(39860400002)(54534003)(189002)(377424004)(199003)(66066001)(6916009)(478600001)(68736007)(97736004)(9686003)(6436002)(72206003)(101416001)(110136004)(2900100001)(189998001)(86362001)(5250100002)(99286003)(50986999)(6506006)(14454004)(54356999)(53936002)(55016002)(7696004)(3280700002)(33656002)(4326008)(8676002)(2906002)(74316002)(8936002)(102836003)(7736002)(305945005)(6116002)(81166006)(81156014)(3846002)(25786009)(105586002)(5660300001)(3660700001)(106356001); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6SPR00MB11; H:DB6PR0801MB2053.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Sep 2017 16:37:15.4967 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6SPR00MB11 Add an alignment test to check that aligned alloca's really do get correctly aligned. Some targets may not ensure SP is always a multiple of STACK_BOUNDARY (particularly with outgoing arguments), which means aligned alloca does not get correctly aligned. This can be fixed either by aligning the outgoing arguments or setting STACK_BOUNDARY correctly. Committed as obvious. ChangeLog: 2017-09-06 Wilco Dijkstra PR middle-end/78468 * gcc.dg/pr78468.c: Add alignment test. diff --git a/gcc/testsuite/gcc.dg/pr78468.c b/gcc/testsuite/gcc.dg/pr78468.c new file mode 100644 index 0000000000000000000000000000000000000000..68eb83a0868c16327e36055aae4eea34fc2ba35e --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr78468.c @@ -0,0 +1,102 @@ +/* { dg-do run } */ +/* { dg-require-effective-target alloca } */ +/* { dg-options "-O2 -fno-inline" } */ + +/* Test that targets correctly round the size of the outgoing arguments + to a multiple of STACK_BOUNDARY. There is a serious alignment bug if + aligned alloca does not get aligned! */ + +__extension__ typedef __UINTPTR_TYPE__ uintptr_t; +extern void abort (void); + +volatile int xx; +volatile int x = 16; + +void +t1 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, + void *p, int align) +{ + xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7; + if ((int)(uintptr_t)p & (align-1)) + abort (); +} + +void +t2 (int x0, int x1, int x2, int x3, int x4, int x5, int x6, int x7, + void *p, int align, int dummy) +{ + xx = x0 + x1 + x2 + x3 + x4 + x4 + x6 + x7; + if ((int)(uintptr_t)p & (align-1)) + abort (); +} + +void +t1_a4 (int size) +{ + void *p = __builtin_alloca_with_align (size, 32); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 4); +} + +void +t2_a4 (int size) +{ + void *p = __builtin_alloca_with_align (size, 32); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 4, 0); +} + +void +t1_a8 (int size) +{ + void *p = __builtin_alloca_with_align (size, 64); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 8); +} + +void +t2_a8 (int size) +{ + void *p = __builtin_alloca_with_align (size, 64); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 8, 0); +} + +void +t1_a16 (int size) +{ + void *p = __builtin_alloca_with_align (size, 128); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 16); +} + +void +t2_a16 (int size) +{ + void *p = __builtin_alloca_with_align (size, 128); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 16, 0); +} + +void +t1_a32 (int size) +{ + void *p = __builtin_alloca_with_align (size, 256); + t1 (0, 0, 0, 0, 0, 0, 0, 0, p, 32); +} + +void +t2_a32 (int size) +{ + void *p = __builtin_alloca_with_align (size, 256); + t2 (0, 0, 0, 0, 0, 0, 0, 0, p, 32, 0); +} + + +int +main () +{ + t1_a4 (x); + t2_a4 (x); + t1_a8 (x); + t2_a8 (x); + t1_a16 (x); + t2_a16 (x); + t1_a32 (x); + t2_a32 (x); + return 0; +}