From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 103025 invoked by alias); 6 Nov 2017 07:08:47 -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 103011 invoked by uid 89); 6 Nov 2017 07:08:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.9 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-io0-f193.google.com Received: from mail-io0-f193.google.com (HELO mail-io0-f193.google.com) (209.85.223.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 06 Nov 2017 07:08:44 +0000 Received: by mail-io0-f193.google.com with SMTP id p186so14584244ioe.12 for ; Sun, 05 Nov 2017 23:08:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=lm/G5DAoVlSC8acQOSX8z/1jhqAMhK3kC0wkPipTIak=; b=GmOWuM9bEoRv1211CRr4rvopcZsY55P+WJFUG3+NURpbBMmymc/AZ8ZN08BRSHqKZY 0XFTb7weaB8Ib9DeafE0+E3RyYLzPEWsrGOsvyypNPAWCL25C3DSWf9L3SPlB9rmACNQ 6ZBnvrQcC7xSvhvbGjIQIc0tnHo+8HpkWiN0sOEGpAVoICMRvzk0e+4JAR5bftN/sOZU mMUgfHOE3oZ8TTKXTylZK3C2mkaQ1ZiS3F/MJrWpY0NX1elE7L6qX84Pa6lCAirG6t9N us/D1asYOmYTs68mye0GscJnh6nqYFZknDm4JCF3BXAXnA1uqPQI35acYZs+9X65E1TU Eklg== X-Gm-Message-State: AMCzsaWAcal0weH3GNo9zzTlK9V7+fnaFymcUBLeL98bTxufH0NmvzKo N+9B+T0k6oyvy3fDhm2Uji17dCrCXbKFjpHg/Oo= X-Google-Smtp-Source: ABhQp+SNgG6PaS9ZihLNthAjsg38co4sHAl8lv51TsNidUSQBwhoNFa9GO3dDh0Pv6aBVjBZiUHa7qMOzTm/StT5h1Y= X-Received: by 10.107.70.6 with SMTP id t6mr17690223ioa.41.1509952122281; Sun, 05 Nov 2017 23:08:42 -0800 (PST) MIME-Version: 1.0 Received: by 10.2.74.18 with HTTP; Sun, 5 Nov 2017 23:08:41 -0800 (PST) In-Reply-To: <2229cabd-3bc3-c654-1eca-41d7d7d36aba@redhat.com> References: <2229cabd-3bc3-c654-1eca-41d7d7d36aba@redhat.com> From: Uros Bizjak Date: Mon, 06 Nov 2017 07:08:00 -0000 Message-ID: Subject: Re: [RFA][PATCH][PR target/82788] Remove uses of PROBE_INTERVAL in x86 target files To: Jeff Law Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset="UTF-8" X-SW-Source: 2017-11/txt/msg00328.txt.bz2 On Mon, Nov 6, 2017 at 5:47 AM, Jeff Law wrote: > On 11/03/2017 02:44 AM, Uros Bizjak wrote: >> Hello! >> >> -ENOCHANGELOG > Arggh. Downside of doing all the work on one machine, but mail > elsewhere. Attached with ChangeLog this time :-) > >> >> diff --git a/gcc/testsuite/gcc.c-torture/execute/pr82788.c >> b/gcc/testsuite/gcc.c-torture/execute/pr82788.c >> new file mode 100644 >> index 0000000..ceaa25f >> --- /dev/null >> +++ b/gcc/testsuite/gcc.c-torture/execute/pr82788.c >> @@ -0,0 +1,2 @@ >> + >> +int main() { int a[1442]; return 0;} >> >> You probably need to add some dg-options to the testcase. > Yea. Must have had a severe brain cramp there. Moved into gcc.dg and > appropriate options added. That and one whitespace nit were the only > changes since the original submission. > > > OK now? > > jeff > > * config/i386/i386.c (PROBE_INTERVAL): Remove. > (get_probe_interval): New function. > (ix86_adjust_stack_and_probe_stack_clash): Use get_probe_interval. > (ix86_adjust_stack_and_probe): Likewise. > (output_adjust_stack_and_probe): Likewise. > (ix86_emit_probe_stack_range): Likewise. > (ix86_expand_prologue): Likewise. > > * gcc.dg/pr82788.c: New test. OK. Thanks, Uros. > diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c > index fc43962..672a085 100644 > --- a/gcc/config/i386/i386.c > +++ b/gcc/config/i386/i386.c > @@ -12083,7 +12083,17 @@ release_scratch_register_on_entry (struct scratch_reg *sr) > } > } > > -#define PROBE_INTERVAL (1 << STACK_CHECK_PROBE_INTERVAL_EXP) > +/* Return the probing interval for -fstack-clash-protection. */ > + > +static HOST_WIDE_INT > +get_probe_interval (void) > +{ > + if (flag_stack_clash_protection) > + return (HOST_WIDE_INT_1U > + << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL)); > + else > + return (HOST_WIDE_INT_1U << STACK_CHECK_PROBE_INTERVAL_EXP); > +} > > /* Emit code to adjust the stack pointer by SIZE bytes while probing it. > > @@ -12147,8 +12157,7 @@ ix86_adjust_stack_and_probe_stack_clash (const HOST_WIDE_INT size) > /* We're allocating a large enough stack frame that we need to > emit probes. Either emit them inline or in a loop depending > on the size. */ > - HOST_WIDE_INT probe_interval > - = 1 << PARAM_VALUE (PARAM_STACK_CLASH_PROTECTION_PROBE_INTERVAL); > + HOST_WIDE_INT probe_interval = get_probe_interval (); > if (size <= 4 * probe_interval) > { > HOST_WIDE_INT i; > @@ -12157,7 +12166,7 @@ ix86_adjust_stack_and_probe_stack_clash (const HOST_WIDE_INT size) > /* Allocate PROBE_INTERVAL bytes. */ > rtx insn > = pro_epilogue_adjust_stack (stack_pointer_rtx, stack_pointer_rtx, > - GEN_INT (-PROBE_INTERVAL), -1, > + GEN_INT (-probe_interval), -1, > m->fs.cfa_reg == stack_pointer_rtx); > add_reg_note (insn, REG_STACK_CHECK, const0_rtx); > > @@ -12250,7 +12259,7 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > that's the easy case. The run-time loop is made up of 9 insns in the > generic case while the compile-time loop is made up of 3+2*(n-1) insns > for n # of intervals. */ > - if (size <= 4 * PROBE_INTERVAL) > + if (size <= 4 * get_probe_interval ()) > { > HOST_WIDE_INT i, adjust; > bool first_probe = true; > @@ -12259,15 +12268,15 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > values of N from 1 until it exceeds SIZE. If only one probe is > needed, this will not generate any code. Then adjust and probe > to PROBE_INTERVAL + SIZE. */ > - for (i = PROBE_INTERVAL; i < size; i += PROBE_INTERVAL) > + for (i = get_probe_interval (); i < size; i += get_probe_interval ()) > { > if (first_probe) > { > - adjust = 2 * PROBE_INTERVAL + dope; > + adjust = 2 * get_probe_interval () + dope; > first_probe = false; > } > else > - adjust = PROBE_INTERVAL; > + adjust = get_probe_interval (); > > emit_insn (gen_rtx_SET (stack_pointer_rtx, > plus_constant (Pmode, stack_pointer_rtx, > @@ -12276,9 +12285,9 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > } > > if (first_probe) > - adjust = size + PROBE_INTERVAL + dope; > + adjust = size + get_probe_interval () + dope; > else > - adjust = size + PROBE_INTERVAL - i; > + adjust = size + get_probe_interval () - i; > > emit_insn (gen_rtx_SET (stack_pointer_rtx, > plus_constant (Pmode, stack_pointer_rtx, > @@ -12288,7 +12297,8 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > /* Adjust back to account for the additional first interval. */ > last = emit_insn (gen_rtx_SET (stack_pointer_rtx, > plus_constant (Pmode, stack_pointer_rtx, > - PROBE_INTERVAL + dope))); > + (get_probe_interval () > + + dope)))); > } > > /* Otherwise, do the same as above, but in a loop. Note that we must be > @@ -12306,7 +12316,7 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > > /* Step 1: round SIZE to the previous multiple of the interval. */ > > - rounded_size = ROUND_DOWN (size, PROBE_INTERVAL); > + rounded_size = ROUND_DOWN (size, get_probe_interval ()); > > > /* Step 2: compute initial and final value of the loop counter. */ > @@ -12314,7 +12324,7 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > /* SP = SP_0 + PROBE_INTERVAL. */ > emit_insn (gen_rtx_SET (stack_pointer_rtx, > plus_constant (Pmode, stack_pointer_rtx, > - - (PROBE_INTERVAL + dope)))); > + - (get_probe_interval () + dope)))); > > /* LAST_ADDR = SP_0 + PROBE_INTERVAL + ROUNDED_SIZE. */ > if (rounded_size <= (HOST_WIDE_INT_1 << 31)) > @@ -12359,7 +12369,8 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > /* Adjust back to account for the additional first interval. */ > last = emit_insn (gen_rtx_SET (stack_pointer_rtx, > plus_constant (Pmode, stack_pointer_rtx, > - PROBE_INTERVAL + dope))); > + (get_probe_interval () > + + dope)))); > > release_scratch_register_on_entry (&sr); > } > @@ -12376,7 +12387,7 @@ ix86_adjust_stack_and_probe (const HOST_WIDE_INT size) > XVECEXP (expr, 0, 1) > = gen_rtx_SET (stack_pointer_rtx, > plus_constant (Pmode, stack_pointer_rtx, > - PROBE_INTERVAL + dope + size)); > + get_probe_interval () + dope + size)); > add_reg_note (last, REG_FRAME_RELATED_EXPR, expr); > RTX_FRAME_RELATED_P (last) = 1; > > @@ -12403,7 +12414,7 @@ output_adjust_stack_and_probe (rtx reg) > > /* SP = SP + PROBE_INTERVAL. */ > xops[0] = stack_pointer_rtx; > - xops[1] = GEN_INT (PROBE_INTERVAL); > + xops[1] = GEN_INT (get_probe_interval ()); > output_asm_insn ("sub%z0\t{%1, %0|%0, %1}", xops); > > /* Probe at SP. */ > @@ -12433,14 +12444,14 @@ ix86_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size) > that's the easy case. The run-time loop is made up of 6 insns in the > generic case while the compile-time loop is made up of n insns for n # > of intervals. */ > - if (size <= 6 * PROBE_INTERVAL) > + if (size <= 6 * get_probe_interval ()) > { > HOST_WIDE_INT i; > > /* Probe at FIRST + N * PROBE_INTERVAL for values of N from 1 until > it exceeds SIZE. If only one probe is needed, this will not > generate any code. Then probe at FIRST + SIZE. */ > - for (i = PROBE_INTERVAL; i < size; i += PROBE_INTERVAL) > + for (i = get_probe_interval (); i < size; i += get_probe_interval ()) > emit_stack_probe (plus_constant (Pmode, stack_pointer_rtx, > -(first + i))); > > @@ -12463,7 +12474,7 @@ ix86_emit_probe_stack_range (HOST_WIDE_INT first, HOST_WIDE_INT size) > > /* Step 1: round SIZE to the previous multiple of the interval. */ > > - rounded_size = ROUND_DOWN (size, PROBE_INTERVAL); > + rounded_size = ROUND_DOWN (size, get_probe_interval ()); > > > /* Step 2: compute initial and final value of the loop counter. */ > @@ -12524,7 +12535,7 @@ output_probe_stack_range (rtx reg, rtx end) > > /* TEST_ADDR = TEST_ADDR + PROBE_INTERVAL. */ > xops[0] = reg; > - xops[1] = GEN_INT (PROBE_INTERVAL); > + xops[1] = GEN_INT (get_probe_interval ()); > output_asm_insn ("sub%z0\t{%1, %0|%0, %1}", xops); > > /* Probe at TEST_ADDR. */ > @@ -13182,7 +13193,7 @@ ix86_expand_prologue (void) > else if (STACK_CHECK_MOVING_SP) > { > if (!(crtl->is_leaf && !cfun->calls_alloca > - && allocate <= PROBE_INTERVAL)) > + && allocate <= get_probe_interval ())) > { > ix86_adjust_stack_and_probe (allocate); > allocate = 0; > @@ -13199,7 +13210,7 @@ ix86_expand_prologue (void) > { > if (crtl->is_leaf && !cfun->calls_alloca) > { > - if (size > PROBE_INTERVAL) > + if (size > get_probe_interval ()) > ix86_emit_probe_stack_range (0, size); > } > else > @@ -13210,7 +13221,7 @@ ix86_expand_prologue (void) > { > if (crtl->is_leaf && !cfun->calls_alloca) > { > - if (size > PROBE_INTERVAL > + if (size > get_probe_interval () > && size > get_stack_check_protect ()) > ix86_emit_probe_stack_range (get_stack_check_protect (), > size - get_stack_check_protect ()); > > diff --git a/gcc/testsuite/gcc.dg/pr82788.c b/gcc/testsuite/gcc.dg/pr82788.c > new file mode 100644 > index 0000000..a8f628f > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/pr82788.c > @@ -0,0 +1,4 @@ > +/* { dg-do run } */ > +/* { dg-options "-O2 -fstack-clash-protection --param stack-clash-protection-probe-interval=10 --param stack-clash-protection-guard-size=12" } */ > +/* { dg-require-effective-target supports_stack_clash_protection } */ > +int main() { int a[1442]; return 0;} > >