From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-qk1-x731.google.com (mail-qk1-x731.google.com [IPv6:2607:f8b0:4864:20::731]) by sourceware.org (Postfix) with ESMTPS id 2568A3851C11 for ; Mon, 25 May 2020 13:08:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2568A3851C11 Received: by mail-qk1-x731.google.com with SMTP id f189so17370663qkd.5 for ; Mon, 25 May 2020 06:08:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=7oj6OA0Itp5bI3fyNVzm6UBvN7WBZws0226OzC9cJNo=; b=ad+oLWFVLhQOoD8qdPiAztbBShJaX4GXPZL55yRvH//Q5ADpylISO2SCdeBpVDstPg 9bbN9gMuyf7xY2DzC/09naIningLVWACp+vjkslAAJ0c848TkEdvGUGEczskdChriDH5 JSxBe/HmWAgZeZw0vjuPOD0+KpJgC4gJNtV8Z0XwHA5TVbKW135IaE2TVKr1fuvWuBGX R0C9ohWc0myxbnXObhlXmjdrix7tEzKcCPlcrYLCW6ZhMNhpDR7hzoirMqvpYtPHO6lg 9L3aYGFc5EC42hZ3XFXaLSkY4ZDoxE9qkuYyDOhCnbTum9mhquodulFOL7USK4tUizsK hSQw== X-Gm-Message-State: AOAM531EOzg6dowPN+avHXXpcGU/wvhvTIh6lUuzM/UnskO4Ye9JZNuU 8bMntZ2yWTJk0fWwbopfL0hXCpX6nnA= X-Google-Smtp-Source: ABdhPJxTrUDeKq/gSLYpYByLmJgWvXomCdenIJbVv8Zk2NGbV1L8KTIB22t81fEMDstSfreLjQTkmQ== X-Received: by 2002:a37:2702:: with SMTP id n2mr1656427qkn.5.1590412096297; Mon, 25 May 2020 06:08:16 -0700 (PDT) Received: from [192.168.0.185] ([179.185.148.238]) by smtp.gmail.com with ESMTPSA id z19sm16484567qtz.81.2020.05.25.06.08.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 May 2020 06:08:15 -0700 (PDT) Subject: Re: -Wtautological-bitwise-compare error in arm-tdep.c To: Simon Marchi , "gdb-patches@sourceware.org" References: From: Luis Machado Message-ID: <98a9d90b-0452-5b53-b707-9441ebcad6b7@linaro.org> Date: Mon, 25 May 2020 10:08:11 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------E4A172C15ED1CBD4EFCD7087" Content-Language: en-US X-Spam-Status: No, score=-9.9 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 May 2020 13:08:18 -0000 This is a multi-part message in MIME format. --------------E4A172C15ED1CBD4EFCD7087 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Hi, On 5/15/20 5:32 PM, Simon Marchi via Gdb-patches wrote: > We get this error in arm-tdep.c when building with clang 11: > > CXX arm-tdep.o > /home/smarchi/src/binutils-gdb/gdb/arm-tdep.c:934:29: error: bitwise comparison always evaluates to false [-Werror,-Wtautological-bitwise-compare] > else if ((insn & 0xffb0) == 0xe950 /* ldrd Rt, Rt2, > ~~~~~~~~~~~~~~~~^~~~~~~~~ > > Indeed, this can never evaluate to true. I tried to look at what the condition > should be, but it's a bit too deep into ARM instruction encoding for me. I am > pretty sure that the corresponding section in the ARM Architecture Reference > Manual [1] is F3.1.15, if somebody wants to take a stab at it. > > Simon > > [1] https://static.docs.arm.com/ddi0487/fb/DDI0487F_b_armv8_arm.pdf > The following patch should fix clang's error and make the code do the right thing. --------------E4A172C15ED1CBD4EFCD7087 Content-Type: text/x-patch; charset=UTF-8; name="0001-ARM-Fix-PR-26000-logical-bitwise-error-prologue-anal.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename*0="0001-ARM-Fix-PR-26000-logical-bitwise-error-prologue-anal.pa"; filename*1="tch" >From dbaf5e7b1f35c7e97bf23aac846509b33eea491b Mon Sep 17 00:00:00 2001 From: Luis Machado Date: Fri, 15 May 2020 23:06:52 -0300 Subject: [PATCH] [ARM] Fix PR 26000, logical bitwise error / prologue analyzer This fixes an instruction mask typo. We should be matching only ldrd (immediate) and not any other of its variants. As is, it never matches anything. With the patch, the instruction mask also allows matching of ldrd (literal), but the check for SP discards this particular instruction pattern, as it has a hardcoded PC register. gdb/ChangeLog: 2020-05-25 Luis Machado PR tdep/26000 * arm-tdep.c (thumb_analyze_prologue): Fix instruction matching for ldrd (immediate). --- gdb/arm-tdep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index 40bffbb2dd..9a73b85899 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -931,7 +931,7 @@ thumb_analyze_prologue (struct gdbarch *gdbarch, parameters from memory. */ ; - else if ((insn & 0xffb0) == 0xe950 /* ldrd Rt, Rt2, + else if ((insn & 0xff70) == 0xe950 /* ldrd Rt, Rt2, [Rn, #+/-imm] */ && pv_is_register (regs[bits (insn, 0, 3)], ARM_SP_REGNUM)) /* Similarly ignore dual loads from the stack. */ -- 2.17.1 --------------E4A172C15ED1CBD4EFCD7087--