1
When allocating new temps during tcg_optmize, do not re-use
1
When allocating new temps during tcg_optmize, do not re-use
2
any EBB temps that were used within the TB. We do not have
2
any EBB temps that were used within the TB. We do not have
3
any idea what span of the TB in which the temp was live.
3
any idea what span of the TB in which the temp was live.
4
5
Introduce tcg_temp_ebb_reset_freed and use before tcg_optimize,
6
as well as replacing the equivalent in plugin_gen_inject and
7
tcg_func_start.
4
8
5
Cc: qemu-stable@nongnu.org
9
Cc: qemu-stable@nongnu.org
6
Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported")
10
Fixes: fb04ab7ddd8 ("tcg/optimize: Lower TCG_COND_TST{EQ,NE} if unsupported")
7
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711
11
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2711
8
Reported-by: wannacu <wannacu2049@gmail.com>
12
Reported-by: wannacu <wannacu2049@gmail.com>
9
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
13
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
14
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
10
---
15
---
16
include/tcg/tcg-temp-internal.h | 6 ++++++
17
accel/tcg/plugin-gen.c | 2 +-
18
tcg/tcg.c | 5 ++++-
19
3 files changed, 11 insertions(+), 2 deletions(-)
11
20
12
Unless there's some other reason to spin an -rc4, this can wait
21
diff --git a/include/tcg/tcg-temp-internal.h b/include/tcg/tcg-temp-internal.h
13
to be the first patch for 10.0.1.
22
index XXXXXXX..XXXXXXX 100644
14
23
--- a/include/tcg/tcg-temp-internal.h
15
r~
24
+++ b/include/tcg/tcg-temp-internal.h
16
25
@@ -XXX,XX +XXX,XX @@ TCGv_i64 tcg_temp_ebb_new_i64(void);
17
---
26
TCGv_ptr tcg_temp_ebb_new_ptr(void);
18
tcg/tcg.c | 3 +++
27
TCGv_i128 tcg_temp_ebb_new_i128(void);
19
1 file changed, 3 insertions(+)
28
20
29
+/* Forget all freed EBB temps, so that new allocations produce new temps. */
30
+static inline void tcg_temp_ebb_reset_freed(TCGContext *s)
31
+{
32
+ memset(s->free_temps, 0, sizeof(s->free_temps));
33
+}
34
+
35
#endif /* TCG_TEMP_FREE_H */
36
diff --git a/accel/tcg/plugin-gen.c b/accel/tcg/plugin-gen.c
37
index XXXXXXX..XXXXXXX 100644
38
--- a/accel/tcg/plugin-gen.c
39
+++ b/accel/tcg/plugin-gen.c
40
@@ -XXX,XX +XXX,XX @@ static void plugin_gen_inject(struct qemu_plugin_tb *plugin_tb)
41
* that might be live within the existing opcode stream.
42
* The simplest solution is to release them all and create new.
43
*/
44
- memset(tcg_ctx->free_temps, 0, sizeof(tcg_ctx->free_temps));
45
+ tcg_temp_ebb_reset_freed(tcg_ctx);
46
47
QTAILQ_FOREACH_SAFE(op, &tcg_ctx->ops, link, next) {
48
switch (op->opc) {
21
diff --git a/tcg/tcg.c b/tcg/tcg.c
49
diff --git a/tcg/tcg.c b/tcg/tcg.c
22
index XXXXXXX..XXXXXXX 100644
50
index XXXXXXX..XXXXXXX 100644
23
--- a/tcg/tcg.c
51
--- a/tcg/tcg.c
24
+++ b/tcg/tcg.c
52
+++ b/tcg/tcg.c
53
@@ -XXX,XX +XXX,XX @@ void tcg_func_start(TCGContext *s)
54
s->nb_temps = s->nb_globals;
55
56
/* No temps have been previously allocated for size or locality. */
57
- memset(s->free_temps, 0, sizeof(s->free_temps));
58
+ tcg_temp_ebb_reset_freed(s);
59
60
/* No constant temps have been previously allocated. */
61
for (int i = 0; i < TCG_TYPE_COUNT; ++i) {
25
@@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start)
62
@@ -XXX,XX +XXX,XX @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb, uint64_t pc_start)
26
}
63
}
27
#endif
64
#endif
28
65
29
+ /* Do not reuse any EBB that may be allocated within the TB. */
66
+ /* Do not reuse any EBB that may be allocated within the TB. */
30
+ memset(s->free_temps, 0, sizeof(s->free_temps));
67
+ tcg_temp_ebb_reset_freed(s);
31
+
68
+
32
tcg_optimize(s);
69
tcg_optimize(s);
33
70
34
reachable_code_pass(s);
71
reachable_code_pass(s);
35
--
72
--
36
2.43.0
73
2.43.0
diff view generated by jsdifflib