Received: from eggs.gnu.org ([2001:4830:134:3::10]:60035) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkZqk-00050y-DJ for qemu-devel@nongnu.org; Thu, 15 Sep 2016 12:49:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkZqg-0001Y0-CY for qemu-devel@nongnu.org; Thu, 15 Sep 2016 12:49:22 -0400 Received: from mail-yw0-f194.google.com ([209.85.161.194]:35830) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkZqg-0001Xq-6z for qemu-devel@nongnu.org; Thu, 15 Sep 2016 12:49:18 -0400 Received: by mail-yw0-f194.google.com with SMTP id u82so2985017ywc.2 for ; Thu, 15 Sep 2016 09:49:18 -0700 (PDT) Sender: Richard Henderson References: <1472935202-3342-1-git-send-email-rth@twiddle.net> <1472935202-3342-35-git-send-email-rth@twiddle.net> <87bmzpi5yn.fsf@linaro.org> From: Richard Henderson Message-ID: Date: Thu, 15 Sep 2016 09:48:15 -0700 MIME-Version: 1.0 In-Reply-To: <87bmzpi5yn.fsf@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v3 34/34] target-alpha: Emulate LL/SC using cmpxchg helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: =?UTF-8?Q?Alex_Benn=c3=a9e?= Cc: qemu-devel@nongnu.org On 09/15/2016 07:38 AM, Alex Bennée wrote: >> + lab_fail = gen_new_label(); >> > + lab_done = gen_new_label(); >> > + tcg_gen_brcond_i64(TCG_COND_NE, addr, cpu_lock_addr, lab_fail); >> > + tcg_temp_free_i64(addr); >> > >> > - lab_fail = gen_new_label(); >> > - lab_done = gen_new_label(); >> > - tcg_gen_brcond_i64(TCG_COND_NE, addr, cpu_lock_addr, lab_fail); >> > + val = tcg_temp_new_i64(); >> > + tcg_gen_atomic_cmpxchg_i64(val, cpu_lock_addr, cpu_lock_value, >> > + load_gpr(ctx, ra), mem_idx, op); >> > + free_context_temps(ctx); > I don't quite follow what free_context_temps() is doing and why it needs > to be done twice during the building of this instructions TCGOps? > It's releasing the zero, sink, imm TCGv temporaries from DisasContext, as they're going out of scope within each basic block. Since they're freed, they'll be re-created as necessary in the next basic block. The two (unlikely) relevant events are: (1) address register = zero register, so the zero temp becomes invalid, and (2) dest register = zero register, so the zero/sink temps become invalid. It's the kind of thing that really shouldn't ever happen for non-malicious code, but you don't want qemu to abort when invalid temps are used. Perhaps a comment is warranted here... r~