diff mbox

[GOOGLE] Reset lambda scope information when popping module for LIPO

Message ID CAAe5K+Xdw2kDyvydirPyXU_-h-ZtF07w5cCu9BDOk0YcxcjidA@mail.gmail.com
State New
Headers show

Commit Message

Teresa Johnson Aug. 15, 2015, 6:13 a.m. UTC
This patch resets the lambda scope based sequence numbering used to assign
numbers to lambdas during parsing when we pop a module scope. This resets
the numbering for subsequent modules imported during LIPO compilation.

It also renames cp_clear_deferred_fns to reset_parsing_state, as that
routine now (and has for awhile) encompasses more than just deferred
function clearing.

Passes regression tests. Ok for google 4_9?

2015-08-14  Teresa Johnson  <tejohnson@google.com>

        Google ref b/23176787.
        * cp/cp-lang.c: Rename clear_deferred_fns to reset_parsing_state.
        * cp/cp-tree.h: Ditto, declare clear_lambda_scope.
        * cp/decl2.c (cp_reset_parsing_state): Ditto, call clear_lambda_scope.
        * cp/parser.c (clear_lambda_scope): New function.
        * l-ipo.c (pop_module_scope): Rename clear_deferred_fns to
        reset_parsing_state.
        * langhooks-def.h: Ditto.
        * langhooks.h: Ditto.

Comments

Xinliang David Li Aug. 15, 2015, 4:47 p.m. UTC | #1
ok.

David

On Fri, Aug 14, 2015 at 11:13 PM, Teresa Johnson <tejohnson@google.com> wrote:
> This patch resets the lambda scope based sequence numbering used to assign
> numbers to lambdas during parsing when we pop a module scope. This resets
> the numbering for subsequent modules imported during LIPO compilation.
>
> It also renames cp_clear_deferred_fns to reset_parsing_state, as that
> routine now (and has for awhile) encompasses more than just deferred
> function clearing.
>
> Passes regression tests. Ok for google 4_9?
>
> 2015-08-14  Teresa Johnson  <tejohnson@google.com>
>
>         Google ref b/23176787.
>         * cp/cp-lang.c: Rename clear_deferred_fns to reset_parsing_state.
>         * cp/cp-tree.h: Ditto, declare clear_lambda_scope.
>         * cp/decl2.c (cp_reset_parsing_state): Ditto, call clear_lambda_scope.
>         * cp/parser.c (clear_lambda_scope): New function.
>         * l-ipo.c (pop_module_scope): Rename clear_deferred_fns to
>         reset_parsing_state.
>         * langhooks-def.h: Ditto.
>         * langhooks.h: Ditto.
>
> Index: cp/cp-lang.c
> ===================================================================
> --- cp/cp-lang.c        (revision 226875)
> +++ cp/cp-lang.c        (working copy)
> @@ -109,8 +109,8 @@ static tree get_template_argument_pack_elems_folde
>  #define LANG_HOOKS_COPY_LANG_TYPE cp_lipo_copy_lang_type
>  #undef LANG_HOOKS_PROCESS_PENDING_DECLS
>  #define LANG_HOOKS_PROCESS_PENDING_DECLS cp_process_pending_declarations
> -#undef LANG_HOOKS_CLEAR_DEFFERED_FNS
> -#define LANG_HOOKS_CLEAR_DEFFERED_FNS cp_clear_deferred_fns
> +#undef LANG_HOOKS_RESET_PARSING_STATE
> +#define LANG_HOOKS_RESET_PARSING_STATE cp_reset_parsing_state
>  #undef LANG_HOOKS_IS_GENERATED_TYPE
>  #define LANG_HOOKS_IS_GENERATED_TYPE cp_is_compiler_generated_type
>  #undef LANG_HOOKS_CMP_LANG_TYPE
> Index: cp/cp-tree.h
> ===================================================================
> --- cp/cp-tree.h        (revision 226875)
> +++ cp/cp-tree.h        (working copy)
> @@ -4385,6 +4385,7 @@ extern int cp_unevaluated_operand;
>  extern tree cp_convert_range_for (tree, tree, tree, bool);
>  extern bool parsing_nsdmi (void);
>  extern void inject_this_parameter (tree, cp_cv_quals);
> +extern void clear_lambda_scope (void);
>
>  /* in pt.c  */
>
> @@ -5342,7 +5343,7 @@ extern void cplus_decl_attributes         (tree *, tree,
>  extern void finish_anon_union                  (tree);
>  extern void cp_write_global_declarations       (void);
>  extern void cp_process_pending_declarations     (location_t);
> -extern void cp_clear_deferred_fns               (void);
> +extern void cp_reset_parsing_state              (void);
>  extern void cp_clear_constexpr_hashtable        (void);
>  extern void cp_clear_conv_type_map              (void);
>  extern tree coerce_new_type                    (tree);
> Index: cp/decl2.c
> ===================================================================
> --- cp/decl2.c  (revision 226875)
> +++ cp/decl2.c  (working copy)
> @@ -4178,10 +4178,10 @@ no_linkage_error (tree decl)
>                "to declare function %q#D with linkage", t, decl);
>  }
>
> -/* Clear the list of deferred functions.  */
> +/* Reset the parsing state for the next module.  */
>
>  void
> -cp_clear_deferred_fns (void)
> +cp_reset_parsing_state (void)
>  {
>    vec_free (deferred_fns);
>    deferred_fns = NULL;
> @@ -4192,6 +4192,7 @@ void
>    clear_pending_templates ();
>    reset_anon_name ();
>    reset_temp_count ();
> +  clear_lambda_scope ();
>  }
>
>  /* Collect declarations from all namespaces relevant to SOURCE_FILE.  */
> Index: cp/parser.c
> ===================================================================
> --- cp/parser.c (revision 226875)
> +++ cp/parser.c (working copy)
> @@ -8705,6 +8705,16 @@ finish_lambda_scope (void)
>    lambda_scope_stack->pop ();
>  }
>
> +void
> +clear_lambda_scope (void)
> +{
> +  if (!lambda_scope_stack)
> +    return;
> +  gcc_assert(lambda_scope_stack->is_empty());
> +  lambda_scope = NULL_TREE;
> +  lambda_count = 0;
> +}
> +
>  /* Parse a lambda expression.
>
>     lambda-expression:
> Index: l-ipo.c
> ===================================================================
> --- l-ipo.c     (revision 226875)
> +++ l-ipo.c     (working copy)
> @@ -414,7 +414,7 @@ pop_module_scope (void)
>    at_eof = 1;
>    cgraph_process_same_body_aliases ();
>    lang_hooks.l_ipo.process_pending_decls (input_location);
> -  lang_hooks.l_ipo.clear_deferred_fns ();
> +  lang_hooks.l_ipo.reset_parsing_state ();
>    at_eof = 0;
>
>    is_last = is_last_module (current_module_id);
> Index: langhooks-def.h
> ===================================================================
> --- langhooks-def.h     (revision 226875)
> +++ langhooks-def.h     (working copy)
> @@ -214,7 +214,7 @@ extern tree lhd_make_node (enum tree_code);
>  #define LANG_HOOKS_DUP_LANG_TYPE lhd_do_nothing_t_t
>  #define LANG_HOOKS_COPY_LANG_TYPE lhd_do_nothing_t_t
>  #define LANG_HOOKS_PROCESS_PENDING_DECLS lhd_do_nothing_u
> -#define LANG_HOOKS_CLEAR_DEFFERED_FNS lhd_do_nothing
> +#define LANG_HOOKS_RESET_PARSING_STATE lhd_do_nothing
>  #define LANG_HOOKS_IS_GENERATED_TYPE lhd_do_nothing_t_return_bool
>  #define LANG_HOOKS_CMP_LANG_TYPE lhd_do_nothing_t_t_return_int
>
> @@ -231,7 +231,7 @@ extern tree lhd_make_node (enum tree_code);
>    LANG_HOOKS_DUP_LANG_TYPE, \
>    LANG_HOOKS_COPY_LANG_TYPE, \
>    LANG_HOOKS_PROCESS_PENDING_DECLS, \
> -  LANG_HOOKS_CLEAR_DEFFERED_FNS, \
> +  LANG_HOOKS_RESET_PARSING_STATE, \
>    LANG_HOOKS_IS_GENERATED_TYPE, \
>    LANG_HOOKS_CMP_LANG_TYPE,  \
>  }
> Index: langhooks.h
> ===================================================================
> --- langhooks.h (revision 226875)
> +++ langhooks.h (working copy)
> @@ -275,8 +275,8 @@ struct lang_hooks_for_lipo
>    /* Process decls after parsing of a source module.  */
>    void (*process_pending_decls) (unsigned);
>
> -  /* Clear the list of deferred functions.  */
> -  void (*clear_deferred_fns) (void);
> +  /* Reset the parsing state for the next module.  */
> +  void (*reset_parsing_state) (void);
>
>    /* Return true if T is compiler generated.  */
>    bool (*is_compiler_generated_type) (tree t);
>
>
> --
> Teresa Johnson | Software Engineer | tejohnson@google.com | 408-460-2413
diff mbox

Patch

Index: cp/cp-lang.c
===================================================================
--- cp/cp-lang.c        (revision 226875)
+++ cp/cp-lang.c        (working copy)
@@ -109,8 +109,8 @@  static tree get_template_argument_pack_elems_folde
 #define LANG_HOOKS_COPY_LANG_TYPE cp_lipo_copy_lang_type
 #undef LANG_HOOKS_PROCESS_PENDING_DECLS
 #define LANG_HOOKS_PROCESS_PENDING_DECLS cp_process_pending_declarations
-#undef LANG_HOOKS_CLEAR_DEFFERED_FNS
-#define LANG_HOOKS_CLEAR_DEFFERED_FNS cp_clear_deferred_fns
+#undef LANG_HOOKS_RESET_PARSING_STATE
+#define LANG_HOOKS_RESET_PARSING_STATE cp_reset_parsing_state
 #undef LANG_HOOKS_IS_GENERATED_TYPE
 #define LANG_HOOKS_IS_GENERATED_TYPE cp_is_compiler_generated_type
 #undef LANG_HOOKS_CMP_LANG_TYPE
Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h        (revision 226875)
+++ cp/cp-tree.h        (working copy)
@@ -4385,6 +4385,7 @@  extern int cp_unevaluated_operand;
 extern tree cp_convert_range_for (tree, tree, tree, bool);
 extern bool parsing_nsdmi (void);
 extern void inject_this_parameter (tree, cp_cv_quals);
+extern void clear_lambda_scope (void);

 /* in pt.c  */

@@ -5342,7 +5343,7 @@  extern void cplus_decl_attributes         (tree *, tree,
 extern void finish_anon_union                  (tree);
 extern void cp_write_global_declarations       (void);
 extern void cp_process_pending_declarations     (location_t);
-extern void cp_clear_deferred_fns               (void);
+extern void cp_reset_parsing_state              (void);
 extern void cp_clear_constexpr_hashtable        (void);
 extern void cp_clear_conv_type_map              (void);
 extern tree coerce_new_type                    (tree);
Index: cp/decl2.c
===================================================================
--- cp/decl2.c  (revision 226875)
+++ cp/decl2.c  (working copy)
@@ -4178,10 +4178,10 @@  no_linkage_error (tree decl)
               "to declare function %q#D with linkage", t, decl);
 }

-/* Clear the list of deferred functions.  */
+/* Reset the parsing state for the next module.  */

 void
-cp_clear_deferred_fns (void)
+cp_reset_parsing_state (void)
 {
   vec_free (deferred_fns);
   deferred_fns = NULL;
@@ -4192,6 +4192,7 @@  void
   clear_pending_templates ();
   reset_anon_name ();
   reset_temp_count ();
+  clear_lambda_scope ();
 }

 /* Collect declarations from all namespaces relevant to SOURCE_FILE.  */
Index: cp/parser.c
===================================================================
--- cp/parser.c (revision 226875)
+++ cp/parser.c (working copy)
@@ -8705,6 +8705,16 @@  finish_lambda_scope (void)
   lambda_scope_stack->pop ();
 }

+void
+clear_lambda_scope (void)
+{
+  if (!lambda_scope_stack)
+    return;
+  gcc_assert(lambda_scope_stack->is_empty());
+  lambda_scope = NULL_TREE;
+  lambda_count = 0;
+}
+
 /* Parse a lambda expression.

    lambda-expression:
Index: l-ipo.c
===================================================================
--- l-ipo.c     (revision 226875)
+++ l-ipo.c     (working copy)
@@ -414,7 +414,7 @@  pop_module_scope (void)
   at_eof = 1;
   cgraph_process_same_body_aliases ();
   lang_hooks.l_ipo.process_pending_decls (input_location);
-  lang_hooks.l_ipo.clear_deferred_fns ();
+  lang_hooks.l_ipo.reset_parsing_state ();
   at_eof = 0;

   is_last = is_last_module (current_module_id);
Index: langhooks-def.h
===================================================================
--- langhooks-def.h     (revision 226875)
+++ langhooks-def.h     (working copy)
@@ -214,7 +214,7 @@  extern tree lhd_make_node (enum tree_code);
 #define LANG_HOOKS_DUP_LANG_TYPE lhd_do_nothing_t_t
 #define LANG_HOOKS_COPY_LANG_TYPE lhd_do_nothing_t_t
 #define LANG_HOOKS_PROCESS_PENDING_DECLS lhd_do_nothing_u
-#define LANG_HOOKS_CLEAR_DEFFERED_FNS lhd_do_nothing
+#define LANG_HOOKS_RESET_PARSING_STATE lhd_do_nothing
 #define LANG_HOOKS_IS_GENERATED_TYPE lhd_do_nothing_t_return_bool
 #define LANG_HOOKS_CMP_LANG_TYPE lhd_do_nothing_t_t_return_int

@@ -231,7 +231,7 @@  extern tree lhd_make_node (enum tree_code);
   LANG_HOOKS_DUP_LANG_TYPE, \
   LANG_HOOKS_COPY_LANG_TYPE, \
   LANG_HOOKS_PROCESS_PENDING_DECLS, \
-  LANG_HOOKS_CLEAR_DEFFERED_FNS, \
+  LANG_HOOKS_RESET_PARSING_STATE, \
   LANG_HOOKS_IS_GENERATED_TYPE, \
   LANG_HOOKS_CMP_LANG_TYPE,  \
 }
Index: langhooks.h
===================================================================
--- langhooks.h (revision 226875)
+++ langhooks.h (working copy)
@@ -275,8 +275,8 @@  struct lang_hooks_for_lipo
   /* Process decls after parsing of a source module.  */
   void (*process_pending_decls) (unsigned);

-  /* Clear the list of deferred functions.  */
-  void (*clear_deferred_fns) (void);
+  /* Reset the parsing state for the next module.  */
+  void (*reset_parsing_state) (void);

   /* Return true if T is compiler generated.  */
   bool (*is_compiler_generated_type) (tree t);