diff --git a/coregrind/vg_instrument.c b/coregrind/vg_instrument.c index 80dd5f056..6bb425f92 100644 --- a/coregrind/vg_instrument.c +++ b/coregrind/vg_instrument.c @@ -84,6 +84,15 @@ void VG_(set_global_var)(UCodeBlock* cb, Addr globvar_ptr, UInt val) uInstr2(cb, STORE, 4, TempReg, t_val, TempReg, t_gv); } +void VG_(set_global_var_tempreg)(UCodeBlock* cb, Addr globvar_ptr, UInt t_val) +{ + Int t_gv = newTemp(cb); + + uInstr2(cb, MOV, 4, Literal, 0, TempReg, t_gv); + uLiteral(cb, globvar_ptr); + uInstr2(cb, STORE, 4, TempReg, t_val, TempReg, t_gv); +} + /*--------------------------------------------------------------------*/ /*--- end vg_instrument.c ---*/ /*--------------------------------------------------------------------*/ diff --git a/include/vg_skin.h b/include/vg_skin.h index 43702fa9b..44643941f 100644 --- a/include/vg_skin.h +++ b/include/vg_skin.h @@ -812,9 +812,13 @@ extern void VG_(call_helper_2_0) ( UCodeBlock* cb, Addr f, UInt arg1, UInt arg2, UInt regparms_n); /* One way around the 3-arg C function limit is to pass args via global - * variables... ugly, but it works. */ + * variables... ugly, but it works. This one puts a literal in there. */ extern void VG_(set_global_var) ( UCodeBlock* cb, Addr globvar_ptr, UInt val); +/* This one puts the contents of a TempReg in the global variable. */ +extern void VG_(set_global_var_tempreg) ( UCodeBlock* cb, Addr globvar_ptr, + UInt t_val); + /* ------------------------------------------------------------------ */ /* Allocating/freeing basic blocks of UCode */ extern UCodeBlock* VG_(setup_UCodeBlock) ( UCodeBlock* cb );