From 79b1af906245558c30e0a5faf26cb52b63f83cce Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Tue, 25 Apr 2017 12:38:52 +0200 Subject: [PATCH] tcg: Initialize return value after exit_atomic Users of tcg_gen_atomic_cmpxchg and do_atomic_op rightfully utilize the output. Even though this code is dead, it gets translated, and without the initialization we encounter a tcg_error. Reported-by: Nikunj A Dadhania Tested-by: Nikunj A Dadhania Tested-by: Peter Maydell Signed-off-by: Richard Henderson --- tcg/tcg-op.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tcg/tcg-op.c b/tcg/tcg-op.c index 95a39b7d8c..6b1f41500c 100644 --- a/tcg/tcg-op.c +++ b/tcg/tcg-op.c @@ -2861,6 +2861,9 @@ void tcg_gen_atomic_cmpxchg_i64(TCGv_i64 retv, TCGv addr, TCGv_i64 cmpv, #endif #else gen_helper_exit_atomic(tcg_ctx.tcg_env); + /* Produce a result, so that we have a well-formed opcode stream + with respect to uses of the result in the (dead) code following. */ + tcg_gen_movi_i64(retv, 0); #endif /* CONFIG_ATOMIC64 */ } else { TCGv_i32 c32 = tcg_temp_new_i32(); @@ -2966,6 +2969,9 @@ static void do_atomic_op_i64(TCGv_i64 ret, TCGv addr, TCGv_i64 val, #endif #else gen_helper_exit_atomic(tcg_ctx.tcg_env); + /* Produce a result, so that we have a well-formed opcode stream + with respect to uses of the result in the (dead) code following. */ + tcg_gen_movi_i64(ret, 0); #endif /* CONFIG_ATOMIC64 */ } else { TCGv_i32 v32 = tcg_temp_new_i32();