commit 3af9315e31e860628316211e56aa970b4eb36473
Author: hiraditya <hiraditya@gmail.com>
Date:   Tue Mar 10 22:39:30 2015 -0500

    Remove splay_tree from gimplify.c

diff --git a/gcc/gimplify.c b/gcc/gimplify.c
index d822913..64e8d9d 100644
--- a/gcc/gimplify.c
+++ b/gcc/gimplify.c
@@ -92,6 +92,18 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-pass.h"		/* FIXME: only for PROP_gimple_any */
 #include "builtins.h"
 
+#include<map>
+
+/* A stable comparison functor to sort trees.  */
+struct tree_compare_decl_uid {
+  bool  operator ()(const tree &xa, const tree &xb) const
+  {
+    return DECL_UID (xa) < DECL_UID (xb);
+  }
+};
+
+typedef std::map<tree, unsigned, tree_compare_decl_uid> gimplify_tree_t;
+
 enum gimplify_omp_var_data
 {
   GOVD_SEEN = 1,
@@ -166,7 +178,7 @@ struct gimplify_ctx
 struct gimplify_omp_ctx
 {
   struct gimplify_omp_ctx *outer_context;
-  splay_tree variables;
+  gimplify_tree_t *variables;
   hash_set<tree> *privatized_types;
   location_t location;
   enum omp_clause_default_kind default_kind;
@@ -364,17 +376,6 @@ gimple_pop_condition (gimple_seq *pre_p)
     }
 }
 
-/* A stable comparison routine for use with splay trees and DECLs.  */
-
-static int
-splay_tree_compare_decl_uid (splay_tree_key xa, splay_tree_key xb)
-{
-  tree a = (tree) xa;
-  tree b = (tree) xb;
-
-  return DECL_UID (a) - DECL_UID (b);
-}
-
 /* Create a new omp construct that deals with variable remapping.  */
 
 static struct gimplify_omp_ctx *
@@ -384,7 +385,7 @@ new_omp_context (enum omp_region_type region_type)
 
   c = XCNEW (struct gimplify_omp_ctx);
   c->outer_context = gimplify_omp_ctxp;
-  c->variables = splay_tree_new (splay_tree_compare_decl_uid, 0, 0);
+  c->variables = new gimplify_tree_t;
   c->privatized_types = new hash_set<tree>;
   c->location = input_location;
   c->region_type = region_type;
@@ -401,7 +402,7 @@ new_omp_context (enum omp_region_type region_type)
 static void
 delete_omp_context (struct gimplify_omp_ctx *c)
 {
-  splay_tree_delete (c->variables);
+  delete c->variables;
   delete c->privatized_types;
   XDELETE (c);
 }
@@ -1093,8 +1094,7 @@ gimplify_bind_expr (tree *expr_p, gimple_seq *pre_p)
 	  /* Mark variable as local.  */
 	  if (ctx && !DECL_EXTERNAL (t)
 	      && (! DECL_SEEN_IN_BIND_EXPR_P (t)
-		  || splay_tree_lookup (ctx->variables,
-					(splay_tree_key) t) == NULL))
+          || (ctx->variables->find(t) == ctx->variables->end())))
 	    {
 	      if (ctx->region_type == ORT_SIMD
 		  && TREE_ADDRESSABLE (t)
@@ -5522,20 +5522,21 @@ gimplify_stmt (tree *stmt_p, gimple_seq *seq_p)
 void
 omp_firstprivatize_variable (struct gimplify_omp_ctx *ctx, tree decl)
 {
-  splay_tree_node n;
+  gimplify_tree_t::iterator n;
 
   if (decl == NULL || !DECL_P (decl))
     return;
 
   do
     {
-      n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
-      if (n != NULL)
+      n = ctx->variables->find(decl);
+      if (n != ctx->variables->end())
 	{
-	  if (n->value & GOVD_SHARED)
-	    n->value = GOVD_FIRSTPRIVATE | (n->value & GOVD_SEEN);
-	  else if (n->value & GOVD_MAP)
-	    n->value |= GOVD_MAP_TO_ONLY;
+      unsigned &value = n->second;
+      if (value & GOVD_SHARED)
+        value = GOVD_FIRSTPRIVATE | (value & GOVD_SEEN);
+      else if (value & GOVD_MAP)
+        value |= GOVD_MAP_TO_ONLY;
 	  else
 	    return;
 	}
@@ -5612,7 +5613,7 @@ omp_firstprivatize_type_sizes (struct gimplify_omp_ctx *ctx, tree type)
 static void
 omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
 {
-  splay_tree_node n;
+  gimplify_tree_t::iterator n;
   unsigned int nflags;
   tree t;
 
@@ -5625,19 +5626,20 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
       || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
     flags |= GOVD_SEEN;
 
-  n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
-  if (n != NULL && n->value != GOVD_ALIGNED)
+  n = ctx->variables->find(decl);
+  if (n != ctx->variables->end() && n->second != GOVD_ALIGNED)
     {
+      unsigned &value = n->second;
       /* We shouldn't be re-adding the decl with the same data
 	 sharing class.  */
-      gcc_assert ((n->value & GOVD_DATA_SHARE_CLASS & flags) == 0);
+      gcc_assert ((value & GOVD_DATA_SHARE_CLASS & flags) == 0);
       /* The only combination of data sharing classes we should see is
 	 FIRSTPRIVATE and LASTPRIVATE.  */
-      nflags = n->value | flags;
+      nflags = value | flags;
       gcc_assert ((nflags & GOVD_DATA_SHARE_CLASS)
 		  == (GOVD_FIRSTPRIVATE | GOVD_LASTPRIVATE)
 		  || (flags & GOVD_DATA_SHARE_CLASS) == 0);
-      n->value = nflags;
+      value = nflags;
       return;
     }
 
@@ -5705,10 +5707,10 @@ omp_add_variable (struct gimplify_omp_ctx *ctx, tree decl, unsigned int flags)
 	}
     }
 
-  if (n != NULL)
-    n->value |= flags;
+  if (n != ctx->variables->end())
+    n->second |= flags;
   else
-    splay_tree_insert (ctx->variables, (splay_tree_key)decl, flags);
+    (*ctx->variables)[decl] = flags;
 }
 
 /* Notice a threadprivate variable DECL used in OMP context CTX.
@@ -5720,36 +5722,37 @@ static bool
 omp_notice_threadprivate_variable (struct gimplify_omp_ctx *ctx, tree decl,
 				   tree decl2)
 {
-  splay_tree_node n;
+  gimplify_tree_t::iterator n;
+
   struct gimplify_omp_ctx *octx;
 
   for (octx = ctx; octx; octx = octx->outer_context)
     if (octx->region_type == ORT_TARGET)
       {
-	n = splay_tree_lookup (octx->variables, (splay_tree_key)decl);
-	if (n == NULL)
+    n = octx->variables->find(decl);
+    if (n == octx->variables->end())
 	  {
 	    error ("threadprivate variable %qE used in target region",
 		   DECL_NAME (decl));
 	    error_at (octx->location, "enclosing target region");
-	    splay_tree_insert (octx->variables, (splay_tree_key)decl, 0);
+        (*octx->variables)[decl] = 0;
 	  }
 	if (decl2)
-	  splay_tree_insert (octx->variables, (splay_tree_key)decl2, 0);
+      (*octx->variables)[decl2] = 0;
       }
 
   if (ctx->region_type != ORT_UNTIED_TASK)
     return false;
-  n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
-  if (n == NULL)
+  n = ctx->variables->find(decl);
+  if (n == ctx->variables->end())
     {
       error ("threadprivate variable %qE used in untied task",
 	     DECL_NAME (decl));
       error_at (ctx->location, "enclosing task");
-      splay_tree_insert (ctx->variables, (splay_tree_key)decl, 0);
+      (*ctx->variables)[decl] = 0;
     }
   if (decl2)
-    splay_tree_insert (ctx->variables, (splay_tree_key)decl2, 0);
+    (*ctx->variables)[decl2] = 0;
   return false;
 }
 
@@ -5762,7 +5765,7 @@ omp_notice_threadprivate_variable (struct gimplify_omp_ctx *ctx, tree decl,
 static bool
 omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 {
-  splay_tree_node n;
+  gimplify_tree_t::iterator n;
   unsigned flags = in_code ? GOVD_SEEN : 0;
   bool ret = false, shared;
 
@@ -5784,11 +5787,11 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 	}
     }
 
-  n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
+  n = ctx->variables->find(decl);
   if (ctx->region_type == ORT_TARGET)
     {
       ret = lang_hooks.decls.omp_disregard_value_expr (decl, true);
-      if (n == NULL)
+      if (n == ctx->variables->end())
 	{
 	  if (!lang_hooks.types.omp_mappable_type (TREE_TYPE (decl)))
 	    {
@@ -5801,15 +5804,16 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 	}
       else
 	{
+      unsigned &value = n->second;
 	  /* If nothing changed, there's nothing left to do.  */
-	  if ((n->value & flags) == flags)
+      if ((value & flags) == flags)
 	    return ret;
-	  n->value |= flags;
+      value |= flags;
 	}
       goto do_outer;
     }
 
-  if (n == NULL)
+  if (n == ctx->variables->end())
     {
       enum omp_clause_default_kind default_kind, kind;
       struct gimplify_omp_ctx *octx;
@@ -5867,12 +5871,12 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 	    omp_notice_variable (ctx->outer_context, decl, in_code);
 	  for (octx = ctx->outer_context; octx; octx = octx->outer_context)
 	    {
-	      splay_tree_node n2;
-
+          gimplify_tree_t::iterator n2;
 	      if ((octx->region_type & (ORT_TARGET_DATA | ORT_TARGET)) != 0)
 		continue;
-	      n2 = splay_tree_lookup (octx->variables, (splay_tree_key) decl);
-	      if (n2 && (n2->value & GOVD_DATA_SHARE_CLASS) != GOVD_SHARED)
+          n2 = octx->variables->find(decl);
+          if (n2 != octx->variables->end() &&
+              (n2->second & GOVD_DATA_SHARE_CLASS) != GOVD_SHARED)
 		{
 		  flags |= GOVD_FIRSTPRIVATE;
 		  break;
@@ -5907,28 +5911,29 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
       goto do_outer;
     }
 
-  if ((n->value & (GOVD_SEEN | GOVD_LOCAL)) == 0
+  if ((n->second & (GOVD_SEEN | GOVD_LOCAL)) == 0
       && (flags & (GOVD_SEEN | GOVD_LOCAL)) == GOVD_SEEN
       && DECL_SIZE (decl)
       && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
     {
-      splay_tree_node n2;
+      gimplify_tree_t::iterator n2;
       tree t = DECL_VALUE_EXPR (decl);
       gcc_assert (TREE_CODE (t) == INDIRECT_REF);
       t = TREE_OPERAND (t, 0);
       gcc_assert (DECL_P (t));
-      n2 = splay_tree_lookup (ctx->variables, (splay_tree_key) t);
-      n2->value |= GOVD_SEEN;
+      n2 = ctx->variables->find(t);
+      gcc_assert(n2 != ctx->variables->end());
+      n2->second |= GOVD_SEEN;
     }
 
-  shared = ((flags | n->value) & GOVD_SHARED) != 0;
+  shared = ((flags | n->second) & GOVD_SHARED) != 0;
   ret = lang_hooks.decls.omp_disregard_value_expr (decl, shared);
 
   /* If nothing changed, there's nothing left to do.  */
-  if ((n->value & flags) == flags)
+  if ((n->second & flags) == flags)
     return ret;
-  flags |= n->value;
-  n->value = flags;
+  flags |= n->second;
+  n->second = flags;
 
  do_outer:
   /* If the variable is private in the current context, then we don't
@@ -5947,12 +5952,13 @@ omp_notice_variable (struct gimplify_omp_ctx *ctx, tree decl, bool in_code)
 static bool
 omp_is_private (struct gimplify_omp_ctx *ctx, tree decl, int simd)
 {
-  splay_tree_node n;
+  gimplify_tree_t::iterator n;
 
-  n = splay_tree_lookup (ctx->variables, (splay_tree_key)decl);
-  if (n != NULL)
+  n = ctx->variables->find(decl);
+  if (n != ctx->variables->end())
     {
-      if (n->value & GOVD_SHARED)
+      unsigned &n_value = n->second;
+      if (n_value & GOVD_SHARED)
 	{
 	  if (ctx == gimplify_omp_ctxp)
 	    {
@@ -5962,30 +5968,30 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl, int simd)
 	      else
 		error ("iteration variable %qE should be private",
 		       DECL_NAME (decl));
-	      n->value = GOVD_PRIVATE;
+          n_value = GOVD_PRIVATE;
 	      return true;
 	    }
 	  else
 	    return false;
 	}
-      else if ((n->value & GOVD_EXPLICIT) != 0
+      else if ((n_value & GOVD_EXPLICIT) != 0
 	       && (ctx == gimplify_omp_ctxp
 		   || (ctx->region_type == ORT_COMBINED_PARALLEL
 		       && gimplify_omp_ctxp->outer_context == ctx)))
 	{
-	  if ((n->value & GOVD_FIRSTPRIVATE) != 0)
+      if ((n_value & GOVD_FIRSTPRIVATE) != 0)
 	    error ("iteration variable %qE should not be firstprivate",
 		   DECL_NAME (decl));
-	  else if ((n->value & GOVD_REDUCTION) != 0)
+      else if ((n_value & GOVD_REDUCTION) != 0)
 	    error ("iteration variable %qE should not be reduction",
 		   DECL_NAME (decl));
-	  else if (simd == 1 && (n->value & GOVD_LASTPRIVATE) != 0)
+      else if (simd == 1 && (n_value & GOVD_LASTPRIVATE) != 0)
 	    error ("iteration variable %qE should not be lastprivate",
 		   DECL_NAME (decl));
-	  else if (simd && (n->value & GOVD_PRIVATE) != 0)
+      else if (simd && (n_value & GOVD_PRIVATE) != 0)
 	    error ("iteration variable %qE should not be private",
 		   DECL_NAME (decl));
-	  else if (simd == 2 && (n->value & GOVD_LINEAR) != 0)
+      else if (simd == 2 && (n_value & GOVD_LINEAR) != 0)
 	    error ("iteration variable %qE is predetermined linear",
 		   DECL_NAME (decl));
 	}
@@ -6009,7 +6015,7 @@ omp_is_private (struct gimplify_omp_ctx *ctx, tree decl, int simd)
 static bool
 omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate)
 {
-  splay_tree_node n;
+  gimplify_tree_t::iterator n;
 
   do
     {
@@ -6025,9 +6031,9 @@ omp_check_private (struct gimplify_omp_ctx *ctx, tree decl, bool copyprivate)
       if ((ctx->region_type & (ORT_TARGET | ORT_TARGET_DATA)) != 0)
 	continue;
 
-      n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
-      if (n != NULL)
-	return (n->value & GOVD_SHARED) == 0;
+      n = ctx->variables->find(decl);
+      if (n != ctx->variables->end())
+    return (n->second & GOVD_SHARED) == 0;
     }
   while (ctx->region_type == ORT_WORKSHARE
 	 || ctx->region_type == ORT_SIMD);
@@ -6390,13 +6396,14 @@ struct gimplify_adjust_omp_clauses_data
    remove PRIVATE, SHARED, and FIRSTPRIVATE clauses.  */
 
 static int
-gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
+gimplify_adjust_omp_clauses_1 (std::pair<tree, unsigned> n,
+                               gimplify_adjust_omp_clauses_data *data)
 {
   tree *list_p = ((struct gimplify_adjust_omp_clauses_data *) data)->list_p;
   gimple_seq *pre_p
     = ((struct gimplify_adjust_omp_clauses_data *) data)->pre_p;
-  tree decl = (tree) n->key;
-  unsigned flags = n->value;
+  tree decl = n.first;
+  unsigned flags = n.second;
   enum omp_clause_code code;
   tree clause;
   bool private_debug;
@@ -6427,11 +6434,11 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data)
 	  struct gimplify_omp_ctx *ctx = gimplify_omp_ctxp->outer_context;
 	  while (ctx != NULL)
 	    {
-	      splay_tree_node on
-		= splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
-	      if (on && (on->value & (GOVD_FIRSTPRIVATE | GOVD_LASTPRIVATE
-				      | GOVD_PRIVATE | GOVD_REDUCTION
-				      | GOVD_LINEAR | GOVD_MAP)) != 0)
+          gimplify_tree_t::iterator on = ctx->variables->find(decl);
+          if ((on != ctx->variables->end()) &&
+              (on->second & (GOVD_FIRSTPRIVATE | GOVD_LASTPRIVATE
+                             | GOVD_PRIVATE | GOVD_REDUCTION
+                             | GOVD_LINEAR | GOVD_MAP)) != 0)
 		break;
 	      ctx = ctx->outer_context;
 	    }
@@ -6519,7 +6526,8 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
 
   while ((c = *list_p) != NULL)
     {
-      splay_tree_node n;
+      gimplify_tree_t::iterator n;
+
       bool remove = false;
 
       switch (OMP_CLAUSE_CODE (c))
@@ -6529,16 +6537,17 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
 	case OMP_CLAUSE_FIRSTPRIVATE:
 	case OMP_CLAUSE_LINEAR:
 	  decl = OMP_CLAUSE_DECL (c);
-	  n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
-	  remove = !(n->value & GOVD_SEEN);
+      n = ctx->variables->find(decl);
+      gcc_assert(n != ctx->variables->end());
+      remove = !(n->second & GOVD_SEEN);
 	  if (! remove)
 	    {
 	      bool shared = OMP_CLAUSE_CODE (c) == OMP_CLAUSE_SHARED;
-	      if ((n->value & GOVD_DEBUG_PRIVATE)
+          if ((n->second & GOVD_DEBUG_PRIVATE)
 		  || lang_hooks.decls.omp_private_debug_clause (decl, shared))
 		{
-		  gcc_assert ((n->value & GOVD_DEBUG_PRIVATE) == 0
-			      || ((n->value & GOVD_DATA_SHARE_CLASS)
+          gcc_assert ((n->second & GOVD_DEBUG_PRIVATE) == 0
+                  || ((n->second & GOVD_DATA_SHARE_CLASS)
 				  == GOVD_PRIVATE));
 		  OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_PRIVATE);
 		  OMP_CLAUSE_PRIVATE_DEBUG (c) = 1;
@@ -6550,22 +6559,23 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
 		{
 		  if (ctx->outer_context->combined_loop
 		      && !OMP_CLAUSE_LINEAR_NO_COPYIN (c))
-		    {
-		      n = splay_tree_lookup (ctx->outer_context->variables,
-					     (splay_tree_key) decl);
-		      if (n == NULL
-			  || (n->value & GOVD_DATA_SHARE_CLASS) == 0)
+            {
+          gimplify_tree_t::iterator n2;
+          gimplify_omp_ctx *octx = ctx->outer_context;
+              n2 = octx->variables->find(decl);
+              if (n2 == octx->variables->end()
+              || (n2->second & GOVD_DATA_SHARE_CLASS) == 0)
 			{
 			  int flags = GOVD_FIRSTPRIVATE;
 			  /* #pragma omp distribute does not allow
 			     lastprivate clause.  */
 			  if (!ctx->outer_context->distribute)
 			    flags |= GOVD_LASTPRIVATE;
-			  if (n == NULL)
+              if (n2 == octx->variables->end())
 			    omp_add_variable (ctx->outer_context, decl,
 					      flags | GOVD_SEEN);
 			  else
-			    n->value |= flags | GOVD_SEEN;
+                n2->second |= flags | GOVD_SEEN;
 			}
 		    }
 		  else if (!is_global_var (decl))
@@ -6578,38 +6588,38 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
 	  /* Make sure OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE is set to
 	     accurately reflect the presence of a FIRSTPRIVATE clause.  */
 	  decl = OMP_CLAUSE_DECL (c);
-	  n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
+      n = ctx->variables->find(decl);
+      gcc_assert(n != ctx->variables->end());
 	  OMP_CLAUSE_LASTPRIVATE_FIRSTPRIVATE (c)
-	    = (n->value & GOVD_FIRSTPRIVATE) != 0;
+        = (n->second & GOVD_FIRSTPRIVATE) != 0;
 	  break;
 
 	case OMP_CLAUSE_ALIGNED:
 	  decl = OMP_CLAUSE_DECL (c);
 	  if (!is_global_var (decl))
 	    {
-	      n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
-	      remove = n == NULL || !(n->value & GOVD_SEEN);
+          n = ctx->variables->find(decl);
+          remove = n == ctx->variables->end() || !(n->second & GOVD_SEEN);
 	      if (!remove && TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE)
 		{
 		  struct gimplify_omp_ctx *octx;
-		  if (n != NULL
-		      && (n->value & (GOVD_DATA_SHARE_CLASS
+          if (n != ctx->variables->end()
+              && (n->second & (GOVD_DATA_SHARE_CLASS
 				      & ~GOVD_FIRSTPRIVATE)))
 		    remove = true;
 		  else
 		    for (octx = ctx->outer_context; octx;
 			 octx = octx->outer_context)
 		      {
-			n = splay_tree_lookup (octx->variables,
-					       (splay_tree_key) decl);
-			if (n == NULL)
+            n = octx->variables->find(decl);
+            if (n == octx->variables->end())
 			  continue;
-			if (n->value & GOVD_LOCAL)
+            if (n->second & GOVD_LOCAL)
 			  break;
 			/* We have to avoid assigning a shared variable
 			   to itself when trying to add
 			   __builtin_assume_aligned.  */
-			if (n->value & GOVD_SHARED)
+            if (n->second & GOVD_SHARED)
 			  {
 			    remove = true;
 			    break;
@@ -6619,8 +6629,8 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
 	    }
 	  else if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
 	    {
-	      n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
-	      if (n != NULL && (n->value & GOVD_DATA_SHARE_CLASS) != 0)
+          n = ctx->variables->find(decl);
+          if (n != ctx->variables->end() && (n->second & GOVD_DATA_SHARE_CLASS) != 0)
 		remove = true;
 	    }
 	  break;
@@ -6629,8 +6639,9 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
 	  decl = OMP_CLAUSE_DECL (c);
 	  if (!DECL_P (decl))
 	    break;
-	  n = splay_tree_lookup (ctx->variables, (splay_tree_key) decl);
-	  if (ctx->region_type == ORT_TARGET && !(n->value & GOVD_SEEN))
+      n = ctx->variables->find(decl);
+      gcc_assert(n != ctx->variables->end());
+      if (ctx->region_type == ORT_TARGET && !(n->second & GOVD_SEEN))
 	    remove = true;
 	  else if (DECL_SIZE (decl)
 		   && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST
@@ -6744,7 +6755,10 @@ gimplify_adjust_omp_clauses (gimple_seq *pre_p, tree *list_p)
   struct gimplify_adjust_omp_clauses_data data;
   data.list_p = list_p;
   data.pre_p = pre_p;
-  splay_tree_foreach (ctx->variables, gimplify_adjust_omp_clauses_1, &data);
+  for (typename gimplify_tree_t::iterator it = ctx->variables->begin(),
+       ie = ctx->variables->end(); it != ie; ++it) {
+    gimplify_adjust_omp_clauses_1(*it, &data);
+  }
 
   gimplify_omp_ctxp = ctx->outer_context;
   delete_omp_context (ctx);
@@ -6957,13 +6971,12 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
       if (orig_for_stmt != for_stmt)
 	/* Do this only on innermost construct for combined ones.  */;
       else if (simd)
-	{
-	  splay_tree_node n = splay_tree_lookup (gimplify_omp_ctxp->variables,
-						 (splay_tree_key)decl);
+    {
+      gimplify_tree_t::iterator n = gimplify_omp_ctxp->variables->find(decl);
 	  omp_is_private (gimplify_omp_ctxp, decl,
 			  1 + (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt))
 			       != 1));
-	  if (n != NULL && (n->value & GOVD_DATA_SHARE_CLASS) != 0)
+      if (n != gimplify_omp_ctxp->variables->end() && (n->second & GOVD_DATA_SHARE_CLASS) != 0)
 	    omp_notice_variable (gimplify_omp_ctxp, decl, true);
 	  else if (TREE_VEC_LENGTH (OMP_FOR_INIT (for_stmt)) == 1)
 	    {
@@ -6992,10 +7005,9 @@ gimplify_omp_for (tree *expr_p, gimple_seq *pre_p)
 		{
 		  struct gimplify_omp_ctx *outer
 		    = gimplify_omp_ctxp->outer_context;
-		  n = splay_tree_lookup (outer->variables,
-					 (splay_tree_key) decl);
-		  if (n != NULL
-		      && (n->value & GOVD_DATA_SHARE_CLASS) == GOVD_LOCAL)
+          n = outer->variables->find(decl);
+          if (n != outer->variables->end()
+              && (n->second & GOVD_DATA_SHARE_CLASS) == GOVD_LOCAL)
 		    lastprivate = false;
 		  else if (omp_check_private (outer, decl, false))
 		    error ("lastprivate variable %qE is private in outer "
