Various plumbing to allow the optimiser (really, just a subset) to be
run post-instrumentation.
git-svn-id: svn://svn.valgrind.org/vex/trunk@492 8f6e269a-dfd6-0310-a8e1-e2731360e62c
diff --git a/priv/main/vex_main.c b/priv/main/vex_main.c
index e0b0983..2ba4e47 100644
--- a/priv/main/vex_main.c
+++ b/priv/main/vex_main.c
@@ -128,6 +128,7 @@
/* IN: optionally, two instrumentation functions. */
IRBB* (*instrument1) ( IRBB*, VexGuestLayout*, IRType hWordTy ),
IRBB* (*instrument2) ( IRBB*, VexGuestLayout*, IRType hWordTy ),
+ Bool cleanup_after_instrumentation,
/* IN: optionally, an access check function for guest code. */
Bool (*byte_accessible) ( Addr64 ),
/* IN: debug: trace vex activity at various points */
@@ -281,6 +282,22 @@
if (instrument1 || instrument2)
sanityCheckIRBB(irbb, guest_word_type);
+ /* Do a post-instrumentation cleanup pass. */
+ if (cleanup_after_instrumentation) {
+ do_deadcode_BB( irbb );
+ irbb = cprop_BB( irbb );
+ do_deadcode_BB( irbb );
+ sanityCheckIRBB(irbb, guest_word_type);
+ }
+
+ if (vex_traceflags & VEX_TRACE_OPT2) {
+ vex_printf("\n------------------------"
+ " After post-instr IR optimisation "
+ "------------------------\n\n");
+ ppIRBB ( irbb );
+ vex_printf("\n");
+ }
+
/* Turn it into virtual-registerised code. */
do_deadcode_BB( irbb );
do_treebuild_BB( irbb );