@@ -567,6 +567,7 @@ recording::context::context (context *parent_ctxt)
567567 m_last_error_str (NULL ),
568568 m_owns_last_error_str (false ),
569569 m_mementos (),
570+ m_type_mementos (),
570571 m_compound_types (),
571572 m_globals (),
572573 m_functions (),
@@ -616,6 +617,10 @@ recording::context::~context ()
616617 {
617618 delete m;
618619 }
620+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
621+ {
622+ delete m;
623+ }
619624
620625 for (i = 0 ; i < GCC_JIT_NUM_STR_OPTIONS; ++i)
621626 free (m_str_options[i]);
@@ -649,6 +654,14 @@ recording::context::record (memento *m)
649654 m_mementos.safe_push (m);
650655}
651656
657+ void
658+ recording::context::record_type (memento *m)
659+ {
660+ gcc_assert (m);
661+
662+ m_type_mementos.safe_push (m);
663+ }
664+
652665/* Replay this context (and any parents) into the given replayer. */
653666
654667void
@@ -680,6 +693,25 @@ recording::context::replay_into (replayer *r)
680693 return ;
681694
682695 /* Replay this context's saved operations into r. */
696+
697+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
698+ {
699+ /* Disabled low-level debugging, here if we need it: print what
700+ we're replaying.
701+ Note that the calls to get_debug_string might lead to more
702+ mementos being created for the strings.
703+ This can also be used to exercise the debug_string
704+ machinery. */
705+ if (0 )
706+ printf (" context %p replaying (%p): %s\n " ,
707+ (void *)this , (void *)m, m->get_debug_string ());
708+
709+ m->replay_into (r);
710+
711+ if (r->errors_occurred ())
712+ return ;
713+ }
714+
683715 FOR_EACH_VEC_ELT (m_mementos, i, m)
684716 {
685717 /* Disabled low-level debugging, here if we need it: print what
@@ -719,6 +751,11 @@ recording::context::disassociate_from_playback ()
719751 if (m_parent_ctxt)
720752 m_parent_ctxt->disassociate_from_playback ();
721753
754+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
755+ {
756+ m->set_playback_obj (NULL );
757+ }
758+
722759 FOR_EACH_VEC_ELT (m_mementos, i, m)
723760 {
724761 m->set_playback_obj (NULL );
@@ -784,7 +821,7 @@ recording::context::get_type (enum gcc_jit_types kind)
784821 else
785822 {
786823 recording::type *result = new memento_of_get_type (this , kind);
787- record (result);
824+ record_type (result);
788825 m_basic_types[kind] = result;
789826 }
790827 }
@@ -862,7 +899,7 @@ recording::context::new_array_type (recording::location *loc,
862899 }
863900 recording::type *result =
864901 new recording::array_type (this , loc, element_type, num_elements);
865- record (result);
902+ record_type (result);
866903 return result;
867904}
868905
@@ -879,7 +916,7 @@ recording::context::new_field (recording::location *loc,
879916{
880917 recording::field *result =
881918 new recording::field (this , loc, type, new_string (name));
882- record (result);
919+ record_type (result);
883920 return result;
884921}
885922
@@ -912,7 +949,7 @@ recording::context::new_struct_type (recording::location *loc,
912949 const char *name)
913950{
914951 recording::struct_ *result = new struct_ (this , loc, new_string (name));
915- record (result);
952+ record_type (result);
916953 m_compound_types.safe_push (result);
917954 return result;
918955}
@@ -928,7 +965,7 @@ recording::context::new_union_type (recording::location *loc,
928965 const char *name)
929966{
930967 recording::union_ *result = new union_ (this , loc, new_string (name));
931- record (result);
968+ record_type (result);
932969 m_compound_types.safe_push (result);
933970 return result;
934971}
@@ -952,7 +989,7 @@ recording::context::new_function_type (recording::type *return_type,
952989 param_types,
953990 is_variadic,
954991 is_target_builtin);
955- record (fn_type);
992+ record_type (fn_type);
956993 return fn_type;
957994}
958995
@@ -2178,6 +2215,8 @@ recording::context::dump_reproducer_to_file (const char *path)
21782215
21792216 r.write (" /* Replay of API calls for %s. */\n " ,
21802217 r.get_identifier (contexts[ctxt_idx]));
2218+ FOR_EACH_VEC_ELT (contexts[ctxt_idx]->m_type_mementos , i, m)
2219+ m->write_reproducer (r);
21812220 FOR_EACH_VEC_ELT (contexts[ctxt_idx]->m_mementos , i, m)
21822221 m->write_reproducer (r);
21832222 }
@@ -2480,7 +2519,7 @@ recording::type::get_pointer ()
24802519 if (!m_pointer_to_this_type)
24812520 {
24822521 m_pointer_to_this_type = new memento_of_get_pointer (this );
2483- m_ctxt->record (m_pointer_to_this_type);
2522+ m_ctxt->record_type (m_pointer_to_this_type);
24842523 }
24852524 return m_pointer_to_this_type;
24862525}
@@ -2494,7 +2533,7 @@ recording::type *
24942533recording::type::get_const ()
24952534{
24962535 recording::type *result = new memento_of_get_const (this );
2497- m_ctxt->record (result);
2536+ m_ctxt->record_type (result);
24982537 return result;
24992538}
25002539
@@ -2507,7 +2546,7 @@ recording::type *
25072546recording::type::get_restrict ()
25082547{
25092548 recording::type *result = new memento_of_get_restrict (this );
2510- m_ctxt->record (result);
2549+ m_ctxt->record_type (result);
25112550 return result;
25122551}
25132552
@@ -2520,7 +2559,7 @@ recording::type *
25202559recording::type::get_volatile ()
25212560{
25222561 recording::type *result = new memento_of_get_volatile (this );
2523- m_ctxt->record (result);
2562+ m_ctxt->record_type (result);
25242563 return result;
25252564}
25262565
@@ -2534,7 +2573,7 @@ recording::type::get_aligned (size_t alignment_in_bytes)
25342573{
25352574 recording::type *result
25362575 = new memento_of_get_aligned (this , alignment_in_bytes);
2537- m_ctxt->record (result);
2576+ m_ctxt->record_type (result);
25382577 return result;
25392578}
25402579
@@ -2554,7 +2593,7 @@ recording::type::get_vector (size_t num_units)
25542593{
25552594 recording::type *result
25562595 = new vector_type (this , num_units);
2557- m_ctxt->record (result);
2596+ m_ctxt->record_type (result);
25582597 return result;
25592598}
25602599
@@ -3816,7 +3855,7 @@ recording::compound_type::set_fields (location *loc,
38163855 gcc_assert (m_fields == NULL );
38173856
38183857 m_fields = new fields (this , num_fields, field_array);
3819- m_ctxt->record (m_fields);
3858+ m_ctxt->record_type (m_fields);
38203859}
38213860
38223861/* Implementation of pure virtual hook recording::type::dereference for
@@ -4063,6 +4102,13 @@ recording::rvalue::access_field (recording::location *loc,
40634102 return result;
40644103}
40654104
4105+ void
4106+ recording::rvalue::set_type (type *new_type)
4107+ {
4108+ gcc_assert (new_type);
4109+ m_type = new_type;
4110+ }
4111+
40664112/* Create a recording::dereference_field_rvalue instance and add it to
40674113 the rvalue's context's list of mementos.
40684114
0 commit comments