|
From: <sv...@va...> - 2008-04-16 11:51:39
|
Author: sewardj
Date: 2008-04-16 12:51:42 +0100 (Wed, 16 Apr 2008)
New Revision: 7881
Log:
Make two different sets of MC_(helperc_value_check{1,2,4,8,N}_fail)
functions, one for use with origin tracking and one without. They
appear frequently in the generated code, and, in the
non-origin-tracking case, the need to pass a dummy zero origin
argument increases the size of the generated code by 4%, for no
purpose.
Modified:
branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_include.h
branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_main.c
branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_translate.c
Modified: branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_include.h
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_include.h 2008-04-15 21:21:02 UTC (rev 7880)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_include.h 2008-04-16 11:51:42 UTC (rev 7881)
@@ -319,12 +319,26 @@
/*------------------------------------------------------------*/
/* Functions defined in mc_main.c */
-extern VG_REGPARM(2) void MC_(helperc_complain_undef) ( HWord, UWord );
-extern VG_REGPARM(1) void MC_(helperc_value_check8_fail) ( UWord );
-extern VG_REGPARM(1) void MC_(helperc_value_check4_fail) ( UWord );
-extern VG_REGPARM(1) void MC_(helperc_value_check1_fail) ( UWord );
-extern VG_REGPARM(1) void MC_(helperc_value_check0_fail) ( UWord );
+/* For the fail_w_o functions, the UWord arg is actually the 32-bit
+ origin tag and should really be UInt, but to be simple and safe
+ considering it's called from generated code, just claim it to be a
+ UWord. */
+extern VG_REGPARM(2) void MC_(helperc_value_checkN_fail_w_o) ( HWord, UWord );
+extern VG_REGPARM(1) void MC_(helperc_value_check8_fail_w_o) ( UWord );
+extern VG_REGPARM(1) void MC_(helperc_value_check4_fail_w_o) ( UWord );
+extern VG_REGPARM(1) void MC_(helperc_value_check1_fail_w_o) ( UWord );
+extern VG_REGPARM(1) void MC_(helperc_value_check0_fail_w_o) ( UWord );
+
+/* And call these ones instead to report an uninitialised value error
+ but with no origin available. */
+extern VG_REGPARM(1) void MC_(helperc_value_checkN_fail_no_o) ( HWord );
+extern VG_REGPARM(0) void MC_(helperc_value_check8_fail_no_o) ( void );
+extern VG_REGPARM(0) void MC_(helperc_value_check4_fail_no_o) ( void );
+extern VG_REGPARM(0) void MC_(helperc_value_check1_fail_no_o) ( void );
+extern VG_REGPARM(0) void MC_(helperc_value_check0_fail_no_o) ( void );
+
+/* V-bits load/store helpers */
extern VG_REGPARM(1) void MC_(helperc_STOREV64be) ( Addr, ULong );
extern VG_REGPARM(1) void MC_(helperc_STOREV64le) ( Addr, ULong );
extern VG_REGPARM(2) void MC_(helperc_STOREV32be) ( Addr, UWord );
@@ -344,6 +358,7 @@
extern void MC_(helperc_MAKE_STACK_UNINIT) ( Addr base, UWord len,
Addr nia );
+/* Origin tag load/store helpers */
VG_REGPARM(2) void MC_(helperc_b_store1) ( Addr a, UWord d32 );
VG_REGPARM(2) void MC_(helperc_b_store2) ( Addr a, UWord d32 );
VG_REGPARM(2) void MC_(helperc_b_store4) ( Addr a, UWord d32 );
Modified: branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_main.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_main.c 2008-04-15 21:21:02 UTC (rev 7880)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_main.c 2008-04-16 11:51:42 UTC (rev 7881)
@@ -4740,33 +4740,60 @@
/*--- Value-check failure handlers. ---*/
/*------------------------------------------------------------*/
-VG_REGPARM(1) void MC_(helperc_value_check0_fail) ( UWord origin )
-{
- mc_record_cond_error ( VG_(get_running_tid)(), (UInt)origin );
+/* Call these ones when an origin is available ... */
+VG_REGPARM(1)
+void MC_(helperc_value_check0_fail_w_o) ( UWord origin ) {
+ mc_record_cond_error ( VG_(get_running_tid)(), (UInt)origin );
}
-VG_REGPARM(1) void MC_(helperc_value_check1_fail) ( UWord origin )
-{
- mc_record_value_error ( VG_(get_running_tid)(), 1, (UInt)origin );
+VG_REGPARM(1)
+void MC_(helperc_value_check1_fail_w_o) ( UWord origin ) {
+ mc_record_value_error ( VG_(get_running_tid)(), 1, (UInt)origin );
}
-VG_REGPARM(1) void MC_(helperc_value_check4_fail) ( UWord origin )
-{
- mc_record_value_error ( VG_(get_running_tid)(), 4, (UInt)origin );
+VG_REGPARM(1)
+void MC_(helperc_value_check4_fail_w_o) ( UWord origin ) {
+ mc_record_value_error ( VG_(get_running_tid)(), 4, (UInt)origin );
}
-VG_REGPARM(1) void MC_(helperc_value_check8_fail) ( UWord origin )
-{
- mc_record_value_error ( VG_(get_running_tid)(), 8, (UInt)origin );
+VG_REGPARM(1)
+void MC_(helperc_value_check8_fail_w_o) ( UWord origin ) {
+ mc_record_value_error ( VG_(get_running_tid)(), 8, (UInt)origin );
}
VG_REGPARM(2)
-void MC_(helperc_complain_undef) ( HWord sz, UWord origin )
-{
- mc_record_value_error ( VG_(get_running_tid)(), (Int)sz, (UInt)origin );
+void MC_(helperc_value_checkN_fail_w_o) ( HWord sz, UWord origin ) {
+ mc_record_value_error ( VG_(get_running_tid)(), (Int)sz, (UInt)origin );
}
+/* ... and these when an origin isn't available. */
+VG_REGPARM(0)
+void MC_(helperc_value_check0_fail_no_o) ( void ) {
+ mc_record_cond_error ( VG_(get_running_tid)(), 0/*origin*/ );
+}
+
+VG_REGPARM(0)
+void MC_(helperc_value_check1_fail_no_o) ( void ) {
+ mc_record_value_error ( VG_(get_running_tid)(), 1, 0/*origin*/ );
+}
+
+VG_REGPARM(0)
+void MC_(helperc_value_check4_fail_no_o) ( void ) {
+ mc_record_value_error ( VG_(get_running_tid)(), 4, 0/*origin*/ );
+}
+
+VG_REGPARM(0)
+void MC_(helperc_value_check8_fail_no_o) ( void ) {
+ mc_record_value_error ( VG_(get_running_tid)(), 8, 0/*origin*/ );
+}
+
+VG_REGPARM(1)
+void MC_(helperc_value_checkN_fail_no_o) ( HWord sz ) {
+ mc_record_value_error ( VG_(get_running_tid)(), (Int)sz, 0/*origin*/ );
+}
+
+
/*------------------------------------------------------------*/
/*--- Metadata get/set functions, for client requests. ---*/
/*------------------------------------------------------------*/
Modified: branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_translate.c
===================================================================
--- branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_translate.c 2008-04-15 21:21:02 UTC (rev 7880)
+++ branches/OTRACK_BY_INSTRUMENTATION/memcheck/mc_translate.c 2008-04-16 11:51:42 UTC (rev 7881)
@@ -901,6 +901,10 @@
IRDirty* di;
IRAtom* cond;
IRAtom* origin;
+ void* fn;
+ HChar* nm;
+ IRExpr** args;
+ Int nargs;
// Don't do V bit tests if we're not reporting undefined value errors.
if (MC_(clo_mc_level) == 1)
@@ -932,51 +936,91 @@
origin = assignNew( 'B', mce, Ity_I64, unop(Iop_32Uto64, origin) );
}
} else {
- origin = mce->hWordTy == Ity_I64 ? mkU64(0) : mkU32(0);
+ origin = NULL;
}
+ fn = NULL;
+ nm = NULL;
+ args = NULL;
+ nargs = -1;
+
switch (sz) {
case 0:
- di = unsafeIRDirty_0_N(
- 1/*regparms*/,
- "MC_(helperc_value_check0_fail)",
- VG_(fnptr_to_fnentry)( &MC_(helperc_value_check0_fail) ),
- mkIRExprVec_1(origin)
- );
+ if (origin) {
+ fn = &MC_(helperc_value_check0_fail_w_o);
+ nm = "MC_(helperc_value_check0_fail_w_o)";
+ args = mkIRExprVec_1(origin);
+ nargs = 1;
+ } else {
+ fn = &MC_(helperc_value_check0_fail_no_o);
+ nm = "MC_(helperc_value_check0_fail_no_o)";
+ args = mkIRExprVec_0();
+ nargs = 0;
+ }
break;
case 1:
- di = unsafeIRDirty_0_N(
- 1/*regparms*/,
- "MC_(helperc_value_check1_fail)",
- VG_(fnptr_to_fnentry)( &MC_(helperc_value_check1_fail) ),
- mkIRExprVec_1(origin)
- );
+ if (origin) {
+ fn = &MC_(helperc_value_check1_fail_w_o);
+ nm = "MC_(helperc_value_check1_fail_w_o)";
+ args = mkIRExprVec_1(origin);
+ nargs = 1;
+ } else {
+ fn = &MC_(helperc_value_check1_fail_no_o);
+ nm = "MC_(helperc_value_check1_fail_no_o)";
+ args = mkIRExprVec_0();
+ nargs = 0;
+ }
break;
case 4:
- di = unsafeIRDirty_0_N(
- 1/*regparms*/,
- "MC_(helperc_value_check4_fail)",
- VG_(fnptr_to_fnentry)( &MC_(helperc_value_check4_fail) ),
- mkIRExprVec_1(origin)
- );
+ if (origin) {
+ fn = &MC_(helperc_value_check4_fail_w_o);
+ nm = "MC_(helperc_value_check4_fail_w_o)";
+ args = mkIRExprVec_1(origin);
+ nargs = 1;
+ } else {
+ fn = &MC_(helperc_value_check4_fail_no_o);
+ nm = "MC_(helperc_value_check4_fail_no_o)";
+ args = mkIRExprVec_0();
+ nargs = 0;
+ }
break;
case 8:
- di = unsafeIRDirty_0_N(
- 1/*regparms*/,
- "MC_(helperc_value_check8_fail)",
- VG_(fnptr_to_fnentry)( &MC_(helperc_value_check8_fail) ),
- mkIRExprVec_1(origin)
- );
+ if (origin) {
+ fn = &MC_(helperc_value_check8_fail_w_o);
+ nm = "MC_(helperc_value_check8_fail_w_o)";
+ args = mkIRExprVec_1(origin);
+ nargs = 1;
+ } else {
+ fn = &MC_(helperc_value_check8_fail_no_o);
+ nm = "MC_(helperc_value_check8_fail_no_o)";
+ args = mkIRExprVec_0();
+ nargs = 0;
+ }
break;
default:
- di = unsafeIRDirty_0_N(
- 2/*regparms*/,
- "MC_(helperc_complain_undef)",
- VG_(fnptr_to_fnentry)( &MC_(helperc_complain_undef) ),
- mkIRExprVec_2( mkIRExpr_HWord( sz ), origin )
- );
+ if (origin) {
+ fn = &MC_(helperc_value_checkN_fail_w_o);
+ nm = "MC_(helperc_value_checkN_fail_w_o)";
+ args = mkIRExprVec_2( mkIRExpr_HWord( sz ), origin);
+ nargs = 2;
+ } else {
+ fn = &MC_(helperc_value_checkN_fail_no_o);
+ nm = "MC_(helperc_value_checkN_fail_no_o)";
+ args = mkIRExprVec_1( mkIRExpr_HWord( sz ) );
+ nargs = 1;
+ }
break;
}
+
+ tl_assert(fn);
+ tl_assert(nm);
+ tl_assert(args);
+ tl_assert(nargs >= 0 && nargs <= 2);
+ tl_assert( (MC_(clo_mc_level) == 3 && origin != NULL)
+ || (MC_(clo_mc_level) == 2 && origin == NULL) );
+
+ di = unsafeIRDirty_0_N( nargs/*regparms*/, nm,
+ VG_(fnptr_to_fnentry)( fn ), args );
di->guard = cond;
setHelperAnns( mce, di );
stmt( 'V', mce, IRStmt_Dirty(di));
@@ -3225,39 +3269,6 @@
We call
void MC_(helperc_MAKE_STACK_UNINIT) ( Addr base, UWord len,
- UInt otag );
-*/
-#if 0
-static
-void do_AbiHint ( MCEnv* mce, IRExpr* base, Int len, Addr64 guest_IP )
-{
- IRDirty* di;
- /* This pretty much duplicates mk_otag_Expr in m_translate.c. Oh
- well. */
- UInt otag;
- ExeContext* ec
- = VG_(make_depth_1_ExeContext_from_Addr)( (Addr)guest_IP );
- tl_assert(ec);
- otag = VG_(get_ExeContext_uniq)( ec );
- tl_assert(otag > 0);
- /* Ok, we have an otag. */
-
- di = unsafeIRDirty_0_N(
- 0/*regparms*/,
- "MC_(helperc_MAKE_STACK_UNINIT)",
- VG_(fnptr_to_fnentry)( &MC_(helperc_MAKE_STACK_UNINIT) ),
- mkIRExprVec_3( base, mkIRExpr_HWord( (UInt)len),
- mkIRExpr_HWord( (HWord)otag ) )
- );
- stmt( 'V', mce, IRStmt_Dirty(di) );
-}
-#else
-/* We have an ABI hint telling us that [base .. base+len-1] is to
- become undefined ("writable"). Generate code to call a helper to
- notify the A/V bit machinery of this fact.
-
- We call
- void MC_(helperc_MAKE_STACK_UNINIT) ( Addr base, UWord len,
Addr nia );
*/
static
@@ -3272,7 +3283,6 @@
);
stmt( 'V', mce, IRStmt_Dirty(di) );
}
-#endif
/*------------------------------------------------------------*/
|