public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-5297] ipa-sra: Testcase that removing a "returns_nonnull" retval works
@ 2021-11-16 9:46 Martin Jambor
0 siblings, 0 replies; only message in thread
From: Martin Jambor @ 2021-11-16 9:46 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:9f7fc82014626173bd2c9effa8d8dcb3abd9b06c
commit r12-5297-g9f7fc82014626173bd2c9effa8d8dcb3abd9b06c
Author: Martin Jambor <mjambor@suse.cz>
Date: Tue Nov 16 10:44:53 2021 +0100
ipa-sra: Testcase that removing a "returns_nonnull" retval works
Since we can now remove return values of functions with return_nonnull
type attribute, I'll feel a bit safer if we can test this does not ICE
when someone attempts to access a non-existent call LHS. Eventually
we should probably drop the attribute when this happens.
gcc/testsuite/ChangeLog:
2021-11-15 Martin Jambor <mjambor@suse.cz>
* gcc.dg/ipa/ipa-sra-ret-nonull.c: New test.
Diff:
---
gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c | 40 +++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c b/gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c
new file mode 100644
index 00000000000..18c13efd609
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-sra-ret-nonull.c
@@ -0,0 +1,40 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fdump-ipa-sra-details" } */
+
+volatile void *gp;
+volatile void *gq;
+char buf[16];
+
+__attribute__((returns_nonnull, noinline))
+static char *
+foo (char *p, char *q)
+{
+ gq = q;
+ gp = p;
+ return q;
+}
+
+__attribute__((returns_nonnull, noinline))
+static char *
+bar (char *p, char *q)
+{
+ return foo (p, q) + 8;
+}
+
+__attribute__((noipa))
+static char *
+get_charp (void)
+{
+ return &buf[0];
+}
+
+int
+main ()
+{
+ char *r;
+ asm volatile ("" : : : "memory");
+ r = bar (get_charp (), get_charp ());
+ return 0;
+}
+
+/* { dg-final { scan-ipa-dump-times "Will SKIP return." 2 "sra" } } */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-11-16 9:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-16 9:46 [gcc r12-5297] ipa-sra: Testcase that removing a "returns_nonnull" retval works Martin Jambor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).