Blame 0046-tcg-optimize-fix-end-of-basic-block-detection.patch

5544c1
From 4ce7a1e0aaecb220016af9b4f390b76f7fffcce8 Mon Sep 17 00:00:00 2001
5544c1
From: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Date: Wed, 19 Sep 2012 21:40:30 +0200
5544c1
Subject: [PATCH] tcg/optimize: fix end of basic block detection
5544c1
5544c1
Commit e31b0a7c050711884ad570fe73df806520953618 fixed copy propagation on
5544c1
32-bit host by restricting the copy between different types. This was the
5544c1
wrong fix.
5544c1
5544c1
The real problem is that the all temps states should be reset at the end
5544c1
of a basic block. This was done by adding such operations in the switch,
5544c1
but brcond2 was forgotten (that's why the crash was only observed on 32-bit
5544c1
hosts).
5544c1
5544c1
Fix that by looking at the TCG_OPF_BB_END instead. We need to keep the case
5544c1
for op_set_label as temps might be modified through another path.
5544c1
5544c1
Cc: Blue Swirl <blauwirbel@gmail.com>
5544c1
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
5544c1
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
5544c1
---
5544c1
 tcg/optimize.c | 22 +++++++++-------------
5544c1
 1 file changed, 9 insertions(+), 13 deletions(-)
5544c1
5544c1
diff --git a/tcg/optimize.c b/tcg/optimize.c
5544c1
index 10d9773..9da333c 100644
5544c1
--- a/tcg/optimize.c
5544c1
+++ b/tcg/optimize.c
5544c1
@@ -632,21 +632,17 @@ static TCGArg *tcg_constant_folding(TCGContext *s, uint16_t *tcg_opc_ptr,
5544c1
                 i--;
5544c1
             }
5544c1
             break;
5544c1
-        case INDEX_op_set_label:
5544c1
-        case INDEX_op_jmp:
5544c1
-        case INDEX_op_br:
5544c1
-            memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
5544c1
-            for (i = 0; i < def->nb_args; i++) {
5544c1
-                *gen_args = *args;
5544c1
-                args++;
5544c1
-                gen_args++;
5544c1
-            }
5544c1
-            break;
5544c1
         default:
5544c1
             /* Default case: we do know nothing about operation so no
5544c1
-               propagation is done.  We only trash output args.  */
5544c1
-            for (i = 0; i < def->nb_oargs; i++) {
5544c1
-                reset_temp(args[i], nb_temps, nb_globals);
5544c1
+               propagation is done.  We trash everything if the operation
5544c1
+               is the end of a basic block, otherwise we only trash the
5544c1
+               output args.  */
5544c1
+            if (def->flags & TCG_OPF_BB_END) {
5544c1
+                memset(temps, 0, nb_temps * sizeof(struct tcg_temp_info));
5544c1
+            } else {
5544c1
+                for (i = 0; i < def->nb_oargs; i++) {
5544c1
+                    reset_temp(args[i], nb_temps, nb_globals);
5544c1
+                }
5544c1
             }
5544c1
             for (i = 0; i < def->nb_args; i++) {
5544c1
                 gen_args[i] = args[i];
5544c1
-- 
5544c1
1.7.12.1
5544c1