From patchwork Mon Sep 23 22:59:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 174227 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp3398349ill; Mon, 23 Sep 2019 16:02:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6FEE8AeBcxU5uOHMUIb1d+ZPOySiFM0P/e3k8qxW//LQy8/aQR5syDAcYt5tVWinq7Ume X-Received: by 2002:a05:6214:1463:: with SMTP id c3mr27270qvy.48.1569279738923; Mon, 23 Sep 2019 16:02:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569279738; cv=none; d=google.com; s=arc-20160816; b=KPJAAWVBf9Dpmf0gJLf9lZycoor6ApVrw6A+j0oxqZqOnK2AKd1ZHFSrHxmG1y/zyI PYJXSLgHnWFpLacgY2pKJiLH1SsctOwOxY64W8UHNSTBtwKAxE7spHeJ2EgaqANAsij/ mGthQWPq78TW4+iGXSqgWgBUFywGMu1/ja9VGGV9OULIcEI0c5q6zGQxuvpZI9nCyZKI R4DMpq6KPfJzIcm2AkMLOcZ5fCmHrEhhkBk9scur6ZA814Uce9Or2MCRysQmpPuBt67v BP8EMitHQs8BH9G9KSpK3XBR30Fm+XdHn7JOdVYCzFis1sf52jrmtw++LfMDB/Zk5hYB f57Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=5Kl11ZmsMIccTxhXV5md4kUi848D5Wwz0Vh+1GCVY20=; b=ZJzI5s2e1+xD8hGuRf0F7cKkNGhYFQT1R4JjtQJUhAXdjCHp0YrYc8yE4fmy6huE6D N2SoTGrrGZLLlqoDOueKTfn7pb4jEqyzM7u6qPbgfaP+kf7VorDl0rtRn3iXSRmsEIjv iVY0hfHxO4MsfMbsBjp96YMf5M+2y+NV7Y6g5Xq2REfHInLoUeZ1UD2uHRP2koxJzoXa AMjPU45dRSdGmtdSFgIox+R+dllWHA+BnR4g49l/sXI9FDcAaIB6ePU/M28XYh3hw5gH lIFzGZrm1zjZGyaHL1Zsv/eMl+NR1UvdWRmZ9XQPXXMrOB+cxM3WXpkoyrh70TWLh+oC 2irw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NY+RhAnU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id a186si9345028qke.250.2019.09.23.16.02.18 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Sep 2019 16:02:18 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=NY+RhAnU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:36960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCXLV-0005Yi-N0 for patch@linaro.org; Mon, 23 Sep 2019 19:02:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35724) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iCXJX-0005Rx-BL for qemu-devel@nongnu.org; Mon, 23 Sep 2019 19:00:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iCXJW-000815-8H for qemu-devel@nongnu.org; Mon, 23 Sep 2019 19:00:15 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:33714) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iCXJW-00080h-2I for qemu-devel@nongnu.org; Mon, 23 Sep 2019 19:00:14 -0400 Received: by mail-pg1-x544.google.com with SMTP id i30so4573pgl.0 for ; Mon, 23 Sep 2019 16:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5Kl11ZmsMIccTxhXV5md4kUi848D5Wwz0Vh+1GCVY20=; b=NY+RhAnUVegbSZ++M38hCn07AAmF9N20PcXLqREfICQIWIkg0+4VRaKv9aYF37Hb3r 2WObegdpu5p1sNo4kso5lrgGD9LNwh4wZ8plzDixSyfOVtrzDyOM+PgWW8XscZ5VJP/B OM0ZbEQUS5YB0PXUvb7mK+Wes4ZjINW2dx0FSyYUYXdetHk1tx3UiizySGXXaNuSCFrl IhU8wR2/t/SnZCo2f3fE0H9hJG8NZ7Q5CfNsK2wRVzFpU6qNyr4oFXaHmS9I5S2s5zlH vFY4M25VX22Ruyk1yBmumklzcRqK8ttJ5wzNp96HNsUejCgW87dwq7p0iQeKDok2WSck 2kjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5Kl11ZmsMIccTxhXV5md4kUi848D5Wwz0Vh+1GCVY20=; b=lXHxtJ0IVX0mnz0K0M/KV+WwOUXGSDxRKRtcVYATGQUD1DO4IAICYGgLNjZegxwh/+ aZ8oXUhJ/8Lul1Ntk3kju6P3jLdmeOGEEbRtgXaB3lUKGZxmQRn7wKJ6YefxlH8MK/Wn RKLIs1x0GvETMaO4NU7Z+WbMcLjbR32yUaKmcyABgspOPtgJK+u4eXav/qbbmULxA83t y44e1FExqO337gPElbgWeSNkmbkiHOWVld+SLv6j+N7tZH+NC72reo9uaD6etXRRC7H7 v4/MYwBShh9kLvNNJBOpjoTUqdeBp8de8so7EU+K04JEJC9j7RHxt3E+x9PWbIGyM8uN ZwPw== X-Gm-Message-State: APjAAAVbQGsAPua8e7s4Ydt8L+rOF5EO8R8htAu3RUKq8BNBp9HkAtSy 1D3luY2WPgq0ws0sm+v+K+SyXmew5zs= X-Received: by 2002:a63:505:: with SMTP id 5mr2189265pgf.297.1569279612724; Mon, 23 Sep 2019 16:00:12 -0700 (PDT) Received: from localhost.localdomain ([12.206.46.59]) by smtp.gmail.com with ESMTPSA id 74sm11674810pfy.78.2019.09.23.16.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Sep 2019 16:00:12 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 03/16] qemu/compiler.h: Add optimize_away Date: Mon, 23 Sep 2019 15:59:51 -0700 Message-Id: <20190923230004.9231-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190923230004.9231-1-richard.henderson@linaro.org> References: <20190923230004.9231-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, alex.bennee@linaro.org, stefanha@redhat.com, david@redhat.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Use this as a compile-time assert that a particular code path is not reachable. Signed-off-by: Richard Henderson --- include/qemu/compiler.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/include/qemu/compiler.h b/include/qemu/compiler.h index 20780e722d..6604ccea92 100644 --- a/include/qemu/compiler.h +++ b/include/qemu/compiler.h @@ -221,4 +221,19 @@ #define QEMU_GENERIC9(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC8(x, __VA_ARGS__)) #define QEMU_GENERIC10(x, a0, ...) QEMU_GENERIC_IF(x, a0, QEMU_GENERIC9(x, __VA_ARGS__)) +/** + * optimize_away() + * + * The compiler, during optimization, is expected to prove that a call + * to this function cannot be reached and remove it. If the compiler + * supports QEMU_ERROR, this will be reported at compile time; otherwise + * this will be reported at link time, due to the missing symbol. + */ +#ifdef __OPTIMIZE__ +extern void QEMU_NORETURN QEMU_ERROR("code path is reachable") + optimize_away(void); +#else +#define optimize_away() g_assert_not_reached() +#endif + #endif /* COMPILER_H */