Message ID | 20220830174830.224541-3-vineetg@rivosinc.com |
---|---|
State | New, archived |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:ecc5:0:0:0:0:0 with SMTP id s5csp1909884wro; Tue, 30 Aug 2022 10:50:18 -0700 (PDT) X-Google-Smtp-Source: AA6agR4eEWONNZ2I7a6WyaiGnO/O4LfzGNsAjYUIMwkYzIU/CYmbAVQrImf7OERkYnP3xSinbiYP X-Received: by 2002:a17:907:7254:b0:731:61c6:ecf9 with SMTP id ds20-20020a170907725400b0073161c6ecf9mr18135504ejc.101.1661881818088; Tue, 30 Aug 2022 10:50:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661881818; cv=none; d=google.com; s=arc-20160816; b=QKzgjI3fDT9mQfTzeTWfxEX0pyNQDL+5yBNL7JLzNMx6BppVyVLGfkYOPph5ivbKmZ PkcleYj2HGNP0QnESgL372JzG7QFMOhPoVIBq62qPdsE3D9iLEQmhYrqtYsJ5kAvmTdt 9fSsD5eMS/KIyRmmCXmvkyulIUCM0PK6bZoZgnAPqhx7WezVXeyr7YmfHItu9aPVSc9V Ab86nbTDNvDzVIMXosis2WbEAf44C8GAOnEpb4kxSug5p/yoJ2TfM4MeqDKTHk3ap8f4 VzfLNM/hC8v1VbsZC16F1M5jGY+5LZvnG3/+ij4w/miypoKcv3U7ErYF/abwbLxRyWy8 YgLw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature:dmarc-filter:delivered-to; bh=6DEv2ESLdRXwiK1bwovaKcucVwYeTnS1bcfDOmrSxEE=; b=Wkh4nEyqsPSIcBK2mY8Pdt4irS5UL5smmoHRe3n+y/BRugpUNGZ/pQdjlVGwgtDgYH AZbdDykBFm7sZhPtRDGHpesE3PpGTaLqjXIm0kQULcCDn8ramfSqs7pLoPZU6MMtJ1NL YY6N7iL3lQLgNA/k3axAqVFMFww2GiP1gexR447AacUb3RmEKYarJgC6ywV3KTwjc987 xdlE08LjCNZrigbAuvy2diT+4AnFRJM0PZ0UP0Suj9yRkj1drXoK9vUuKYTSVMIJv8Zi ybNNtlRoFymae6CJh2Ivrs9sq0eR/VpFXM/+FwWBst3pBxh1XzpEZEI87Fav/nkEDPy3 X9RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=w6jyMmYq; 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 sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v16-20020a1709067d9000b0073d19e6ce0bsi8085820ejo.301.2022.08.30.10.50.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 10:50:18 -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=fail header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=w6jyMmYq; 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 EED7C3AA889F for <ouuuleilei@gmail.com>; Tue, 30 Aug 2022 17:49:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by sourceware.org (Postfix) with ESMTPS id F099E385841A for <gcc-patches@gcc.gnu.org>; Tue, 30 Aug 2022 17:48:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F099E385841A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pg1-x52d.google.com with SMTP id b196so1627762pga.7 for <gcc-patches@gcc.gnu.org>; Tue, 30 Aug 2022 10:48:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=6DEv2ESLdRXwiK1bwovaKcucVwYeTnS1bcfDOmrSxEE=; b=w6jyMmYqI3I9LSrTKPm6Ic8yiZYcOofXZZmNVQSOOcRIUZ2YIDlVBqqbUyf9ZGK2Kj 5BwURd7j/WNAS3lD6eNHABtaC9L1b7YT8QcboySfA3LELnkV8a1JTLUfXJrPNlOW15GE rWDQSJ6FMNP/8d1Lj3TS7daeMp3eOClYTt6Vo4ZL7UTiNFP2NetcaC76HsQVOc7xttmA PYC+7bqWKKRyoO367lThJRq70H08ZiVk6DUiOOIG6GKDKQuzK4LwX/GZKtDsAdHNJwCn Yp+xhaypgjJy/Z5cdsrE0e9yQGnwdwXI1QhDFXiWkeHO/JOcXftgUxq2LUwn4p4N5jAq KIRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=6DEv2ESLdRXwiK1bwovaKcucVwYeTnS1bcfDOmrSxEE=; b=s1reXp392LpQ4dzIDu5ZnXc2Iqocv6JLgZ28/Gk+lPMyeE2n5MMJX1wfstHKlPIUbU exBBavYeAL4YZmQKXvNdycehOmffreBrqCtgckCssFuhThWNa4+iNDcr8aafBVors67h 2A5p5YurRTRScbeiRBabSeXvXU5KvQfu0anI2mPFUsucgR4CWzUtY1tWpTNcEQ5g8zRr 05SgbiL/x3L/UYNq6Cjb9cqWa5sdK+OfD0DQDneQXs2SaPh4t8V97onv9uS0GMTSDeRZ s282EBS1+x3b/3xaJN/+MZI0fbQr+SsB3j3w4gqL9DL4YrHMLd+MbEEX9h8jdNrt8evx 4S1w== X-Gm-Message-State: ACgBeo2YOViV71glFdaNvHQi1Vq9WJwDuzjE8GGmhJTmI8c+49ar/E1O h6NnTR1OpczLDUk3oJtbyzoUU/u2hDNgnsDt2qs= X-Received: by 2002:a63:4558:0:b0:429:b6e6:6638 with SMTP id u24-20020a634558000000b00429b6e66638mr18725250pgk.83.1661881716808; Tue, 30 Aug 2022 10:48:36 -0700 (PDT) Received: from vineetg-framework.hq.rivosinc.com ([12.3.194.138]) by smtp.gmail.com with ESMTPSA id w5-20020aa79545000000b005386162bc2asm3618852pfq.92.2022.08.30.10.48.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Aug 2022 10:48:36 -0700 (PDT) From: Vineet Gupta <vineetg@rivosinc.com> To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] RISC-V: remove CM_PIC as it doesn't do much Date: Tue, 30 Aug 2022 10:48:30 -0700 Message-Id: <20220830174830.224541-3-vineetg@rivosinc.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220830174830.224541-1-vineetg@rivosinc.com> References: <20220830174830.224541-1-vineetg@rivosinc.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.5 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.29 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> Cc: collison@rivosinc.com, gnu-toolchain@rivosinc.com, Vineet Gupta <vineetg@rivosinc.com>, kito.cheng@gmail.com, Philipp Tomsich <philipp.tomsich@vrull.eu> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1742609388854646105?= X-GMAIL-MSGID: =?utf-8?q?1742609388854646105?= |
Series |
PIC cleanup
|
|
Commit Message
Vineet Gupta
Aug. 30, 2022, 5:48 p.m. UTC
CM_PIC is no longer doing anything directly. Removing it might
potentially affect USE_LOAD_ADDRESS_MACRO() but seems unlikely.
Signed-off-by: Vineet Gupta <vineetg@rivosinc.com>
---
gcc/config/riscv/riscv-c.cc | 4 ----
gcc/config/riscv/riscv-opts.h | 3 +--
gcc/config/riscv/riscv.cc | 2 +-
3 files changed, 2 insertions(+), 7 deletions(-)
Comments
On Tue, 30 Aug 2022 10:48:30 PDT (-0700), Vineet Gupta wrote: > CM_PIC is no longer doing anything directly. Removing it might > potentially affect USE_LOAD_ADDRESS_MACRO() but seems unlikely. At least in the short term, there's kind of a mess here that needs to get sorted out but just removing CM_PIC doesn't really get us there. > Signed-off-by: Vineet Gupta <vineetg@rivosinc.com> > --- > gcc/config/riscv/riscv-c.cc | 4 ---- > gcc/config/riscv/riscv-opts.h | 3 +-- > gcc/config/riscv/riscv.cc | 2 +- > 3 files changed, 2 insertions(+), 7 deletions(-) > > diff --git a/gcc/config/riscv/riscv-c.cc b/gcc/config/riscv/riscv-c.cc > index bba72cf77a82..7064fcf142fe 100644 > --- a/gcc/config/riscv/riscv-c.cc > +++ b/gcc/config/riscv/riscv-c.cc > @@ -92,13 +92,9 @@ riscv_cpu_cpp_builtins (cpp_reader *pfile) > builtin_define ("__riscv_cmodel_medlow"); > break; > > - case CM_PIC: > - /* FALLTHROUGH. */ > - > case CM_MEDANY: > builtin_define ("__riscv_cmodel_medany"); > break; > - > } > > if (TARGET_MIN_VLEN != 0) > diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h > index 85e869e62e3a..ce3237beca7a 100644 > --- a/gcc/config/riscv/riscv-opts.h > +++ b/gcc/config/riscv/riscv-opts.h > @@ -34,8 +34,7 @@ extern enum riscv_abi_type riscv_abi; > > enum riscv_code_model { > CM_MEDLOW, > - CM_MEDANY, > - CM_PIC > + CM_MEDANY > }; > extern enum riscv_code_model riscv_cmodel; > > diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc > index 7c120eaa8e33..a239fe43047c 100644 > --- a/gcc/config/riscv/riscv.cc > +++ b/gcc/config/riscv/riscv.cc > @@ -5162,7 +5162,7 @@ riscv_option_override (void) > init_machine_status = &riscv_init_machine_status; > > if (flag_pic) > - riscv_cmodel = CM_PIC; > + riscv_cmodel = CM_MEDANY; > > /* We get better code with explicit relocs for CM_MEDLOW, but > worse code for the others (for now). Pick the best default. */ I'm fine either way on this one: having CM_PIC gone makes it a bit more likely to confuse CM_MEDANY with PIC, but flag_pic is overriding riscv_cmodel anyway so this isn't really used and deleting code is always a plus.
On 8/31/22 07:57, Palmer Dabbelt wrote: >> if (flag_pic) >> - riscv_cmodel = CM_PIC; >> + riscv_cmodel = CM_MEDANY; >> >> /* We get better code with explicit relocs for CM_MEDLOW, but >> worse code for the others (for now). Pick the best default. */ > > I'm fine either way on this one: having CM_PIC gone makes it a bit > more likely to confuse CM_MEDANY with PIC, but flag_pic is overriding > riscv_cmodel anyway so this isn't really used and deleting code is > always a plus. Indeed this was the most contentious part of removing CM_PIC, but it seems this is the way fwd. I'll add Kito's comment from [1] in code to make it more explicit. [1]https://github.com/riscv-non-isa/riscv-c-api-doc/pull/11#issuecomment-686385585 Thx, -Vineett
On 8/31/22 13:39, Vineet Gupta wrote: > > > On 8/31/22 07:57, Palmer Dabbelt wrote: >>> if (flag_pic) >>> - riscv_cmodel = CM_PIC; >>> + riscv_cmodel = CM_MEDANY; >>> >>> /* We get better code with explicit relocs for CM_MEDLOW, but >>> worse code for the others (for now). Pick the best default. */ >> >> I'm fine either way on this one: having CM_PIC gone makes it a bit >> more likely to confuse CM_MEDANY with PIC, but flag_pic is overriding >> riscv_cmodel anyway so this isn't really used and deleting code is >> always a plus. > > Indeed this was the most contentious part of removing CM_PIC, but it > seems this is the way fwd. I'll add Kito's comment from [1] in code to > make it more explicit. > > [1]https://github.com/riscv-non-isa/riscv-c-api-doc/pull/11#issuecomment-686385585 I think I'll punt on this one, in the short-term. The reason being it affects USE_LOAD_ADDRESS_MACRO. #define USE_LOAD_ADDRESS_MACRO(sym) \ (!TARGET_EXPLICIT_RELOCS && \ ((flag_pic \ && ((SYMBOL_REF_P (sym) && SYMBOL_REF_LOCAL_P (sym)) \ || ((GET_CODE (sym) == CONST) \ && SYMBOL_REF_P (XEXP (XEXP (sym, 0),0)) \ && SYMBOL_REF_LOCAL_P (XEXP (XEXP (sym, 0),0))))) \ || riscv_cmodel == CM_MEDANY)) With the patch, PIC implies CM_MEDANY and thus will change codegen for pic non-local symbols to also use the load address macro. I think we want to go in the opposite direction, i.e. wean away from the asm macros and have gcc codegen natively. It seems there are bugs in that area so once we flush them out (after creating a few as I don't know of any existing documented ones) this will get cleaned out. Thx -Vineet
diff --git a/gcc/config/riscv/riscv-c.cc b/gcc/config/riscv/riscv-c.cc index bba72cf77a82..7064fcf142fe 100644 --- a/gcc/config/riscv/riscv-c.cc +++ b/gcc/config/riscv/riscv-c.cc @@ -92,13 +92,9 @@ riscv_cpu_cpp_builtins (cpp_reader *pfile) builtin_define ("__riscv_cmodel_medlow"); break; - case CM_PIC: - /* FALLTHROUGH. */ - case CM_MEDANY: builtin_define ("__riscv_cmodel_medany"); break; - } if (TARGET_MIN_VLEN != 0) diff --git a/gcc/config/riscv/riscv-opts.h b/gcc/config/riscv/riscv-opts.h index 85e869e62e3a..ce3237beca7a 100644 --- a/gcc/config/riscv/riscv-opts.h +++ b/gcc/config/riscv/riscv-opts.h @@ -34,8 +34,7 @@ extern enum riscv_abi_type riscv_abi; enum riscv_code_model { CM_MEDLOW, - CM_MEDANY, - CM_PIC + CM_MEDANY }; extern enum riscv_code_model riscv_cmodel; diff --git a/gcc/config/riscv/riscv.cc b/gcc/config/riscv/riscv.cc index 7c120eaa8e33..a239fe43047c 100644 --- a/gcc/config/riscv/riscv.cc +++ b/gcc/config/riscv/riscv.cc @@ -5162,7 +5162,7 @@ riscv_option_override (void) init_machine_status = &riscv_init_machine_status; if (flag_pic) - riscv_cmodel = CM_PIC; + riscv_cmodel = CM_MEDANY; /* We get better code with explicit relocs for CM_MEDLOW, but worse code for the others (for now). Pick the best default. */