From patchwork Fri May 13 08:07:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 53904 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 85BFF385140A for ; Fri, 13 May 2022 08:21:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 85BFF385140A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652430073; bh=mb4FKTms5ZgNzqiymoq+9nmVoG6hiJIk1rToYD3nCqA=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=IXHPg8bQ1l5mEDj3H0qdOS8+/j0F5eRYBKv09zjcrxOdXxuOGjjH2eN31n8IPEmpt 8ZOCl3AJILF9hLq6BpFmXotUim9t+hzbYLskEElKxOTiNmYMMp6TfuE/JE6I/sAopZ RTVFcJZeIcabFwxjqcryGCoLardecwz7AO7J60AU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by sourceware.org (Postfix) with ESMTPS id D2F42385736E for ; Fri, 13 May 2022 08:07:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D2F42385736E Received: by mail-wr1-x430.google.com with SMTP id i5so10297427wrc.13 for ; Fri, 13 May 2022 01:07:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=mb4FKTms5ZgNzqiymoq+9nmVoG6hiJIk1rToYD3nCqA=; b=cI4lNSiOnqNngEBvlJXab5LdtqCjcQCwTUW28R//bG6kKlJiyRXfgV2KRNJ4a+eQNq 2ialaLZx22f7RUJPmlbTaHdnrvt9m6y/w0QI4rvx/AueLj9hoO9SLZ7Ecna/fHf79QJ1 KxLYr1blh2ruo3cWyVh9WFwK1DkRBXA2sQyg6b3u+Kb1Cq0mOy88nPT181ock6F805JL vbdxmRMKwAO03ChqWTU4lXXuIACDPTuD/mXBuCQ1RbRtsK47RzvdeP9/acH2Q7X38QEZ jme91ek54oS9FWA4nZtvNLqE/QenNHXBxTe67Dnti/iiuAWvFPl2xnowPJPf48Ntbybt Ug9w== X-Gm-Message-State: AOAM532vAyZOvYmGNfYpIl4KVHoxnAwL3Iurlg5NH8jdVuaGCsCwBC/F yMCSmdUZPX0lR2QaZNGs+eFzYVbO11sdfVyN X-Google-Smtp-Source: ABdhPJwuqNXm4py9v95s6kA2YUa/jDwm23M4b/4HiYrzkgVR+i2aa3ch0KWyTt9uJS2v1Gju3jzNPg== X-Received: by 2002:adf:ec92:0:b0:20a:d261:2cf2 with SMTP id z18-20020adfec92000000b0020ad2612cf2mr2805791wrn.296.1652429263460; Fri, 13 May 2022 01:07:43 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:bf38:f508:6f40:de1d]) by smtp.gmail.com with ESMTPSA id e23-20020adf9bd7000000b0020aca418f26sm1507213wrc.1.2022.05.13.01.07.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 01:07:42 -0700 (PDT) X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [PATCH] Do not use DW_OP_not for TRUTH_NOT_EXPR in conditional expressions Date: Fri, 13 May 2022 10:07:24 +0200 Message-ID: <3103467.5fSG56mABF@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eric Botcazou via Gcc-patches From: Eric Botcazou Reply-To: Eric Botcazou Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, DW_OP_not is a bitwise, not a logical NOT, so it computes the wrong result in a DWARF conditional expression. Tested (GCC + GDB° on x86-64/Linux, OK for the mainline? 2022-05-13 Eric Botcazou * dwarf2out.c (loc_list_from_tree_1) : Swap the operands if the condition is a TRUTH_NOT_EXPR. diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 5681b01749a..affa2b5e52e 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -19497,6 +19497,15 @@ loc_list_from_tree_1 (tree loc, int want_address, list_ret = loc_list_from_tree_1 (TREE_OPERAND (TREE_OPERAND (loc, 0), 0), 0, context); + /* DW_OP_not is a bitwise, not a logical NOT, so avoid it. */ + else if (TREE_CODE (TREE_OPERAND (loc, 0)) == TRUTH_NOT_EXPR) + { + lhs = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0, context); + rhs = loc_list_from_tree_1 (TREE_OPERAND (loc, 1), 0, context); + list_ret + = loc_list_from_tree_1 (TREE_OPERAND (TREE_OPERAND (loc, 0), 0), + 0, context); + } else list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context); if (list_ret == 0 || lhs == 0 || rhs == 0)