]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
x86/amd64 front ends: don't chase a conditional branch that leads
authorJulian Seward <jseward@acm.org>
Sun, 17 Jan 2010 15:47:01 +0000 (15:47 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 17 Jan 2010 15:47:01 +0000 (15:47 +0000)
back to the start of the trace.  It's better to leave the IR loop
unroller to handle such cases.

git-svn-id: svn://svn.valgrind.org/vex/trunk@1959

VEX/priv/guest_amd64_toIR.c
VEX/priv/guest_x86_toIR.c

index 0eba8f06a9829efd527907fad3d659db62199b4c..901792f4f253bbe07865eebf5acf75655a461171 100644 (file)
@@ -14007,12 +14007,15 @@ DisResult disInstr_AMD64_WRK (
       delta++;
       if (resteerCisOk
           && vex_control.guest_chase_cond
+          && (Addr64)d64 != (Addr64)guest_RIP_bbstart
           && jmpDelta < 0
           && resteerOkFn( callback_opaque, d64) ) {
          /* Speculation: assume this backward branch is taken.  So we
             need to emit a side-exit to the insn following this one,
             on the negation of the condition, and continue at the
-            branch target address (d64). */
+            branch target address (d64).  If we wind up back at the
+            first instruction of the trace, just stop; it's better to
+            let the IR loop unroller handle that case. */
          stmt( IRStmt_Exit( 
                   mk_amd64g_calculate_condition(
                      (AMD64Condcode)(1 ^ (opc - 0x70))),
@@ -14025,6 +14028,7 @@ DisResult disInstr_AMD64_WRK (
       else
       if (resteerCisOk
           && vex_control.guest_chase_cond
+          && (Addr64)d64 != (Addr64)guest_RIP_bbstart
           && jmpDelta >= 0
           && resteerOkFn( callback_opaque, guest_RIP_bbstart+delta ) ) {
          /* Speculation: assume this forward branch is not taken.  So
@@ -15843,12 +15847,15 @@ DisResult disInstr_AMD64_WRK (
          delta += 4;
          if (resteerCisOk
              && vex_control.guest_chase_cond
+             && (Addr64)d64 != (Addr64)guest_RIP_bbstart
              && jmpDelta < 0
              && resteerOkFn( callback_opaque, d64) ) {
             /* Speculation: assume this backward branch is taken.  So
                we need to emit a side-exit to the insn following this
                one, on the negation of the condition, and continue at
-               the branch target address (d64). */
+               the branch target address (d64).  If we wind up back at
+               the first instruction of the trace, just stop; it's
+               better to let the IR loop unroller handle that case. */
             stmt( IRStmt_Exit( 
                      mk_amd64g_calculate_condition(
                         (AMD64Condcode)(1 ^ (opc - 0x80))),
@@ -15861,6 +15868,7 @@ DisResult disInstr_AMD64_WRK (
          else
          if (resteerCisOk
              && vex_control.guest_chase_cond
+             && (Addr64)d64 != (Addr64)guest_RIP_bbstart
              && jmpDelta >= 0
              && resteerOkFn( callback_opaque, guest_RIP_bbstart+delta ) ) {
             /* Speculation: assume this forward branch is not taken.
@@ -15868,7 +15876,8 @@ DisResult disInstr_AMD64_WRK (
                continue disassembling at the insn immediately
                following this one. */
             stmt( IRStmt_Exit( 
-                     mk_amd64g_calculate_condition((AMD64Condcode)(opc - 0x80)),
+                     mk_amd64g_calculate_condition((AMD64Condcode)
+                                                   (opc - 0x80)),
                      Ijk_Boring,
                      IRConst_U64(d64) ) );
             dres.whatNext   = Dis_ResteerC;
index 7597b9eb5e7c4f02754b556170be23331ce7dc0b..edf4e338ab088d72cea4b9ddb8df751033755b63 100644 (file)
@@ -12933,12 +12933,15 @@ DisResult disInstr_X86_WRK (
       delta++;
       if (resteerCisOk
           && vex_control.guest_chase_cond
+          && (Addr32)d32 != (Addr32)guest_EIP_bbstart
           && jmpDelta < 0
           && resteerOkFn( callback_opaque, (Addr64)(Addr32)d32) ) {
          /* Speculation: assume this backward branch is taken.  So we
             need to emit a side-exit to the insn following this one,
             on the negation of the condition, and continue at the
-            branch target address (d32). */
+            branch target address (d32).  If we wind up back at the
+            first instruction of the trace, just stop; it's better to
+            let the IR loop unroller handle that case. */
          stmt( IRStmt_Exit( 
                   mk_x86g_calculate_condition((X86Condcode)(1 ^ (opc - 0x70))),
                   Ijk_Boring,
@@ -12950,6 +12953,7 @@ DisResult disInstr_X86_WRK (
       else
       if (resteerCisOk
           && vex_control.guest_chase_cond
+          && (Addr32)d32 != (Addr32)guest_EIP_bbstart
           && jmpDelta >= 0
           && resteerOkFn( callback_opaque, 
                           (Addr64)(Addr32)(guest_EIP_bbstart+delta)) ) {
@@ -14484,14 +14488,18 @@ DisResult disInstr_X86_WRK (
          delta += 4;
          if (resteerCisOk
              && vex_control.guest_chase_cond
+             && (Addr32)d32 != (Addr32)guest_EIP_bbstart
              && jmpDelta < 0
              && resteerOkFn( callback_opaque, (Addr64)(Addr32)d32) ) {
             /* Speculation: assume this backward branch is taken.  So
                we need to emit a side-exit to the insn following this
                one, on the negation of the condition, and continue at
-               the branch target address (d32). */
+               the branch target address (d32).  If we wind up back at
+               the first instruction of the trace, just stop; it's
+               better to let the IR loop unroller handle that case.*/
             stmt( IRStmt_Exit( 
-                     mk_x86g_calculate_condition((X86Condcode)(1 ^ (opc - 0x80))),
+                     mk_x86g_calculate_condition((X86Condcode)
+                                                 (1 ^ (opc - 0x80))),
                      Ijk_Boring,
                      IRConst_U32(guest_EIP_bbstart+delta) ) );
             dres.whatNext   = Dis_ResteerC;
@@ -14501,6 +14509,7 @@ DisResult disInstr_X86_WRK (
          else
          if (resteerCisOk
              && vex_control.guest_chase_cond
+             && (Addr32)d32 != (Addr32)guest_EIP_bbstart
              && jmpDelta >= 0
              && resteerOkFn( callback_opaque, 
                              (Addr64)(Addr32)(guest_EIP_bbstart+delta)) ) {