From patchwork Sat Sep 22 00:18:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 186002 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id ED1462C0040 for ; Sat, 22 Sep 2012 11:04:42 +1000 (EST) Received: from localhost ([::1]:40188 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TFDR8-0006bZ-PJ for incoming@patchwork.ozlabs.org; Fri, 21 Sep 2012 20:19:10 -0400 Received: from eggs.gnu.org ([208.118.235.92]:60324) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TFDQU-0004dd-VE for qemu-devel@nongnu.org; Fri, 21 Sep 2012 20:18:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TFDQU-00016W-0t for qemu-devel@nongnu.org; Fri, 21 Sep 2012 20:18:30 -0400 Received: from mail-pa0-f45.google.com ([209.85.220.45]:62643) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TFDQT-00015R-Qs for qemu-devel@nongnu.org; Fri, 21 Sep 2012 20:18:29 -0400 Received: by mail-pa0-f45.google.com with SMTP id fb10so598759pad.4 for ; Fri, 21 Sep 2012 17:18:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=2rkfzkILTo+ZqBwv61fKttgUSZU/QnvZD/ou+XYZFKg=; b=FrXoYgPnyCHobAndTt7qu2SOKixm9QQ8lC9uzRUVkNPLcLQ1oxaa3aWpQp5EeKBKty Vn78ldllIhqJjHIWBDVIuhh8odCK2eX4jPM/LyGjy8bZ5MEZGdYnnVwukpZ9AQShFuQp i/ERD8ODklSSCbhILibs9ruN+c+UmFecd2z6ocSsEXOo50NeYGNsi0m2YsiVHjtJL4GI QyXArMLjTmm7YW51+VMeMNl+/DlbfDjZTx/UeSkIz1dN5vjnfKINKIFbcz0f+hVCCbRQ oesPQGA4UFV8vQo8YpAvNFStWBcgSAhM+4goTh4v/G2G8J8BAf+AyPfGKCGJFFN9XOPR z2lg== Received: by 10.66.88.233 with SMTP id bj9mr16632075pab.72.1348273109540; Fri, 21 Sep 2012 17:18:29 -0700 (PDT) Received: from anchor.twiddle.home.com ([173.160.232.49]) by mx.google.com with ESMTPS id j9sm4837761pav.15.2012.09.21.17.18.28 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 21 Sep 2012 17:18:29 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 21 Sep 2012 17:18:14 -0700 Message-Id: <1348273096-1495-7-git-send-email-rth@twiddle.net> X-Mailer: git-send-email 1.7.11.4 In-Reply-To: <1348273096-1495-1-git-send-email-rth@twiddle.net> References: <1348273096-1495-1-git-send-email-rth@twiddle.net> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.220.45 Cc: aurelien@aurel32.net Subject: [Qemu-devel] [PATCH 6/8] tcg: Add tcg_debug_assert X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Like the C assert macro, except only enabled for CONFIG_DEBUG_TCG, and without having to set _NDEBUG and disable all other asserts at the same time. The use of __builtin_unreachable (when available) gives the compiler the same information, which may (or may not) help it optimize better. Signed-off-by: Richard Henderson Reviewed-by: Aurelien Jarno --- tcg/tcg.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tcg/tcg.h b/tcg/tcg.h index 48a56f0..4501c15 100644 --- a/tcg/tcg.h +++ b/tcg/tcg.h @@ -530,6 +530,15 @@ do {\ abort();\ } while (0) +#ifdef CONFIG_DEBUG_TCG +# define tcg_debug_assert(X) do { assert(X); } while (0) +#elif QEMU_GNUC_PREREQ(4, 5) +# define tcg_debug_assert(X) \ + do { if (!(X)) { __builtin_unreachable(); } } while (0) +#else +# define tcg_debug_assert(X) do { (void)(X); } while (0) +#endif + void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs); #if TCG_TARGET_REG_BITS == 32