| Message ID | 20211008024016.2625-1-kito.cheng@sifive.com |
|---|---|
| State | Committed |
| Commit | 4e5bc4e4506a7ae7bb88fc925a425652a1da6b2d |
| Headers |
Return-Path: <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> 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 6607C3857C4A for <patchwork@sourceware.org>; Fri, 8 Oct 2021 02:40:38 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id B8E07385840E for <gcc-patches@gcc.gnu.org>; Fri, 8 Oct 2021 02:40:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B8E07385840E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=sifive.com Received: by mail-pl1-x62d.google.com with SMTP id n2so5165135plk.12 for <gcc-patches@gcc.gnu.org>; Thu, 07 Oct 2021 19:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e81LmimqvXp7h5S/rNWwJKIuM9tvRnoU4FwH5mKQpNs=; b=fnZyuE4A7OZ619RpPff/vUwPUdiwPcqpikuwRZvBdBc3hswo9VkdofCVly0nktzoqV cBAYA8V0PlzACZOYSDHRA0lCvLOIniRyCL1Pw1WEXg3N/cc+QjcJDU/AKBxJggDx2uaS i80o3Nfyn7EqAGkR/d4WgeAtO//yZB64fHQHlZmYwBrYMVQyL+I/RDxrE4W4++uZLskX VdVpVnhEW/BrTrGrLUiz1WosHLTrBRnJaHAMsohz9Kzc//vkqxpQ+mXEuwztI/m2u2vb mFND/ijCQwTI2F8K98d9ympY3Wzvg9yAA1KBdrkcTt3+Wm3pY4p2LR1y2oCUcNkJd8gC Y1tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=e81LmimqvXp7h5S/rNWwJKIuM9tvRnoU4FwH5mKQpNs=; b=RPY8ZVcnpMPxsx5k3GxswsTxFd+Pbp+QzppsfHdfviolM0ZWxHmOHrzqAissAs3zTi s8sCHXPFhq/zD29tiOYqYNhjHFDOS+b49Hvr6eKs9o3rfz5EUEOfQ9Mf92C45hoPZr1U 0bUNA0gJxM6hzBD2YbtoTEAdYUlFVdIXRTlnWZAPfNZiFEHJZNAKa2kQjfUjfoP+Lqmy d0fTyU98iYqTDUBXchNdrLk/UXX6Iit/npKkucIk8iPZ/RE7PoNYk/pCcr40qWcP5zeI bCrzVKerpHYzbU0mo8QyJop6mRc+2835TvjT1ZxBusI4RMDMG7WWWCtTKf+QyulTpytz m0fA== X-Gm-Message-State: AOAM533UWy322sTJex6HWAI/GsgYIkWAkSfdeQkVUq5TbMlHrAU0t678 jgumDGKzYmNOyJ1SKrdcoFK64KB1tFV1Vw== X-Google-Smtp-Source: ABdhPJwQa9I6iTWF+CYFGpnF8Z51lnvKllLjlZy9sFB7U6VBHu9hXMGdWYESF1W/j6dQVunNWbCJRA== X-Received: by 2002:a17:902:c407:b0:13f:68f:6753 with SMTP id k7-20020a170902c40700b0013f068f6753mr6473288plk.39.1633660820301; Thu, 07 Oct 2021 19:40:20 -0700 (PDT) Received: from hsinchu02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id o2sm9581559pja.7.2021.10.07.19.40.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 19:40:19 -0700 (PDT) From: Kito Cheng <kito.cheng@sifive.com> To: gcc-patches@gcc.gnu.org, kito.cheng@gmail.com, jimw@sifive.com, christophm30@gmail.com, oliva@adacore.com, pinskia@gmail.com Subject: [PATCH v3] [PR/target 100316] Allow constant address for __builtin___clear_cache. Date: Fri, 8 Oct 2021 10:40:16 +0800 Message-Id: <20211008024016.2625-1-kito.cheng@sifive.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.6 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.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Kito Cheng <kito.cheng@sifive.com> Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org> |
| Series |
[v3,PR/target,100316] Allow constant address for __builtin___clear_cache.
|
|
Commit Message
Kito Cheng
Oct. 8, 2021, 2:40 a.m. UTC
__builtin___clear_cache was able to accept constant address for the
argument, but it seems no longer accept recently, and it even not
accept constant address which is hold in variable when optimization is
enable:
```
void foo3(){
void *yy = (void*)0x1000;
__builtin___clear_cache(yy, yy);
}
```
So this patch make BEGIN and END accept VOIDmode, like cselib_lookup_mem did per
Jim Wilson's suggestion.
```
static cselib_val *
cselib_lookup_mem (rtx x, int create)
{
...
addr_mode = GET_MODE (XEXP (x, 0));
if (addr_mode == VOIDmode)
addr_mode = Pmode;
```
Changes v2 -> v3:
- Use gcc_assert rather than error, maybe_emit_call_builtin___clear_cache is
internal use only, and we already checked the type in other place.
Changes v1 -> v2:
- Check is CONST_INT intead of cehck mode, no new testcase, since
constant value with other type like CONST_DOUBLE will catched by
front-end.
e.g.
Code:
```c
void foo(){
__builtin___clear_cache(1.11, 0);
}
```
Error message:
```
clearcache-double.c: In function 'foo':
clearcache-double.c:2:27: error: incompatible type for argument 1 of '__builtin___clear_cache'
2 | __builtin___clear_cache(1.11, 0);
| ^~~~
| |
| double
clearcache-double.c:2:27: note: expected 'void *' but argument is of type 'double'
```
gcc/ChangeLog:
PR target/100316
* builtins.c (maybe_emit_call_builtin___clear_cache): Allow
CONST_INT for BEGIN and END, and use gcc_assert rather than
error.
gcc/testsuite/ChangeLog:
PR target/100316
* gcc.c-torture/compile/pr100316.c: New.
---
gcc/builtins.c | 10 ++++------
gcc/testsuite/gcc.c-torture/compile/pr100316.c | 18 ++++++++++++++++++
2 files changed, 22 insertions(+), 6 deletions(-)
create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr100316.c
Comments
On Fri, Oct 8, 2021 at 4:40 AM Kito Cheng <kito.cheng@sifive.com> wrote: > > __builtin___clear_cache was able to accept constant address for the > argument, but it seems no longer accept recently, and it even not > accept constant address which is hold in variable when optimization is > enable: > > ``` > void foo3(){ > void *yy = (void*)0x1000; > __builtin___clear_cache(yy, yy); > } > ``` > > So this patch make BEGIN and END accept VOIDmode, like cselib_lookup_mem did per > Jim Wilson's suggestion. > > ``` > static cselib_val * > cselib_lookup_mem (rtx x, int create) > { > ... > addr_mode = GET_MODE (XEXP (x, 0)); > if (addr_mode == VOIDmode) > addr_mode = Pmode; > ``` > > Changes v2 -> v3: > - Use gcc_assert rather than error, maybe_emit_call_builtin___clear_cache is > internal use only, and we already checked the type in other place. > > Changes v1 -> v2: > - Check is CONST_INT intead of cehck mode, no new testcase, since > constant value with other type like CONST_DOUBLE will catched by > front-end. > e.g. > Code: > ```c > void foo(){ > __builtin___clear_cache(1.11, 0); > } > ``` > Error message: > ``` > clearcache-double.c: In function 'foo': > clearcache-double.c:2:27: error: incompatible type for argument 1 of '__builtin___clear_cache' > 2 | __builtin___clear_cache(1.11, 0); > | ^~~~ > | | > | double > clearcache-double.c:2:27: note: expected 'void *' but argument is of type 'double' > ``` > > gcc/ChangeLog: > > PR target/100316 > * builtins.c (maybe_emit_call_builtin___clear_cache): Allow > CONST_INT for BEGIN and END, and use gcc_assert rather than > error. > > gcc/testsuite/ChangeLog: > > PR target/100316 > * gcc.c-torture/compile/pr100316.c: New. > --- > gcc/builtins.c | 10 ++++------ > gcc/testsuite/gcc.c-torture/compile/pr100316.c | 18 ++++++++++++++++++ > 2 files changed, 22 insertions(+), 6 deletions(-) > create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr100316.c > > diff --git a/gcc/builtins.c b/gcc/builtins.c > index 3e57eb03af0..80a1bb191c6 100644 > --- a/gcc/builtins.c > +++ b/gcc/builtins.c > @@ -5163,12 +5163,10 @@ default_emit_call_builtin___clear_cache (rtx begin, rtx end) > void > maybe_emit_call_builtin___clear_cache (rtx begin, rtx end) > { > - if ((GET_MODE (begin) != ptr_mode && GET_MODE (begin) != Pmode) > - || (GET_MODE (end) != ptr_mode && GET_MODE (end) != Pmode)) > - { > - error ("both arguments to %<__builtin___clear_cache%> must be pointers"); > - return; > - } > + gcc_assert ((GET_MODE (begin) == ptr_mode || GET_MODE (begin) == Pmode > + || CONST_INT_P (begin)) > + && (GET_MODE (end) == ptr_mode || GET_MODE (end) == Pmode > + || CONST_INT_P (end))); OK I guess. I'm not 100% sure we might not ICE here when using __builtin_clear_cache on a pointer with some other than the default address-space which might have a mode that's not ptr_mode or Pmode? Thanks, Richard. > if (targetm.have_clear_cache ()) > { > diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100316.c b/gcc/testsuite/gcc.c-torture/compile/pr100316.c > new file mode 100644 > index 00000000000..38eca86f49f > --- /dev/null > +++ b/gcc/testsuite/gcc.c-torture/compile/pr100316.c > @@ -0,0 +1,18 @@ > +void foo(){ > + __builtin___clear_cache(0, 0); > +} > + > +void foo1(){ > + __builtin___clear_cache((void*)0, (void*)0); > +} > + > +void foo2(){ > + void *yy = 0; > + __builtin___clear_cache(yy, yy); > +} > + > +void foo3(){ > + void *yy = (void*)0x1000; > + __builtin___clear_cache(yy, yy); > +} > + > -- > 2.33.0 >
Hi Richard:
Test with x86 and rl78, both are rejected by the front-end if modes
are different from Pmode/ptr_mode,
so I'm gonna commit this change :)
Testcase for x86 / x86_64:
```
void test(void)
{
int __seg_fs *f = (int __seg_fs *)16;
int __seg_fs *g = (int __seg_fs *)32;
__builtin___clear_cache (f, g); // error: passing argument 1 of
‘__builtin___clear_cache’ from pointer to non-enclosed address space
}
```
Testcase for rl78 (Pmode == HImode):
```
void test(void)
{
int __near *f = (int __near *)16; // mode == HImode, same as Pmode
int __near *g = (int __near *)32;
__builtin___clear_cache (f, g); // OK to compile
}
void test2(void)
{
int __far *f = (int __far *)16; // mode == SImode
int __far *g = (int __far *)32;
__builtin___clear_cache (f, g); // error: passing argument 1 of
‘__builtin___clear_cache’ from pointer to non-enclosed address space
}
```
On Fri, Oct 8, 2021 at 2:47 PM Richard Biener
<richard.guenther@gmail.com> wrote:
>
> On Fri, Oct 8, 2021 at 4:40 AM Kito Cheng <kito.cheng@sifive.com> wrote:
> >
> > __builtin___clear_cache was able to accept constant address for the
> > argument, but it seems no longer accept recently, and it even not
> > accept constant address which is hold in variable when optimization is
> > enable:
> >
> > ```
> > void foo3(){
> > void *yy = (void*)0x1000;
> > __builtin___clear_cache(yy, yy);
> > }
> > ```
> >
> > So this patch make BEGIN and END accept VOIDmode, like cselib_lookup_mem did per
> > Jim Wilson's suggestion.
> >
> > ```
> > static cselib_val *
> > cselib_lookup_mem (rtx x, int create)
> > {
> > ...
> > addr_mode = GET_MODE (XEXP (x, 0));
> > if (addr_mode == VOIDmode)
> > addr_mode = Pmode;
> > ```
> >
> > Changes v2 -> v3:
> > - Use gcc_assert rather than error, maybe_emit_call_builtin___clear_cache is
> > internal use only, and we already checked the type in other place.
> >
> > Changes v1 -> v2:
> > - Check is CONST_INT intead of cehck mode, no new testcase, since
> > constant value with other type like CONST_DOUBLE will catched by
> > front-end.
> > e.g.
> > Code:
> > ```c
> > void foo(){
> > __builtin___clear_cache(1.11, 0);
> > }
> > ```
> > Error message:
> > ```
> > clearcache-double.c: In function 'foo':
> > clearcache-double.c:2:27: error: incompatible type for argument 1 of '__builtin___clear_cache'
> > 2 | __builtin___clear_cache(1.11, 0);
> > | ^~~~
> > | |
> > | double
> > clearcache-double.c:2:27: note: expected 'void *' but argument is of type 'double'
> > ```
> >
> > gcc/ChangeLog:
> >
> > PR target/100316
> > * builtins.c (maybe_emit_call_builtin___clear_cache): Allow
> > CONST_INT for BEGIN and END, and use gcc_assert rather than
> > error.
> >
> > gcc/testsuite/ChangeLog:
> >
> > PR target/100316
> > * gcc.c-torture/compile/pr100316.c: New.
> > ---
> > gcc/builtins.c | 10 ++++------
> > gcc/testsuite/gcc.c-torture/compile/pr100316.c | 18 ++++++++++++++++++
> > 2 files changed, 22 insertions(+), 6 deletions(-)
> > create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr100316.c
> >
> > diff --git a/gcc/builtins.c b/gcc/builtins.c
> > index 3e57eb03af0..80a1bb191c6 100644
> > --- a/gcc/builtins.c
> > +++ b/gcc/builtins.c
> > @@ -5163,12 +5163,10 @@ default_emit_call_builtin___clear_cache (rtx begin, rtx end)
> > void
> > maybe_emit_call_builtin___clear_cache (rtx begin, rtx end)
> > {
> > - if ((GET_MODE (begin) != ptr_mode && GET_MODE (begin) != Pmode)
> > - || (GET_MODE (end) != ptr_mode && GET_MODE (end) != Pmode))
> > - {
> > - error ("both arguments to %<__builtin___clear_cache%> must be pointers");
> > - return;
> > - }
> > + gcc_assert ((GET_MODE (begin) == ptr_mode || GET_MODE (begin) == Pmode
> > + || CONST_INT_P (begin))
> > + && (GET_MODE (end) == ptr_mode || GET_MODE (end) == Pmode
> > + || CONST_INT_P (end)));
>
> OK I guess.
>
> I'm not 100% sure we might not ICE here when using
> __builtin_clear_cache on a pointer
> with some other than the default address-space which might have a mode
> that's not
> ptr_mode or Pmode?
>
> Thanks,
> Richard.
>
> > if (targetm.have_clear_cache ())
> > {
> > diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100316.c b/gcc/testsuite/gcc.c-torture/compile/pr100316.c
> > new file mode 100644
> > index 00000000000..38eca86f49f
> > --- /dev/null
> > +++ b/gcc/testsuite/gcc.c-torture/compile/pr100316.c
> > @@ -0,0 +1,18 @@
> > +void foo(){
> > + __builtin___clear_cache(0, 0);
> > +}
> > +
> > +void foo1(){
> > + __builtin___clear_cache((void*)0, (void*)0);
> > +}
> > +
> > +void foo2(){
> > + void *yy = 0;
> > + __builtin___clear_cache(yy, yy);
> > +}
> > +
> > +void foo3(){
> > + void *yy = (void*)0x1000;
> > + __builtin___clear_cache(yy, yy);
> > +}
> > +
> > --
> > 2.33.0
> >
Committed to trunk :) On Mon, Oct 11, 2021 at 11:23 AM Kito Cheng <kito.cheng@sifive.com> wrote: > > Hi Richard: > > Test with x86 and rl78, both are rejected by the front-end if modes > are different from Pmode/ptr_mode, > so I'm gonna commit this change :) > > Testcase for x86 / x86_64: > ``` > void test(void) > { > int __seg_fs *f = (int __seg_fs *)16; > int __seg_fs *g = (int __seg_fs *)32; > __builtin___clear_cache (f, g); // error: passing argument 1 of > ‘__builtin___clear_cache’ from pointer to non-enclosed address space > } > ``` > > Testcase for rl78 (Pmode == HImode): > ``` > void test(void) > { > int __near *f = (int __near *)16; // mode == HImode, same as Pmode > int __near *g = (int __near *)32; > __builtin___clear_cache (f, g); // OK to compile > } > > void test2(void) > { > int __far *f = (int __far *)16; // mode == SImode > int __far *g = (int __far *)32; > __builtin___clear_cache (f, g); // error: passing argument 1 of > ‘__builtin___clear_cache’ from pointer to non-enclosed address space > } > ``` > > On Fri, Oct 8, 2021 at 2:47 PM Richard Biener > <richard.guenther@gmail.com> wrote: > > > > On Fri, Oct 8, 2021 at 4:40 AM Kito Cheng <kito.cheng@sifive.com> wrote: > > > > > > __builtin___clear_cache was able to accept constant address for the > > > argument, but it seems no longer accept recently, and it even not > > > accept constant address which is hold in variable when optimization is > > > enable: > > > > > > ``` > > > void foo3(){ > > > void *yy = (void*)0x1000; > > > __builtin___clear_cache(yy, yy); > > > } > > > ``` > > > > > > So this patch make BEGIN and END accept VOIDmode, like cselib_lookup_mem did per > > > Jim Wilson's suggestion. > > > > > > ``` > > > static cselib_val * > > > cselib_lookup_mem (rtx x, int create) > > > { > > > ... > > > addr_mode = GET_MODE (XEXP (x, 0)); > > > if (addr_mode == VOIDmode) > > > addr_mode = Pmode; > > > ``` > > > > > > Changes v2 -> v3: > > > - Use gcc_assert rather than error, maybe_emit_call_builtin___clear_cache is > > > internal use only, and we already checked the type in other place. > > > > > > Changes v1 -> v2: > > > - Check is CONST_INT intead of cehck mode, no new testcase, since > > > constant value with other type like CONST_DOUBLE will catched by > > > front-end. > > > e.g. > > > Code: > > > ```c > > > void foo(){ > > > __builtin___clear_cache(1.11, 0); > > > } > > > ``` > > > Error message: > > > ``` > > > clearcache-double.c: In function 'foo': > > > clearcache-double.c:2:27: error: incompatible type for argument 1 of '__builtin___clear_cache' > > > 2 | __builtin___clear_cache(1.11, 0); > > > | ^~~~ > > > | | > > > | double > > > clearcache-double.c:2:27: note: expected 'void *' but argument is of type 'double' > > > ``` > > > > > > gcc/ChangeLog: > > > > > > PR target/100316 > > > * builtins.c (maybe_emit_call_builtin___clear_cache): Allow > > > CONST_INT for BEGIN and END, and use gcc_assert rather than > > > error. > > > > > > gcc/testsuite/ChangeLog: > > > > > > PR target/100316 > > > * gcc.c-torture/compile/pr100316.c: New. > > > --- > > > gcc/builtins.c | 10 ++++------ > > > gcc/testsuite/gcc.c-torture/compile/pr100316.c | 18 ++++++++++++++++++ > > > 2 files changed, 22 insertions(+), 6 deletions(-) > > > create mode 100644 gcc/testsuite/gcc.c-torture/compile/pr100316.c > > > > > > diff --git a/gcc/builtins.c b/gcc/builtins.c > > > index 3e57eb03af0..80a1bb191c6 100644 > > > --- a/gcc/builtins.c > > > +++ b/gcc/builtins.c > > > @@ -5163,12 +5163,10 @@ default_emit_call_builtin___clear_cache (rtx begin, rtx end) > > > void > > > maybe_emit_call_builtin___clear_cache (rtx begin, rtx end) > > > { > > > - if ((GET_MODE (begin) != ptr_mode && GET_MODE (begin) != Pmode) > > > - || (GET_MODE (end) != ptr_mode && GET_MODE (end) != Pmode)) > > > - { > > > - error ("both arguments to %<__builtin___clear_cache%> must be pointers"); > > > - return; > > > - } > > > + gcc_assert ((GET_MODE (begin) == ptr_mode || GET_MODE (begin) == Pmode > > > + || CONST_INT_P (begin)) > > > + && (GET_MODE (end) == ptr_mode || GET_MODE (end) == Pmode > > > + || CONST_INT_P (end))); > > > > OK I guess. > > > > I'm not 100% sure we might not ICE here when using > > __builtin_clear_cache on a pointer > > with some other than the default address-space which might have a mode > > that's not > > ptr_mode or Pmode? > > > > Thanks, > > Richard. > > > > > if (targetm.have_clear_cache ()) > > > { > > > diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100316.c b/gcc/testsuite/gcc.c-torture/compile/pr100316.c > > > new file mode 100644 > > > index 00000000000..38eca86f49f > > > --- /dev/null > > > +++ b/gcc/testsuite/gcc.c-torture/compile/pr100316.c > > > @@ -0,0 +1,18 @@ > > > +void foo(){ > > > + __builtin___clear_cache(0, 0); > > > +} > > > + > > > +void foo1(){ > > > + __builtin___clear_cache((void*)0, (void*)0); > > > +} > > > + > > > +void foo2(){ > > > + void *yy = 0; > > > + __builtin___clear_cache(yy, yy); > > > +} > > > + > > > +void foo3(){ > > > + void *yy = (void*)0x1000; > > > + __builtin___clear_cache(yy, yy); > > > +} > > > + > > > -- > > > 2.33.0 > > >
diff --git a/gcc/builtins.c b/gcc/builtins.c index 3e57eb03af0..80a1bb191c6 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -5163,12 +5163,10 @@ default_emit_call_builtin___clear_cache (rtx begin, rtx end) void maybe_emit_call_builtin___clear_cache (rtx begin, rtx end) { - if ((GET_MODE (begin) != ptr_mode && GET_MODE (begin) != Pmode) - || (GET_MODE (end) != ptr_mode && GET_MODE (end) != Pmode)) - { - error ("both arguments to %<__builtin___clear_cache%> must be pointers"); - return; - } + gcc_assert ((GET_MODE (begin) == ptr_mode || GET_MODE (begin) == Pmode + || CONST_INT_P (begin)) + && (GET_MODE (end) == ptr_mode || GET_MODE (end) == Pmode + || CONST_INT_P (end))); if (targetm.have_clear_cache ()) { diff --git a/gcc/testsuite/gcc.c-torture/compile/pr100316.c b/gcc/testsuite/gcc.c-torture/compile/pr100316.c new file mode 100644 index 00000000000..38eca86f49f --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/compile/pr100316.c @@ -0,0 +1,18 @@ +void foo(){ + __builtin___clear_cache(0, 0); +} + +void foo1(){ + __builtin___clear_cache((void*)0, (void*)0); +} + +void foo2(){ + void *yy = 0; + __builtin___clear_cache(yy, yy); +} + +void foo3(){ + void *yy = (void*)0x1000; + __builtin___clear_cache(yy, yy); +} +