From 85da7f5c90a9755578d54755b10df29b9305f9b5 Mon Sep 17 00:00:00 2001
From: Erick Ochoa <eochoa@gcc.gnu.org>
Date: Wed, 8 Sep 2021 20:34:11 +0200
Subject: [PATCH 1/4] Initial commit

---
 gcc/Makefile.in      |  1 +
 gcc/common.opt       |  5 +++
 gcc/ipa-hash.c       | 83 ++++++++++++++++++++++++++++++++++++++++++++
 gcc/ipa-hash.h       |  1 +
 gcc/lto-section-in.c |  1 +
 gcc/lto-streamer.h   |  1 +
 gcc/passes.def       |  1 +
 gcc/tree-pass.h      |  1 +
 8 files changed, 94 insertions(+)
 create mode 100644 gcc/ipa-hash.c
 create mode 100644 gcc/ipa-hash.h

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index f0c560fe45b..efcee73c00f 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -1449,6 +1449,7 @@ OBJS = \
 	init-regs.o \
 	internal-fn.o \
 	ipa-cp.o \
+	ipa-hash.o \
 	ipa-sra.o \
 	ipa-devirt.o \
 	ipa-fnsummary.o \
diff --git a/gcc/common.opt b/gcc/common.opt
index f103a7de004..c1163a9a501 100644
--- a/gcc/common.opt
+++ b/gcc/common.opt
@@ -1866,6 +1866,10 @@ fipa-pta
 Common Var(flag_ipa_pta) Init(0) Optimization
 Perform interprocedural points-to analysis.
 
+fipa-hash
+Common Var(flag_ipa_hash) Init (0) Optimization
+Please help me understand the problem.
+
 fipa-pure-const
 Common Var(flag_ipa_pure_const) Init(0) Optimization
 Discover pure and const functions.
@@ -3528,4 +3532,5 @@ fipa-ra
 Common Var(flag_ipa_ra) Optimization
 Use caller save register across calls if possible.
 
+
 ; This comment is to ensure we retain the blank line above.
diff --git a/gcc/ipa-hash.c b/gcc/ipa-hash.c
new file mode 100644
index 00000000000..84abe1da0d9
--- /dev/null
+++ b/gcc/ipa-hash.c
@@ -0,0 +1,83 @@
+#include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "backend.h"
+#include "tree.h"
+#include "gimple-expr.h"
+#include "predict.h"
+#include "alloc-pool.h"
+#include "tree-pass.h"
+#include "cgraph.h"
+#include "diagnostic.h"
+#include "fold-const.h"
+#include "gimple-fold.h"
+#include "symbol-summary.h"
+#include "tree-vrp.h"
+#include "ipa-prop.h"
+#include "tree-pretty-print.h"
+#include "tree-inline.h"
+#include "ipa-fnsummary.h"
+#include "ipa-utils.h"
+#include "tree-ssa-ccp.h"
+#include "stringpool.h"
+#include "attribs.h"
+#include "gimple.h"
+#include "data-streamer.h"
+#include "lto-streamer.h"
+#include "ipa-hash.h"
+
+static void
+ipa_hash_generate_summary (void)
+{
+  return;
+}
+
+static unsigned
+ipa_pta_execute (void)
+{
+  if (dump_file) fprintf (dump_file, "hello from wpa\n");
+  return 0;
+}
+
+namespace {
+const pass_data pass_data_ipa_hash =
+{
+  IPA_PASS,
+  "hash",
+  OPTGROUP_NONE,
+  TV_NONE,
+  (PROP_cfg | PROP_ssa),
+  0,
+  0,
+  0,
+  0,
+};
+
+class pass_ipa_hash : public ipa_opt_pass_d
+{
+public:
+  pass_ipa_hash (gcc::context *ctxt)
+    : ipa_opt_pass_d (pass_data_ipa_hash, ctxt,
+		    ipa_hash_generate_summary,
+		    NULL,
+		    NULL,
+		    NULL,
+		    NULL,
+		    NULL,
+		    0,
+		    NULL,
+		    NULL)
+  {}
+
+  virtual bool gate (function*) { return flag_ipa_hash; }
+  virtual unsigned execute (function*) { return ipa_pta_execute (); }
+
+};
+
+} // anonymous-namespace
+
+ipa_opt_pass_d*
+make_pass_ipa_hash (gcc::context *ctxt)
+{
+  return new pass_ipa_hash (ctxt);
+}
diff --git a/gcc/ipa-hash.h b/gcc/ipa-hash.h
new file mode 100644
index 00000000000..6f70f09beec
--- /dev/null
+++ b/gcc/ipa-hash.h
@@ -0,0 +1 @@
+#pragma once
diff --git a/gcc/lto-section-in.c b/gcc/lto-section-in.c
index d16b3353221..bd02c24a00e 100644
--- a/gcc/lto-section-in.c
+++ b/gcc/lto-section-in.c
@@ -57,6 +57,7 @@ const char *lto_section_name[LTO_N_SECTION_TYPES] =
   "ipa_sra",
   "odr_types",
   "ipa_modref",
+  "ipa_hash",
 };
 
 /* Hooks so that the ipa passes can call into the lto front end to get
diff --git a/gcc/lto-streamer.h b/gcc/lto-streamer.h
index 5f0335eb76c..493cb4d6fe7 100644
--- a/gcc/lto-streamer.h
+++ b/gcc/lto-streamer.h
@@ -229,6 +229,7 @@ enum lto_section_type
   LTO_section_ipa_sra,
   LTO_section_odr_types,
   LTO_section_ipa_modref,
+  LTO_section_ipa_hash,
   LTO_N_SECTION_TYPES		/* Must be last.  */
 };
 
diff --git a/gcc/passes.def b/gcc/passes.def
index d7a1f8c97a6..7c4752db710 100644
--- a/gcc/passes.def
+++ b/gcc/passes.def
@@ -168,6 +168,7 @@ along with GCC; see the file COPYING3.  If not see
      symbols are not allowed outside of the comdat group.  Privatizing early
      would result in missed optimizations due to this restriction.  */
   NEXT_PASS (pass_ipa_comdats);
+  NEXT_PASS (pass_ipa_hash);
   TERMINATE_PASS_LIST (all_regular_ipa_passes)
 
   /* Simple IPA passes executed after the regular passes.  In WHOPR mode the
diff --git a/gcc/tree-pass.h b/gcc/tree-pass.h
index 83941bc0cee..825fc4e98b7 100644
--- a/gcc/tree-pass.h
+++ b/gcc/tree-pass.h
@@ -531,6 +531,7 @@ extern ipa_opt_pass_d *make_pass_ipa_profile (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_cdtor_merge (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_single_use (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_comdats (gcc::context *ctxt);
+extern ipa_opt_pass_d *make_pass_ipa_hash (gcc::context *ctxt);
 extern ipa_opt_pass_d *make_pass_ipa_modref (gcc::context *ctxt);
 
 extern gimple_opt_pass *make_pass_cleanup_cfg_post_optimizing (gcc::context
-- 
2.25.1

