From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id F136B38582B1 for ; Wed, 6 Dec 2023 01:04:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F136B38582B1 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F136B38582B1 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::52d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701824689; cv=none; b=vb981mq/1mK2HBBpbXYp9YRUDrYwwDmr17sBP3s+E6hTTgQbRmKPmRq5s+w+v908ExekKWBuDfCGRPeNC7vxUgqyV0UOPDjZhv7Sr6ERzjXZizRwxuUAVRTvDC+vjLmOzWLFdCbH4xjj5yAIzjIBzT803HApd6Lh2Ka7h8jyyyw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701824689; c=relaxed/simple; bh=azrk363dGrsFJPN22PHInmO3swu6HHMugRf+nE/szaU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=Va2aGvmpYvn+qbMs30h6bHjhnrOVwELtjXnJn6DZR7BaHMsM4TXUekRGxUHr0tpcvLDh1jhH2G38KYwDWWKS2W/Mbvsi6RrC6G/DxJSL+13/eOdkj7gCuN9pBK2cVMSlIhWz1z8VNqt6YRJtys0dVrWrydvFxGcfteQMvbekc+U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-53fa455cd94so2821217a12.2 for ; Tue, 05 Dec 2023 17:04:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1701824685; x=1702429485; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=OUwSC0bUOQVdrgw0v9fAb8NEdSKROauSnD303nCVLGM=; b=LNFTVZvZaka6IRsxBNxMYf/tWssV9gNBjdqd3TBkPtaIAbuGU/CGu1I6lHWJ0mRvtm LobeuaoT31hc0Va5/AI7XNIh6i8odR3OoHIbGUxP3YODMTTHYHOUuxkpjfDfEKROv/oG mDIKNxhRbs2FnbqLUsv3gqJEJhpJWnqj1jCMUVOXfTkzrrXfX7xDwPGSkvXh9DVITNEx 5UOSkfa8X5WjKzVmUlME87/cM/REWif0eAeRWT2VSjzTitQoccb7yF6AYFGvZsxDj5GO wgoB50wztFJbbouGAXLX7smOeZ0sxbYd+KRiMKpJnR7mzeKPm1G4ycoZfq5CH98JBC3B 0COw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701824685; x=1702429485; h=mime-version:user-agent:message-id:in-reply-to:date:references :organization:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OUwSC0bUOQVdrgw0v9fAb8NEdSKROauSnD303nCVLGM=; b=qyZNc1T2ySBoD5cKItFUGXzXR8POcZNAwZ9KmGRS2WBp+MHfIw3j5tMZypYFDDy1i6 xKPwmPSi19LS+Gabu7nS2znVJVY2qoDU/YwJQ00o+ZRx7KVKjnA0342kCyWTIp9m/vFP rJaWaXX1affClr/pGs3g5gX93BYt8FdE3CXrJrsjuS0Ki7a6InTqiPEhqJNhDZIgwPdj c0+EJbKyKlRKQuvWWtxLqX56mOGbLET0hmPHWDcxeHavdmbH0bC0kpASVSxuCp9uteQ8 y2h0grAmqTfRSazVgQNgrqotx9jhXxmgFMCEhHAqfka2G1nHL5Cr1/qicFdJA4WJLWmM 9pHg== X-Gm-Message-State: AOJu0YzklIozY//E0kpU1xvRXG0V2DCkX9oTaCajWhKDH5eLXjXOMpGJ 3Ra0kk1L8bfj/zKDjBO+OIEZJw== X-Google-Smtp-Source: AGHT+IHtsMObZ7S4McZ8K4VqZpPhKpyNIDnZj884NdVtrtAVgCCbVMPKnBHR30N84nFsPQ3KDnFXAQ== X-Received: by 2002:a05:6a20:cea7:b0:18b:236d:3f0 with SMTP id if39-20020a056a20cea700b0018b236d03f0mr54459pzb.43.1701824684673; Tue, 05 Dec 2023 17:04:44 -0800 (PST) Received: from free.home ([2804:7f1:2080:ac51:aa28:dd55:15e9:45df]) by smtp.gmail.com with ESMTPSA id y13-20020a17090a154d00b0028699a25207sm5312915pja.12.2023.12.05.17.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 17:04:44 -0800 (PST) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 3B614UeY232831 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Tue, 5 Dec 2023 22:04:30 -0300 From: Alexandre Oliva To: Richard Biener Cc: gcc-patches@gcc.gnu.org, Jeremy Bennett , Craig Blackmore , Graham Markall , Martin Jambor , Jan Hubicka , Jim Wilson , Jeff Law , Jakub Jelinek Subject: Re: [PATCH v5] Introduce strub: machine-independent stack scrubbing Organization: Free thinker, does not speak for AdaCore References: Date: Tue, 05 Dec 2023 22:04:30 -0300 In-Reply-To: (Alexandre Oliva's message of "Tue, 05 Dec 2023 03:25:59 -0300") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE,WEIRD_QUOTING autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Dec 5, 2023, Alexandre Oliva wrote: > I intend to install this as part of the monster patch upthread. I tweaked it a little further, so that exceptions don't mess with the pattern counts, and extending the same anti-vrp measure to the other strub-const tests, even though they weren't affected. I also had to tweak strub-ptrfn2.c, because of the recent warning-to-error changes. Finally, the ChangeLog checker noticed that this entry was no longer applicable: > * multiple_target.cc (pass_target_clone::gate): Test seen_error. I'd duplicated exactly the fix for ipa/107897, and didn't realize it had been fixed independently. I'm reposting only the parts of the final patch pertaining to the modified test files below, to spare you all yet another copy of the moster patch. The whole thing is r14-6201. I've also refreshed my strub repo with the trunk commit (same commit id), with the extra patchlets for broader strub testing on top of it. diff --git a/gcc/testsuite/c-c++-common/torture/strub-const1.c b/gcc/testsuite/c-c++-common/torture/strub-const1.c new file mode 100644 index 0000000000000..5e956cb1a9b6b --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/strub-const1.c @@ -0,0 +1,23 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrub=strict -fdump-ipa-strub" } */ + +/* Check that, along with a strub const function call, we issue an asm + statement to make sure the watermark passed to it is held in memory before + the call, and another to make sure it is not assumed to be unchanged. f + should not be inlined into g, but if it were too simple it might be folded + by interprocedural value-range propagation. */ + +extern int __attribute__ ((__strub__ ("callable"), + __const__, __nothrow__)) c (); + +int __attribute__ ((__strub__, __const__)) +f () { + return c (); +} + +int +g () { + return f (); +} + +/* { dg-final { scan-ipa-dump-times "__asm__" 2 "strub" } } */ diff --git a/gcc/testsuite/c-c++-common/torture/strub-const2.c b/gcc/testsuite/c-c++-common/torture/strub-const2.c new file mode 100644 index 0000000000000..73d650292dfbf --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/strub-const2.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrub=strict -fdump-ipa-strub" } */ + +/* Check that, along with a strub implicitly-const function call, we issue an + asm statement to make sure the watermark passed to it is held in memory + before the call, and another to make sure it is not assumed to be + unchanged. */ + +extern int __attribute__ ((__strub__ ("callable"), + __const__, __nothrow__)) c (); + +int __attribute__ ((__strub__)) +#if ! __OPTIMIZE__ +__attribute__ ((__const__)) +#endif +f () { + return c (); +} + +int +g () { + return f (); +} + +/* { dg-final { scan-ipa-dump-times "__asm__" 2 "strub" } } */ diff --git a/gcc/testsuite/c-c++-common/torture/strub-const3.c b/gcc/testsuite/c-c++-common/torture/strub-const3.c new file mode 100644 index 0000000000000..2584f1f974a58 --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/strub-const3.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrub=strict -fdump-ipa-strub" } */ + +/* Check that, along with a strub const wrapping call, we issue an asm statement + to make sure the watermark passed to it is held in memory before the call, + and another to make sure it is not assumed to be unchanged. */ + +extern int __attribute__ ((__strub__ ("callable"), + __const__, __nothrow__)) c (); + +int __attribute__ ((__strub__ ("internal"), __const__)) +f () { + return c (); +} + +/* { dg-final { scan-ipa-dump-times "__asm__" 2 "strub" } } */ diff --git a/gcc/testsuite/c-c++-common/torture/strub-const4.c b/gcc/testsuite/c-c++-common/torture/strub-const4.c new file mode 100644 index 0000000000000..d819f54ec0230 --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/strub-const4.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrub=strict -fdump-ipa-strub" } */ + +/* Check that, along with a strub implicitly-const wrapping call, we issue an + asm statement to make sure the watermark passed to it is held in memory + before the call, and another to make sure it is not assumed to be + unchanged. */ + +extern int __attribute__ ((__strub__ ("callable"), + __const__, __nothrow__)) c (); + +int __attribute__ ((__strub__ ("internal"))) +#if ! __OPTIMIZE__ +__attribute__ ((__const__)) +#endif +f () { + return c (); +} + +/* { dg-final { scan-ipa-dump-times "__asm__" 2 "strub" } } */ [...] diff --git a/gcc/testsuite/c-c++-common/torture/strub-ptrfn2.c b/gcc/testsuite/c-c++-common/torture/strub-ptrfn2.c new file mode 100644 index 0000000000000..ef634d351265f --- /dev/null +++ b/gcc/testsuite/c-c++-common/torture/strub-ptrfn2.c @@ -0,0 +1,55 @@ +/* { dg-do compile } */ +/* { dg-options "-fstrub=relaxed -Wpedantic" } */ + +/* C++ does not warn about the partial incompatibilities. + + The d_p () calls are actually rejected, even in C++, but they are XFAILed + here because we don't get far enough in the compilation as to observe them, + because the incompatibilities are errors without -fpermissive. + strub-ptrfn3.c uses -fpermissive to check those. + */ + +extern int __attribute__ ((strub ("callable"))) bac (void); +extern int __attribute__ ((strub ("disabled"))) bad (void); +extern int __attribute__ ((strub ("internal"))) bar (void); +extern int __attribute__ ((strub ("at-calls"))) bal (void); + +void __attribute__ ((strub)) +bap (void) +{ + int __attribute__ ((strub ("disabled"))) (*d_p) (void) = bad; + int __attribute__ ((strub ("callable"))) (*c_p) (void) = bac; + int __attribute__ ((strub ("at-calls"))) (*a_p) (void) = bal; + + d_p = bac; /* { dg-warning "not quite compatible" "" { xfail c++ } } */ + c_p = bad; /* { dg-warning "not quite compatible" "" { xfail c++ } } */ + c_p = bar; /* { dg-warning "not quite compatible" "" { xfail c++ } } */ + c_p = bal; /* { dg-message "incompatible|invalid conversion" } */ + a_p = bac; /* { dg-message "incompatible|invalid conversion" } */ + + d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" "" { xfail *-*-* } } */ + c_p (); + a_p (); +} + +void __attribute__ ((strub)) +baP (void) +{ + typedef int __attribute__ ((strub ("disabled"))) d_fn_t (void); + typedef int __attribute__ ((strub ("callable"))) c_fn_t (void); + typedef int __attribute__ ((strub ("at-calls"))) a_fn_t (void); + + d_fn_t *d_p = bad; + c_fn_t *c_p = bac; + a_fn_t *a_p = bal; + + d_p = bac; /* { dg-warning "not quite compatible" "" { xfail c++ } } */ + c_p = bad; /* { dg-warning "not quite compatible" "" { xfail c++ } } */ + c_p = bar; /* { dg-warning "not quite compatible" "" { xfail c++ } } */ + c_p = bal; /* { dg-message "incompatible|invalid conversion" } */ + a_p = bac; /* { dg-message "incompatible|invalid conversion" } */ + + d_p (); /* { dg-error "indirect non-.strub. call in .strub. context" "" { xfail *-*-* } } */ + c_p (); + a_p (); +} -- Alexandre Oliva, happy hacker https://FSFLA.org/blogs/lxo/ Free Software Activist GNU Toolchain Engineer More tolerance and less prejudice are key for inclusion and diversity Excluding neuro-others for not behaving ""normal"" is *not* inclusive