summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c')
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c
new file mode 100644
index 00000000000..55879c43719
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-10-return-type-escapes-0.c
@@ -0,0 +1,42 @@
+/* { dg-do link } */
+/* { dg-options "-flto -fipa-type-escape-analysis -fdump-ipa-type-escape-analysis -fprint-cast-analysis" } */
+
+#include <stddef.h>
+
+struct astruct_s
+{
+ _Bool a;
+ _Bool b;
+ _Bool c;
+};
+struct astruct_s astruct; // This should not escape
+struct bstruct_s
+{
+ _Bool a;
+ _Bool b;
+ _Bool c;
+};
+struct bstruct_s bstruct; // This should not escape
+
+// This will make astruct_s escape
+struct astruct_s __attribute__ ((externally_visible)) escaping ()
+{
+ struct astruct_s a;
+ return a;
+}
+struct bstruct_s
+non_escaping ()
+{}
+
+int
+main ()
+{
+ astruct = escaping ();
+ bstruct = non_escaping ();
+}
+
+// This says that astruct_s escapes because it is returning from an externally
+// visible function
+/* { dg-final { scan-wpa-ipa-dump " record astruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: e=1 g=0 p=0 r=1 c=0 v=0 u=0 i=0" "type-escape-analysis" } } */
+// This says that bstruct_s does not escape
+/* { dg-final { scan-wpa-ipa-dump " record bstruct_s .boolean_type a;boolean_type b;boolean_type c;. reason: e=0 g=0 p=0 r=0 c=0 v=0 u=0 i=0" "type-escape-analysis" } } */