Message ID | 20231031183504.832611-1-vineetg@rivosinc.com |
---|---|
State | Accepted |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b90f:0:b0:403:3b70:6f57 with SMTP id t15csp437706vqg; Tue, 31 Oct 2023 11:35:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHB+E12cLtepBGb+CUDHSplAwhjmeKeF1TWCZoR6GllSqgQQD58pifS9AzJVbvF8eJyj8XQ X-Received: by 2002:ac8:5c07:0:b0:412:395c:e794 with SMTP id i7-20020ac85c07000000b00412395ce794mr17419311qti.50.1698777334691; Tue, 31 Oct 2023 11:35:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698777334; cv=pass; d=google.com; s=arc-20160816; b=hfTYqzcRgkBTvE7LHnOPAwcjRDzrCDAAl6xEc1YGphoVvKc0mWVEeeVYmxza7Xs6Dm YXBYjp8Wn216jAwknJKIbNHdzqK45hy99R79HHP/TcqfpRBjimE04kiNg3kyM9+a5osT b/f26Br7tSx1jjnUnasjVE3F9iOlHVTEdkeNBgKMkgBkIUKjjF27SJxiSDUeVQ0c/vVJ 1A9yS6xkELPST7wL2lJ1UhiwKSbeccKs9kgHBl8Ws0wyBgfiuZmat3nUxcL3nIOIm3PC uUBjPNvgD7uV+rxDI0HHTCL6lT8R4TqBVhIRwq4T51OUS42Eknl9zMN9DyyQ2xRpGZJf 6Rpw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=nckNZrdAD+VIw0/AYspCiwtZC156CWQwwMeCAQ/VWKI=; fh=viazKkcHi6DoYbA2Nlz5k3jWdn5ZGzo/0R9UcRXACb8=; b=tPnCj5TPip0lFIty2WgctX21Wd061gM7YoExLT58WzDeYNLrSI27s9xPjjb6/Te1hn EYUSu/7ZfjWZpWB3tIIVGnahsRe9wc4QFR6FM8qpbFMZJW2cd3IcdxJbgF4jJWT++w/t 64vhcivgC3D7YrOEJclYMSTDYgP0OK1k3U1PmGK9B3y68dhr1zy9bNhIp4pabyTZNyDU hw3R4H17Qm3Mgi5FuY5A9e2GqYDIqZA4F0beTLkB4karAu2qz33QmaX6R8TSwIQCMq29 NqEw9OixxemsPLsvZtf7tHJnfOPJXWzVZiDHY414Q6j5CXofL0UMfC2g3ZKf1Dq9RdYI oKrQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="1JR/hQjq"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id s2-20020a05622a1a8200b0041814373040si1621071qtc.49.2023.10.31.11.35.34 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 11:35:34 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@rivosinc-com.20230601.gappssmtp.com header.s=20230601 header.b="1JR/hQjq"; arc=pass (i=1); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 52B223858031 for <ouuuleilei@gmail.com>; Tue, 31 Oct 2023 18:35:34 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id B4D793858418 for <gcc-patches@gcc.gnu.org>; Tue, 31 Oct 2023 18:35:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B4D793858418 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org B4D793858418 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::32a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698777311; cv=none; b=Wo3t1W+uyEmVjJix6kyufSq22rQfNIwN4lZGa/IZFfLlgYF40sxyNExT5GkWR5lb+AzvAEStHIzyseZp3cl/U8D8eFkNYjZAZOzWeYEwEfz/GtRgBM1kquglk/Eb1XnhXZ0VqNef/dgvlIPP4uGDdn+YBzLlaaVspvp1A+9vGSI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698777311; c=relaxed/simple; bh=sObq2CvaWA3tvQYlLLskGRy/lnPX//Og03krtOMnYHE=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=TihgjHwfyVMM1xe9Q7wlTzW+Z2IrbnnYL5QT+hTrh0D1f5vhtVjwqngorpC51cf9aKXeoZsEFxZV18OoBlMXgQEErMDFFqJXxuaZG8PEkB5iDsQZ5VeQqiHjzJlsbDIBPGI7+MkgupB0eISILxYA2842ef7WX/GMnVZSYZX5a6U= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-ot1-x32a.google.com with SMTP id 46e09a7af769-6ce2c5b2154so3892797a34.3 for <gcc-patches@gcc.gnu.org>; Tue, 31 Oct 2023 11:35:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1698777309; x=1699382109; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=nckNZrdAD+VIw0/AYspCiwtZC156CWQwwMeCAQ/VWKI=; b=1JR/hQjq184kL9wiocxEKLIk+epVKTwnuM+QI+jDhQNRD17QhoP2gAnzwuYSk7UC8s OLgYfzka7ahIU/v/CPFnfFz6fgGqyFLtowgwynyz/9KZd5YYi7WeIWKcK5j3oRCFvpbq NG1mM9zx8lPtHDMnMb/SYjZs2Fgve1esEEdI61GOfjDkhJtnp1lc5rkepshk9A0ZF1lW a5xzOIBWzXIZrD8TLmEERkp5MDsLEIrEMLaecveTFTY5m2PV5w8HnNhcWFos8dcjTrCS 6czukR1ojbpr9ziMyo/UCmSJEw4/rWgBwBJXPuY4qZrdIahQBfeAmUPwAZMr3CXBdUEW 6Wsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698777309; x=1699382109; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=nckNZrdAD+VIw0/AYspCiwtZC156CWQwwMeCAQ/VWKI=; b=sN0yTl8O0Y91985ufuxmiNhPLI5/1eoteEW4E7xErYd3sdESlJzeLASnajgycm5BSD 0vfG5q57B5w0vdrQ3qFCLTWO/c7BqRihdnXzxbESnHX0s/a6452NsO6N13Y1lzHfw6hk Iwrl7mr+APnlXNy46YmyWUjWTkMuyVRcFaDRDgO99vjIb5BoRXaSACpBlXqlOOhGkKLp 1hl6R2uZT0dA0LroiE9ML7WI68X2oHYAKzMobWjqouzS0Sikf+5CCsCWV7Zy+BKHhL0G Iu4tQu+54Hl5afhKh8gdPEXmJ2IoHHbHvPnesj940f1Q0+shOw3Kl/W+PTboWAVMEDvA Nh7A== X-Gm-Message-State: AOJu0YxrTZHFFh9FNX6FbWMkIAnNLh4X6U2r/WwkvGk3V92+anxXNPXx W59lWcwKP0ckcSsxF3cS+DRSrUZmPfSdDbHQMs3egA== X-Received: by 2002:a9d:7c8b:0:b0:6be:fdab:dc65 with SMTP id q11-20020a9d7c8b000000b006befdabdc65mr15035559otn.19.1698777308857; Tue, 31 Oct 2023 11:35:08 -0700 (PDT) Received: from vineet-framework.hq.rivosinc.com ([12.44.203.122]) by smtp.gmail.com with ESMTPSA id j9-20020a056830270900b006ce33dc3004sm311109otu.49.2023.10.31.11.35.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Oct 2023 11:35:08 -0700 (PDT) From: Vineet Gupta <vineetg@rivosinc.com> To: gcc-patches@gcc.gnu.org Cc: gnu-toolchain@rivosinc.com, Jeff Law <jeffreyalaw@gmail.com>, Vineet Gupta <vineetg@rivosinc.com> Subject: [PATCH] RISC-V: fix TARGET_PROMOTE_FUNCTION_MODE hook for libcalls Date: Tue, 31 Oct 2023 11:35:04 -0700 Message-Id: <20231031183504.832611-1-vineetg@rivosinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE, URIBL_BLACK 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.30 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781297142072050497 X-GMAIL-MSGID: 1781297142072050497 |
Series |
RISC-V: fix TARGET_PROMOTE_FUNCTION_MODE hook for libcalls
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | success | Github commit url |
Commit Message
Vineet Gupta
Oct. 31, 2023, 6:35 p.m. UTC
riscv_promote_function_mode doesn't promote a SI to DI for libcalls
case.
The fix is what generic promote_mode () in explow.cc does. I really
don't understand why the old code didn't work, but stepping thru the
debugger shows old code didn't and fixed does.
This showed up when testing Ajit's REE ABI extension series which probes
the ABI (using a NULL tree type) and ends up hitting the libcall code path.
[Usual caveat, I'll wait for Pre-commit CI to run the tests and report]
gcc/ChangeLog:
* config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode
returned for libcall case.
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
---
gcc/config/riscv/riscv.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On 10/31/23 12:35, Vineet Gupta wrote: > riscv_promote_function_mode doesn't promote a SI to DI for libcalls > case. > > The fix is what generic promote_mode () in explow.cc does. I really > don't understand why the old code didn't work, but stepping thru the > debugger shows old code didn't and fixed does. > > This showed up when testing Ajit's REE ABI extension series which probes > the ABI (using a NULL tree type) and ends up hitting the libcall code path. > > [Usual caveat, I'll wait for Pre-commit CI to run the tests and report] > > gcc/ChangeLog: > * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode > returned for libcall case. Hmm. There may be dragons in here. I'll need to find and review an old conversation in this space (libcalls and argument promotions). Jeff
On Tue, 31 Oct 2023 16:18:35 PDT (-0700), jeffreyalaw@gmail.com wrote: > > > On 10/31/23 12:35, Vineet Gupta wrote: >> riscv_promote_function_mode doesn't promote a SI to DI for libcalls >> case. >> >> The fix is what generic promote_mode () in explow.cc does. I really >> don't understand why the old code didn't work, but stepping thru the >> debugger shows old code didn't and fixed does. >> >> This showed up when testing Ajit's REE ABI extension series which probes >> the ABI (using a NULL tree type) and ends up hitting the libcall code path. >> >> [Usual caveat, I'll wait for Pre-commit CI to run the tests and report] >> >> gcc/ChangeLog: >> * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode >> returned for libcall case. > Hmm. There may be dragons in here. I'll need to find and review an old > conversation in this space (libcalls and argument promotions). We also have a non-orthogonality in the ABI sign extension rules between SI and DI, a few of us were talking about it on the internal slack (though the specifics were for a different patch, Vineet has a few in flight).
On 10/31/23 17:41, Palmer Dabbelt wrote: > On Tue, 31 Oct 2023 16:18:35 PDT (-0700), jeffreyalaw@gmail.com wrote: >> >> >> On 10/31/23 12:35, Vineet Gupta wrote: >>> riscv_promote_function_mode doesn't promote a SI to DI for libcalls >>> case. >>> >>> The fix is what generic promote_mode () in explow.cc does. I really >>> don't understand why the old code didn't work, but stepping thru the >>> debugger shows old code didn't and fixed does. >>> >>> This showed up when testing Ajit's REE ABI extension series which probes >>> the ABI (using a NULL tree type) and ends up hitting the libcall code >>> path. >>> >>> [Usual caveat, I'll wait for Pre-commit CI to run the tests and report] >>> >>> gcc/ChangeLog: >>> * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode >>> returned for libcall case. >> Hmm. There may be dragons in here. I'll need to find and review an old >> conversation in this space (libcalls and argument promotions). > > We also have a non-orthogonality in the ABI sign extension rules between > SI and DI, a few of us were talking about it on the internal slack > (though the specifics were for a different patch, Vineet has a few in > flight). So the old issue I was thinking of really only affects targets that push arguments on the stack and when a sub-word push actually allocates a full word on the stack (m68k, but !coldfire, h8 and probably others of that era). Point being, those issues don't apply here. jeff
On 10/31/23 17:51, Jeff Law wrote: >>> >> >> We also have a non-orthogonality in the ABI sign extension rules >> between SI and DI, a few of us were talking about it on the internal >> slack (though the specifics were for a different patch, Vineet has a >> few in flight). > So the old issue I was thinking of really only affects targets that > push arguments on the stack and when a sub-word push actually > allocates a full word on the stack (m68k, but !coldfire, h8 and > probably others of that era). > > Point being, those issues don't apply here. OK, I think Palmer was conflating this with the discussion in other thread/patch. -Vineet
On 10/31/23 12:35, Vineet Gupta wrote: > riscv_promote_function_mode doesn't promote a SI to DI for libcalls > case. > > The fix is what generic promote_mode () in explow.cc does. I really > don't understand why the old code didn't work, but stepping thru the > debugger shows old code didn't and fixed does. > > This showed up when testing Ajit's REE ABI extension series which probes > the ABI (using a NULL tree type) and ends up hitting the libcall code path. > > [Usual caveat, I'll wait for Pre-commit CI to run the tests and report] > > gcc/ChangeLog: > * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode > returned for libcall case. Macro that change their arguments are evil ;( I think Juzhe's patch in this space a few months back wasn't supposed to change behavior. OK once CI finishes without regressions. jeff
On 11/1/23 12:11, Jeff Law wrote: > > > On 10/31/23 12:35, Vineet Gupta wrote: >> riscv_promote_function_mode doesn't promote a SI to DI for libcalls >> case. >> >> The fix is what generic promote_mode () in explow.cc does. I really >> don't understand why the old code didn't work, but stepping thru the >> debugger shows old code didn't and fixed does. >> >> This showed up when testing Ajit's REE ABI extension series which probes >> the ABI (using a NULL tree type) and ends up hitting the libcall code >> path. >> >> [Usual caveat, I'll wait for Pre-commit CI to run the tests and report] >> >> gcc/ChangeLog: >> * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode >> returned for libcall case. > Macro that change their arguments are evil ;( I think Juzhe's patch > in this space a few months back wasn't supposed to change behavior. Oh, its a regression. I can add a Fixes: tag > > OK once CI finishes without regressions. Thx, -Vineet
On 11/1/23 12:19, Vineet Gupta wrote: > > > On 11/1/23 12:11, Jeff Law wrote: >> >> >> On 10/31/23 12:35, Vineet Gupta wrote: >>> riscv_promote_function_mode doesn't promote a SI to DI for libcalls >>> case. >>> >>> The fix is what generic promote_mode () in explow.cc does. I really >>> don't understand why the old code didn't work, but stepping thru the >>> debugger shows old code didn't and fixed does. >>> >>> This showed up when testing Ajit's REE ABI extension series which >>> probes >>> the ABI (using a NULL tree type) and ends up hitting the libcall >>> code path. >>> >>> [Usual caveat, I'll wait for Pre-commit CI to run the tests and report] >>> >>> gcc/ChangeLog: >>> * config/riscv/riscv.cc (riscv_promote_function_mode): Fix mode >>> returned for libcall case. >> Macro that change their arguments are evil ;( I think Juzhe's patch >> in this space a few months back wasn't supposed to change behavior. > > Oh, its a regression. I can add a Fixes: tag > >> >> OK once CI finishes without regressions. > > Thx, > -Vineet > It passes precommit CI without any new failures: https://github.com/ewlu/gcc-precommit-ci/issues/526#issuecomment-1787891174 Tested-by: Patrick O'Neill <patrick@rivosinc.com> Thanks, Patrick
diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 3e27897d6d30..7b8e9af0a5af 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -8630,9 +8630,10 @@ riscv_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, return promote_mode (type, mode, punsignedp); unsignedp = *punsignedp; - PROMOTE_MODE (as_a <scalar_mode> (mode), unsignedp, type); + scalar_mode smode = as_a <scalar_mode> (mode); + PROMOTE_MODE (smode, unsignedp, type); *punsignedp = unsignedp; - return mode; + return smode; } /* Implement TARGET_MACHINE_DEPENDENT_REORG. */