Skip to contentSkip to conversation

target-xtensa: fix search_pc for the last TB opcode

PATCH Superseded Max Filippov 2 participants 3 messages Dec 18, 2012 – Dec 19, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-xtensa: fix search_pc for the last TB opcode

Zero out tcg_ctx.gen_opc_instr_start for instructions representing the last guest opcode in the TB.

---
 target-xtensa/translate.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
target-xtensa/translate.c +7 -1
index 5d8762c..d109a08 100644
@@ -3005,7 +3005,13 @@ static void gen_intermediate_code_internal(
     gen_icount_end(tb, insn_count);
     *tcg_ctx.gen_opc_ptr = INDEX_op_end;
 
-    if (!search_pc) {
+    if (search_pc) {
+        j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
+        lj++;
+        while (lj <= j) {
+            tcg_ctx.gen_opc_instr_start[lj++] = 0;
+        }
+    } else {
         tb->size = dc.pc - pc_start;
         tb->icount = insn_count;
     }
Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 14 lines · Max Filippov

Zero out tcg_ctx.gen_opc_instr_start for instructions representing the last guest opcode in the TB.

---
 target-xtensa/translate.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
target-xtensa/translate.c +0 -0
index 5d8762c..d109a08 100644

target-xtensa/translate.c static void gen_intermediate_code_internal( · line 3013

Quoted 10 lines
target-xtensa/translate.c +6 -1
@@ -3005,7 +3005,13 @@ static void gen_intermediate_code_internal(
     gen_icount_end(tb, insn_count);
     *tcg_ctx.gen_opc_ptr = INDEX_op_end;
 
-    if (!search_pc) {
+    if (search_pc) {
+        j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
+        lj++;
+        while (lj <= j) {
+            tcg_ctx.gen_opc_instr_start[lj++] = 0;
+        }

Instead of the loop, how about something like memset(&tcg_ctx.gen_opc_instr_start[lj], 0, j - lj)?

Quoted 7 lines
target-xtensa/translate.c +1 -1
+    } else {
         tb->size = dc.pc - pc_start;
         tb->icount = insn_count;
     }
--

1.7.7.6

#2 lore raw
Quoted 18 lines · Blue Swirl
Quoted 17 lines · Max Filippov

Zero out tcg_ctx.gen_opc_instr_start for instructions representing the last guest opcode in the TB.

---
 target-xtensa/translate.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
target-xtensa/translate.c +0 -0
index 5d8762c..d109a08 100644
@@ -3005,7 +3005,13 @@ static void gen_intermediate_code_internal(
     gen_icount_end(tb, insn_count);
     *tcg_ctx.gen_opc_ptr = INDEX_op_end;
 
Quoted 10 lines

target-xtensa/translate.c static void gen_intermediate_code_internal( · line 3013

Quoted 7 lines
target-xtensa/translate.c +6 -1
-    if (!search_pc) {
+    if (search_pc) {
+        j = tcg_ctx.gen_opc_ptr - tcg_ctx.gen_opc_buf;
+        lj++;
+        while (lj <= j) {
+            tcg_ctx.gen_opc_instr_start[lj++] = 0;
+        }

Instead of the loop, how about something like memset(&tcg_ctx.gen_opc_instr_start[lj], 0, j - lj)?

Off by one, j - lj + 1.
Wanted to keep it looking as other instances, but can do it this way too.

Quoted 7 lines
Quoted 7 lines
target-xtensa/translate.c +1 -1
+    } else {
         tb->size = dc.pc - pc_start;
         tb->icount = insn_count;
     }
--

1.7.7.6

Signature · 2 lines
Thanks.
-- Max