@@ -567,6 +567,7 @@ recording::context::context (context *parent_ctxt)
567
567
m_last_error_str (NULL ),
568
568
m_owns_last_error_str (false ),
569
569
m_mementos (),
570
+ m_type_mementos (),
570
571
m_compound_types (),
571
572
m_globals (),
572
573
m_functions (),
@@ -616,6 +617,10 @@ recording::context::~context ()
616
617
{
617
618
delete m;
618
619
}
620
+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
621
+ {
622
+ delete m;
623
+ }
619
624
620
625
for (i = 0 ; i < GCC_JIT_NUM_STR_OPTIONS; ++i)
621
626
free (m_str_options[i]);
@@ -649,6 +654,14 @@ recording::context::record (memento *m)
649
654
m_mementos.safe_push (m);
650
655
}
651
656
657
+ void
658
+ recording::context::record_type (memento *m)
659
+ {
660
+ gcc_assert (m);
661
+
662
+ m_type_mementos.safe_push (m);
663
+ }
664
+
652
665
/* Replay this context (and any parents) into the given replayer. */
653
666
654
667
void
@@ -680,6 +693,25 @@ recording::context::replay_into (replayer *r)
680
693
return ;
681
694
682
695
/* 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
+
683
715
FOR_EACH_VEC_ELT (m_mementos, i, m)
684
716
{
685
717
/* Disabled low-level debugging, here if we need it: print what
@@ -719,6 +751,11 @@ recording::context::disassociate_from_playback ()
719
751
if (m_parent_ctxt)
720
752
m_parent_ctxt->disassociate_from_playback ();
721
753
754
+ FOR_EACH_VEC_ELT (m_type_mementos, i, m)
755
+ {
756
+ m->set_playback_obj (NULL );
757
+ }
758
+
722
759
FOR_EACH_VEC_ELT (m_mementos, i, m)
723
760
{
724
761
m->set_playback_obj (NULL );
@@ -784,7 +821,7 @@ recording::context::get_type (enum gcc_jit_types kind)
784
821
else
785
822
{
786
823
recording::type *result = new memento_of_get_type (this , kind);
787
- record (result);
824
+ record_type (result);
788
825
m_basic_types[kind] = result;
789
826
}
790
827
}
@@ -862,7 +899,7 @@ recording::context::new_array_type (recording::location *loc,
862
899
}
863
900
recording::type *result =
864
901
new recording::array_type (this , loc, element_type, num_elements);
865
- record (result);
902
+ record_type (result);
866
903
return result;
867
904
}
868
905
@@ -879,7 +916,7 @@ recording::context::new_field (recording::location *loc,
879
916
{
880
917
recording::field *result =
881
918
new recording::field (this , loc, type, new_string (name));
882
- record (result);
919
+ record_type (result);
883
920
return result;
884
921
}
885
922
@@ -912,7 +949,7 @@ recording::context::new_struct_type (recording::location *loc,
912
949
const char *name)
913
950
{
914
951
recording::struct_ *result = new struct_ (this , loc, new_string (name));
915
- record (result);
952
+ record_type (result);
916
953
m_compound_types.safe_push (result);
917
954
return result;
918
955
}
@@ -928,7 +965,7 @@ recording::context::new_union_type (recording::location *loc,
928
965
const char *name)
929
966
{
930
967
recording::union_ *result = new union_ (this , loc, new_string (name));
931
- record (result);
968
+ record_type (result);
932
969
m_compound_types.safe_push (result);
933
970
return result;
934
971
}
@@ -952,7 +989,7 @@ recording::context::new_function_type (recording::type *return_type,
952
989
param_types,
953
990
is_variadic,
954
991
is_target_builtin);
955
- record (fn_type);
992
+ record_type (fn_type);
956
993
return fn_type;
957
994
}
958
995
@@ -2178,6 +2215,8 @@ recording::context::dump_reproducer_to_file (const char *path)
2178
2215
2179
2216
r.write (" /* Replay of API calls for %s. */\n " ,
2180
2217
r.get_identifier (contexts[ctxt_idx]));
2218
+ FOR_EACH_VEC_ELT (contexts[ctxt_idx]->m_type_mementos , i, m)
2219
+ m->write_reproducer (r);
2181
2220
FOR_EACH_VEC_ELT (contexts[ctxt_idx]->m_mementos , i, m)
2182
2221
m->write_reproducer (r);
2183
2222
}
@@ -2480,7 +2519,7 @@ recording::type::get_pointer ()
2480
2519
if (!m_pointer_to_this_type)
2481
2520
{
2482
2521
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);
2484
2523
}
2485
2524
return m_pointer_to_this_type;
2486
2525
}
@@ -2494,7 +2533,7 @@ recording::type *
2494
2533
recording::type::get_const ()
2495
2534
{
2496
2535
recording::type *result = new memento_of_get_const (this );
2497
- m_ctxt->record (result);
2536
+ m_ctxt->record_type (result);
2498
2537
return result;
2499
2538
}
2500
2539
@@ -2507,7 +2546,7 @@ recording::type *
2507
2546
recording::type::get_restrict ()
2508
2547
{
2509
2548
recording::type *result = new memento_of_get_restrict (this );
2510
- m_ctxt->record (result);
2549
+ m_ctxt->record_type (result);
2511
2550
return result;
2512
2551
}
2513
2552
@@ -2520,7 +2559,7 @@ recording::type *
2520
2559
recording::type::get_volatile ()
2521
2560
{
2522
2561
recording::type *result = new memento_of_get_volatile (this );
2523
- m_ctxt->record (result);
2562
+ m_ctxt->record_type (result);
2524
2563
return result;
2525
2564
}
2526
2565
@@ -2534,7 +2573,7 @@ recording::type::get_aligned (size_t alignment_in_bytes)
2534
2573
{
2535
2574
recording::type *result
2536
2575
= new memento_of_get_aligned (this , alignment_in_bytes);
2537
- m_ctxt->record (result);
2576
+ m_ctxt->record_type (result);
2538
2577
return result;
2539
2578
}
2540
2579
@@ -2554,7 +2593,7 @@ recording::type::get_vector (size_t num_units)
2554
2593
{
2555
2594
recording::type *result
2556
2595
= new vector_type (this , num_units);
2557
- m_ctxt->record (result);
2596
+ m_ctxt->record_type (result);
2558
2597
return result;
2559
2598
}
2560
2599
@@ -3816,7 +3855,7 @@ recording::compound_type::set_fields (location *loc,
3816
3855
gcc_assert (m_fields == NULL );
3817
3856
3818
3857
m_fields = new fields (this , num_fields, field_array);
3819
- m_ctxt->record (m_fields);
3858
+ m_ctxt->record_type (m_fields);
3820
3859
}
3821
3860
3822
3861
/* Implementation of pure virtual hook recording::type::dereference for
@@ -4063,6 +4102,13 @@ recording::rvalue::access_field (recording::location *loc,
4063
4102
return result;
4064
4103
}
4065
4104
4105
+ void
4106
+ recording::rvalue::set_type (type *new_type)
4107
+ {
4108
+ gcc_assert (new_type);
4109
+ m_type = new_type;
4110
+ }
4111
+
4066
4112
/* Create a recording::dereference_field_rvalue instance and add it to
4067
4113
the rvalue's context's list of mementos.
4068
4114
0 commit comments