From patchwork Sun Feb 7 12:22:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Marcin_Ko=C5=9Bcielnicki?= X-Patchwork-Id: 579965 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 274791409C2 for ; Sun, 7 Feb 2016 23:22:47 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=GVz+CKIx; dkim-atps=neutral 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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; q=dns; s= default; b=P/L5CPOEmfynvN8G8ZuKngEz4FAtqtNR9THxVKMur8QpvZ5f1UlgU vAskNq+ZXcN8GAAtvXFRLzY7IbnbOzXOSTjCm1vZCCfAladtJpJKm58AcCRkJx1L IXmMzDHONMzLIjfRIzIl/1D4TfxT5CGxv9x7WCnPkRizFnOpfUmeMc= 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:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=default; bh=N5qOUj7h2phdCMzoVFYa4J8easU=; b=GVz+CKIx7uVCOD6PShOEGUcaeM7y M1Q3IrF608TgbvnwytPr+u7DFk2Q/BsmTo4XJ9KImFmDkkHRiBHHMK+VdgCcaXth UPjpw0/oOtb+0YVU5I2xEPtvhWsnfXzJipKMebyF0oPz5Tz1M8Hfcu1jGndpmWY3 bFRd+omROHg5iKA= Received: (qmail 61726 invoked by alias); 7 Feb 2016 12:22:40 -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 61716 invoked by uid 89); 7 Feb 2016 12:22:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_05, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=chi, stm, ahi, stg X-HELO: xyzzy.0x04.net Received: from xyzzy.0x04.net (HELO xyzzy.0x04.net) (109.74.193.254) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 07 Feb 2016 12:22:37 +0000 Received: from hogfather.0x04.net (89-65-66-135.dynamic.chello.pl [89.65.66.135]) by xyzzy.0x04.net (Postfix) with ESMTPS id 6F7053FE0F; Sun, 7 Feb 2016 13:23:21 +0100 (CET) Received: by hogfather.0x04.net (Postfix, from userid 1000) id 8839458008E; Sun, 7 Feb 2016 13:22:32 +0100 (CET) From: =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= To: krebbel@linux.vnet.ibm.com Cc: gcc-patches@gcc.gnu.org, =?UTF-8?q?Marcin=20Ko=C5=9Bcielnicki?= Subject: [PATCH] testsuite/s390: Add __morestack test. Date: Sun, 7 Feb 2016 13:22:31 +0100 Message-Id: <1454847751-9758-1-git-send-email-koriakin@0x04.net> In-Reply-To: <56AB907E.2010809@linux.vnet.ibm.com> References: <56AB907E.2010809@linux.vnet.ibm.com> MIME-Version: 1.0 gcc/testsuite/ChangeLog: * gcc.target/s390/morestack.c: New test. --- Here's the promised test. gcc/testsuite/ChangeLog | 4 + gcc/testsuite/gcc.target/s390/morestack.c | 260 ++++++++++++++++++++++++++++++ 2 files changed, 264 insertions(+) create mode 100644 gcc/testsuite/gcc.target/s390/morestack.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 8f528b2..26d600f 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2016-02-05 Marcin Koƛcielnicki : + + * gcc.target/s390/morestack.c: New test. + 2016-02-04 Martin Liska * g++.dg/asan/pr69276.C: New test. diff --git a/gcc/testsuite/gcc.target/s390/morestack.c b/gcc/testsuite/gcc.target/s390/morestack.c new file mode 100644 index 0000000..aa28b72 --- /dev/null +++ b/gcc/testsuite/gcc.target/s390/morestack.c @@ -0,0 +1,260 @@ +/* Checks proper behavior of __morestack function - specifically, GPR + values surviving, stack parameters being copied, and vararg + pointer being correct. */ + +/* { dg-do run } */ +/* { dg-options "" } */ + +#include + +void *orig_r15; + +/* 1. Function "test" saves registers, makes a stack frame, puts known + * values in registers, and calls __morestack, telling it to jump to + * testinner, with return address pointing to "testret". + * 2. "testinner" checks that parameter registers match what has been + * passed from "test", stack parameters were copied properly to + * the new stack, and the argument pointer matches the calling + * function's stack pointer. It then leaves new values in volatile + * registers (including return value registers) and returns. + * 3. "testret" checks that return value registers contain the expected + * return value, callee-saved GPRs match the values from "test", + * and then returns to main. */ + +extern unsigned long testparams[3]; + +#ifdef __s390x__ + +asm( + ".global test\n" + "test:\n" + ".type test, @function\n" + /* Save registers. */ + "stmg %r6, %r15, 0x30(%r15)\n" + /* Save original sp in a global. */ + "larl %r1, orig_r15\n" + "stg %r15, 0(%r1)\n" + /* Make a stack frame. */ + "aghi %r15, -168\n" + /* A stack parameter. */ + "lghi %r1, 0x1240\n" + "stg %r1, 160(%r15)\n" + /* Registers. */ + "lghi %r0, 0x1230\n" + "lghi %r2, 0x1232\n" + "lghi %r3, 0x1233\n" + "lghi %r4, 0x1234\n" + "lghi %r5, 0x1235\n" + "lghi %r6, 0x1236\n" + "lghi %r7, 0x1237\n" + "lghi %r8, 0x1238\n" + "lghi %r9, 0x1239\n" + "lghi %r10, 0x123a\n" + "lghi %r11, 0x123b\n" + "lghi %r12, 0x123c\n" + "lghi %r13, 0x123d\n" + /* Fake return address. */ + "larl %r14, testret\n" + /* Call morestack. */ + "larl %r1, testparams\n" + "jg __morestack\n" + + /* Entry point. */ + "testinner:\n" + /* Check registers. */ + "cghi %r0, 0x1230\n" + "jne testerr\n" + "cghi %r2, 0x1232\n" + "jne testerr\n" + "cghi %r3, 0x1233\n" + "jne testerr\n" + "cghi %r4, 0x1234\n" + "jne testerr\n" + "cghi %r5, 0x1235\n" + "jne testerr\n" + "cghi %r6, 0x1236\n" + "jne testerr\n" + /* Check stack param. */ + "lg %r0, 0xa0(%r15)\n" + "cghi %r0, 0x1240\n" + "jne testerr\n" + /* Check argument pointer. */ + "aghi %r1, 8\n" + "larl %r2, orig_r15\n" + "cg %r1, 0(%r2)\n" + "jne testerr\n" + /* Modify volatile registers. */ + "lghi %r0, 0x1250\n" + "lghi %r1, 0x1251\n" + "lghi %r2, 0x1252\n" + "lghi %r3, 0x1253\n" + "lghi %r4, 0x1254\n" + "lghi %r5, 0x1255\n" + /* Return. */ + "br %r14\n" + + /* Returns here. */ + "testret:\n" + /* Check return registers. */ + "cghi %r2, 0x1252\n" + "jne testerr\n" + /* Check callee-saved registers. */ + "cghi %r6, 0x1236\n" + "jne testerr\n" + "cghi %r7, 0x1237\n" + "jne testerr\n" + "cghi %r8, 0x1238\n" + "jne testerr\n" + "cghi %r9, 0x1239\n" + "jne testerr\n" + "cghi %r10, 0x123a\n" + "jne testerr\n" + "cghi %r11, 0x123b\n" + "jne testerr\n" + "cghi %r12, 0x123c\n" + "jne testerr\n" + "cghi %r13, 0x123d\n" + "jne testerr\n" + /* Return. */ + "lmg %r6, %r15, 0xd8(%r15)\n" + "br %r14\n" + + /* Parameters block. */ + ".section .data\n" + ".align 8\n" + "testparams:\n" + ".quad 160\n" + ".quad 8\n" + ".quad testinner-testparams\n" + ".text\n" +); + +#else + +asm( + ".global test\n" + "test:\n" + ".type test, @function\n" + /* Save registers. */ + "stm %r6, %r15, 0x18(%r15)\n" + /* Save original sp in a global. */ + "larl %r1, orig_r15\n" + "st %r15, 0(%r1)\n" + /* Make a stack frame. */ + "ahi %r15, -0x68\n" + /* A stack parameter. */ + "lhi %r1, 0x1240\n" + "st %r1, 0x60(%r15)\n" + "lhi %r1, 0x1241\n" + "st %r1, 0x64(%r15)\n" + /* Registers. */ + "lhi %r0, 0x1230\n" + "lhi %r2, 0x1232\n" + "lhi %r3, 0x1233\n" + "lhi %r4, 0x1234\n" + "lhi %r5, 0x1235\n" + "lhi %r6, 0x1236\n" + "lhi %r7, 0x1237\n" + "lhi %r8, 0x1238\n" + "lhi %r9, 0x1239\n" + "lhi %r10, 0x123a\n" + "lhi %r11, 0x123b\n" + "lhi %r12, 0x123c\n" + "lhi %r13, 0x123d\n" + /* Fake return address. */ + "larl %r14, testret\n" + /* Call morestack. */ + "larl %r1, testparams\n" + "jg __morestack\n" + + /* Entry point. */ + "testinner:\n" + /* Check registers. */ + "chi %r0, 0x1230\n" + "jne testerr\n" + "chi %r2, 0x1232\n" + "jne testerr\n" + "chi %r3, 0x1233\n" + "jne testerr\n" + "chi %r4, 0x1234\n" + "jne testerr\n" + "chi %r5, 0x1235\n" + "jne testerr\n" + "chi %r6, 0x1236\n" + "jne testerr\n" + /* Check stack param. */ + "l %r0, 0x60(%r15)\n" + "chi %r0, 0x1240\n" + "jne testerr\n" + "l %r0, 0x64(%r15)\n" + "chi %r0, 0x1241\n" + "jne testerr\n" + /* Check argument pointer. */ + "ahi %r1, 8\n" + "larl %r2, orig_r15\n" + "c %r1, 0(%r2)\n" + "jne testerr\n" + /* Modify volatile registers. */ + "lhi %r0, 0x1250\n" + "lhi %r1, 0x1251\n" + "lhi %r2, 0x1252\n" + "lhi %r3, 0x1253\n" + "lhi %r4, 0x1254\n" + "lhi %r5, 0x1255\n" + /* Return. */ + "br %r14\n" + + /* Returns here. */ + "testret:\n" + /* Check return registers. */ + "chi %r2, 0x1252\n" + "jne testerr\n" + "chi %r3, 0x1253\n" + "jne testerr\n" + /* Check callee-saved registers. */ + "chi %r6, 0x1236\n" + "jne testerr\n" + "chi %r7, 0x1237\n" + "jne testerr\n" + "chi %r8, 0x1238\n" + "jne testerr\n" + "chi %r9, 0x1239\n" + "jne testerr\n" + "chi %r10, 0x123a\n" + "jne testerr\n" + "chi %r11, 0x123b\n" + "jne testerr\n" + "chi %r12, 0x123c\n" + "jne testerr\n" + "chi %r13, 0x123d\n" + "jne testerr\n" + /* Return. */ + "lm %r6, %r15, 0x80(%r15)\n" + "br %r14\n" + + /* Parameters block. */ + ".section .data\n" + ".align 4\n" + "testparams:\n" + ".long 96\n" + ".long 8\n" + ".long testinner-testparams\n" + ".text\n" +); + +#endif + +_Noreturn void testerr (void) { + exit(1); +} + +extern void test (void); + +int main (void) { + test(); + /* Now try again, with huge stack frame requested - to exercise + both paths in __morestack (new allocation needed or not). */ + testparams[0] = 1000000; + test(); + return 0; +}