From 4682dbc5e1d69564b9d698060c0e46150d786729 Mon Sep 17 00:00:00 2001 From: Julian Seward Date: Fri, 5 Aug 2016 15:02:48 +0000 Subject: [PATCH] Reduce the number of IR sanity checks from 4 per block to 2 per block. Also relax assertion checking in the register allocator. Together with valgrind r15927 this reduces per-block JITting cost by 10%-15%. git-svn-id: svn://svn.valgrind.org/vex/trunk@3239 --- VEX/priv/host_generic_reg_alloc2.c | 4 ++-- VEX/priv/main_main.c | 18 +++++++++++++----- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/VEX/priv/host_generic_reg_alloc2.c b/VEX/priv/host_generic_reg_alloc2.c index fd46486f86..3c0b8dbaba 100644 --- a/VEX/priv/host_generic_reg_alloc2.c +++ b/VEX/priv/host_generic_reg_alloc2.c @@ -993,13 +993,13 @@ HInstrArray* doRegisterAllocation ( /* ------------ Sanity checks ------------ */ /* Sanity checks are expensive. So they are done only once - every 13 instructions, and just before the last + every 17 instructions, and just before the last instruction. */ do_sanity_check = toBool( False /* Set to True for sanity checking of all insns. */ || ii == instrs_in->arr_used-1 - || (ii > 0 && (ii % 13) == 0) + || (ii > 0 && (ii % 17) == 0) ); if (do_sanity_check) { diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index 8fd2503bb0..e263754c6f 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -916,8 +916,13 @@ VexTranslateResult LibVEX_Translate ( VexTranslateArgs* vta ) irsb = do_iropt_BB ( irsb, specHelper, preciseMemExnsFn, pxControl, vta->guest_bytes_addr, vta->arch_guest ); - sanityCheckIRSB( irsb, "after initial iropt", - True/*must be flat*/, guest_word_type ); + + // JRS 2016 Aug 03: Sanity checking is expensive, we already checked + // the output of the front end, and iropt never screws up the IR by + // itself, unless it is being hacked on. So remove this post-iropt + // check in "production" use. + // sanityCheckIRSB( irsb, "after initial iropt", + // True/*must be flat*/, guest_word_type ); if (vex_traceflags & VEX_TRACE_OPT1) { vex_printf("\n------------------------" @@ -953,9 +958,12 @@ VexTranslateResult LibVEX_Translate ( VexTranslateArgs* vta ) vex_printf("\n"); } - if (vta->instrument1 || vta->instrument2) - sanityCheckIRSB( irsb, "after instrumentation", - True/*must be flat*/, guest_word_type ); + // JRS 2016 Aug 03: as above, this never actually fails in practice. + // And we'll sanity check anyway after the post-instrumentation + // cleanup pass. So skip this check in "production" use. + // if (vta->instrument1 || vta->instrument2) + // sanityCheckIRSB( irsb, "after instrumentation", + // True/*must be flat*/, guest_word_type ); /* Do a post-instrumentation cleanup pass. */ if (vta->instrument1 || vta->instrument2) { -- 2.47.2