From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-x129.google.com (mail-lf1-x129.google.com [IPv6:2a00:1450:4864:20::129]) by sourceware.org (Postfix) with ESMTPS id 2B8B73858C98 for ; Thu, 25 Jan 2024 07:33:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2B8B73858C98 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2B8B73858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::129 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706167995; cv=none; b=iIR55EyB8F1bWmqF271fDADSGLXoDlMiiBCbYmPxTjgTRetZatscucWRlRVWMenyy/e2Cvz+C+lBfobEarJe/ArVuABvdtiYo0tTGKogmtMVm0wDgjBFmVG5oEnzeG5G7j1KlbXkbaXmRj+E4k0aPhMr2Nbj4wD5qtnlPmSFLm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706167995; c=relaxed/simple; bh=qGM4ejcHkRPJqRCNl917RjRPhxEUkJ0d5SLG831kx3Y=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=HYSHDAVlNuixcm/y5PxBVcWSvaEU/6G5mhY4u0un5AGXbcTpoxep1ZkPGVsVBvmWAUawr16ceosX66nHkSgVxxg24uRNrwGjdJ8ATxerq9b3pAEz8YxYXOuipjvc2ZNVxqDzRnoFfTYvugDbejQsk0cgnaLm9l3zPAHlLPnTb9g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-lf1-x129.google.com with SMTP id 2adb3069b0e04-51016492b14so1490866e87.3 for ; Wed, 24 Jan 2024 23:33:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1706167991; x=1706772791; darn=sourceware.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=CUoS9yGSB2Sn9JkrC3QsPl3n8Ru6eYgYa+JXGieAwGo=; b=Fqbng7FmtPV9knsCjJrlaUlon57beagS3fhvXDhhMI+Vq97HYs3yDThx7JpW8hp4HG 13Yyo4y7gG7S1GPKkzi/CqPJy9HRjDEN3Bi3t9IzAaH3slQ5jn2aZy7JMRscO54uPzAt 8z7TckH6U2ApdEjGkjA313scSGQ9opBkCSD4Yd/1UV7305Pct4xmzHbxwtOMX4AxnfD4 MWAT5r+IBUMC6+08xLyTfai2save2wMDJZrqtje82mQ+mZ8ztwkA/lAcyvVe+f5m4sk+ c+OTX8F0HfxQX7xOqfmc+MVZet9GgCoSsc3kA2KGLvs1qbH0WP+izoireI++onn7EOXX 4H8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706167991; x=1706772791; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CUoS9yGSB2Sn9JkrC3QsPl3n8Ru6eYgYa+JXGieAwGo=; b=ZaXBAJINwTEFg7jxyRXkrcF2T3D83nXAGVp8fvbCCHJOxm2E8gc9Z+dzsQREnDm04L zxWFYR/IOZlqHs3aj8RSCz4F2Me5RA7lo8tQI3y9Ls9/owtCrzgB5LGmfNyPp9BOJUTV L1rBQi1GqH1Uf1Y1Tbwi2QkNXSfSHHGSsE9P4f0if5SPfbaBy46xEhi6WhtxrX+BfvSP 9PrTb7BH2hX/JffPaGWJ4ApMDkXo3O0fFRelBpi2GT4xzKR256Hlf2PHupbkAlmWcXwP 7gJs/cZ6rfO4nHg4N+hFgLBrYJsnn/M8sfHbtn9HNPEK+K2+WgMJmnkuT/eAMPkWcfEq yu9A== X-Gm-Message-State: AOJu0YwdsX3xAoGPwPZvu7DhauchRoH06gHQDeOPpmxSPdhoEKyEUEeh 4VP5EBEWZ7EuwjRnJxhbhBX8k4K7GFdzc0ubjOkj94o1aOMr0KUV7TYbmh6mOA== X-Google-Smtp-Source: AGHT+IHyXDg56HlvCfJaZDySvB9w67NuqkLB/h5/1OBl6Fzux3j/P5KcqC8t3xI1kUqfE9UISqm8/A== X-Received: by 2002:a05:6512:3b91:b0:50e:6ef5:990b with SMTP id g17-20020a0565123b9100b0050e6ef5990bmr228555lfv.11.1706167991466; Wed, 24 Jan 2024 23:33:11 -0800 (PST) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id w11-20020a056602034b00b007bf9eed92ebsm1562706iou.26.2024.01.24.23.33.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 24 Jan 2024 23:33:10 -0800 (PST) Message-ID: Date: Thu, 25 Jan 2024 08:33:07 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH,V2] gas: x86: ginsn: adjust ginsns for certain lea ops Content-Language: en-US To: Indu Bhagat Cc: binutils@sourceware.org References: <20240124064046.1191952-1-indu.bhagat@oracle.com> <2c745a10-04f5-4994-a627-ea434218a823@suse.com> From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz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FY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3025.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,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 List-Id: On 25.01.2024 00:56, Indu Bhagat wrote: > On 1/23/24 23:51, Jan Beulich wrote: >> On 24.01.2024 07:40, Indu Bhagat wrote: >>> + /* lea disp(%base) %dst or lea disp(,%index,imm) %dst. */ >> >> Would be nice if the missing commas were added here. >> > > OK. > >>> - if (i.disp_operands) >>> - src_disp = i.op[0].disps->X_add_number; >>> - >>> - if (src_disp) >>> - /* Generate an ADD ginsn. */ >>> - ginsn = ginsn_new_add (insn_end_sym, true, >>> - GINSN_SRC_REG, base_reg, 0, >>> - GINSN_SRC_IMM, 0, src_disp, >>> - GINSN_DST_REG, dst_reg, 0); >>> - else >>> - /* Generate a MOV ginsn. */ >>> - ginsn = ginsn_new_mov (insn_end_sym, true, >>> - GINSN_SRC_REG, base_reg, 0, >>> - GINSN_DST_REG, dst_reg, 0); >>> - } >>> - else if (!i.base_reg && i.index_reg) >>> - { >>> - /* lea (,%index,imm), %dst. */ >>> - /* TBD_GINSN_INFO_LOSS - There is no explicit ginsn multiply operation, >>> - instead use GINSN_TYPE_OTHER. Also, note that info about displacement >>> - is not carried forward either. But this is fine because >>> - GINSN_TYPE_OTHER will cause SCFI pass to bail out any which way if >>> - dest reg is interesting. */ >>> index_scale = i.log2_scale_factor; >>> - index_reg = ginsn_dw2_regnum (i.index_reg); >>> + src1 = (i.base_reg) ? i.base_reg : i.index_reg; >>> + src1_reg = ginsn_dw2_regnum (src1); >> >> Since I can't spot any other use of src1, why not simply >> >> src1_reg = ginsn_dw2_regnum (i.base_reg ? i.base_reg : i.index_reg); >> >> ? Otherwise at the very least please omit the pointless parentheses in >> the conditional expression. >> > > Will remove the parentheses. > >>> dst_reg = ginsn_dw2_regnum (i.op[1].regs); >>> - ginsn = ginsn_new_other (insn_end_sym, true, >>> - GINSN_SRC_REG, index_reg, >>> - GINSN_SRC_IMM, index_scale, >>> - GINSN_DST_REG, dst_reg); >>> - /* FIXME - It seems to make sense to represent a scale factor of 1 >>> - correctly here (i.e. not as "other", but rather similar to the >>> - base-without- index case above)? */ >>> - } >>> - else >>> - { >>> - /* lea disp(%base,%index,imm) %dst. */ >>> - /* TBD_GINSN_INFO_LOSS - Skip adding information about the disp and imm >>> - for index reg. */ >>> - base_reg = ginsn_dw2_regnum (i.base_reg); >>> - index_reg = ginsn_dw2_regnum (i.index_reg); >>> - dst_reg = ginsn_dw2_regnum (i.op[1].regs); >>> - /* Generate an GINSN_TYPE_OTHER ginsn. */ >>> - ginsn = ginsn_new_other (insn_end_sym, true, >>> - GINSN_SRC_REG, base_reg, >>> - GINSN_SRC_REG, index_reg, >>> - GINSN_DST_REG, dst_reg); >>> - } >>> + /* It makes sense to represent a scale factor of 1 precisely here >>> + (i.e., not using GINSN_TYPE_OTHER, but rather similar to the >>> + base-without-index case). Ignore the case when disp has a symbol >>> + instead. */ >>> + if (!index_scale >>> + && (!i.disp_operands >>> + || (i.disp_operands && i.op[0].disps->X_op == O_constant))) >> >> This is functionally identical to the shorter >> >> if (!index_scale >> && (!i.disp_operands || i.op[0].disps->X_op == O_constant)) >> >> But: What about any of >> >> lea (%rax,%riz),%rbp >> lea (%rax,4),%rbp >> lea (%rax,%riz,4),%rbp >> >> ? > > Current behaviour is: > > lea (%rax,%riz),%rbp > ginsn: OTH 0, 0, %r6 Ought to be MOV? > lea (%rax,4),%rbp > **** Warning: scale factor of 4 without an index register > ginsn: MOV %r0, %r6 Oh, right - the scale factor is zapped in that case along with issuing the warning. That's not quite right though, I suppose. > lea (%rax,%riz,4),%rbp > ginsn: OTH 0, 0, %r6 Ought to be MOV again? > lea sym(,%riz), %rbp > ginsn: OTH 0, 0, %r6 > > lea (,%riz), %rbp > ginsn: MOV %r4, %r6 > (We use DWARF register number 4 {%rsi} in lieu of %riz). Where's the 4 coming from? That doesn't look right. Imo when you create insns other than OTHER, they should be correct. Irrespective of SCFI's needs. (The case here is no different from "lea const, ..." so ought to be handled like that.) Jan