summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErick Ochoa <erick.ochoa@theobroma-systems.com>2020-03-09 12:38:58 +0100
committerErick Ochoa <erick.ochoa@theobroma-systems.com>2020-04-28 23:35:48 +0200
commite03585e86ff1ee055c5350be4ec9754cecb97fb1 (patch)
tree185e16d2a3370a2a2d5d6e16b58540dfc88e7f65
parent5f9159551a2e2b60b20c1e2a2e76052d0f06c6b7 (diff)
Find out if function escapes
-rw-r--r--gcc/ipa-hello-world.c21
-rw-r--r--gcc/testsuite/gcc.dg/ipa/ipa-ea-07-function-escapes-0.c23
2 files changed, 44 insertions, 0 deletions
diff --git a/gcc/ipa-hello-world.c b/gcc/ipa-hello-world.c
index e5f69308e3c..85092f85453 100644
--- a/gcc/ipa-hello-world.c
+++ b/gcc/ipa-hello-world.c
@@ -210,6 +210,26 @@ is_variable_escaping(varpool_node *vnode)
return vnode->externally_visible;
}
+static bool
+is_function_escaping(cgraph_node *cnode)
+{
+ gcc_assert(cnode);
+ return cnode->externally_visible;
+}
+
+void
+is_any_function_escaping(type_map &escape_map)
+{
+ cgraph_node *cnode = NULL;
+ FOR_EACH_FUNCTION (cnode)
+ {
+ log("function name = %s\n", cnode->name());
+ bool is_escaping = is_function_escaping(cnode);
+ log("function %s is escaping %s\n", cnode->name(), is_escaping ? "true" : "false");
+
+ }
+}
+
void
is_any_variable_escaping(type_map &escape_map)
{
@@ -237,6 +257,7 @@ iphw_execute()
type_map escape_map;
collect_types(escape_map);
is_any_variable_escaping(escape_map);
+ is_any_function_escaping(escape_map);
print_types(escape_map);
return 0;
}
diff --git a/gcc/testsuite/gcc.dg/ipa/ipa-ea-07-function-escapes-0.c b/gcc/testsuite/gcc.dg/ipa/ipa-ea-07-function-escapes-0.c
new file mode 100644
index 00000000000..0e76135d984
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/ipa/ipa-ea-07-function-escapes-0.c
@@ -0,0 +1,23 @@
+/* { dg-do link } */
+/* { dg-options "-flto -fipa-hello-world -fdump-ipa-hello-world" } */
+/* { dg-require-effective-target lto } */
+
+
+#include <stddef.h>
+
+__attribute__((externally_visible)) void escaping()
+{
+}
+
+void non_escaping()
+{
+}
+
+int main()
+{
+}
+
+
+/* { dg-final { scan-wpa-ipa-dump "function escaping is escaping true" "hello-world" } } */
+/* { dg-final { scan-wpa-ipa-dump "function main is escaping true" "hello-world" } } */
+/* { dg-final { scan-wpa-ipa-dump "function non_escaping is escaping false" "hello-world" } } */