Re: [PATCH v2] OpenMP: Use VOID_TYPE_P to check for void return type in SIMD function clones.
Andrea Pinski <[email protected]>
| Newsgroups | gmane.comp.gcc.patches |
|---|---|
| Message-ID | <CALvbMcD-eGRNc2YaifpYwc+fK+8J6YF3oNjkW8Ecmr40rVz00g@mail.gmail.com> |
On Sat, Aug 8, 2026 at 3:52 AM Kevin Stefanov <[email protected]> wrote: > > This change fixes an issue where functions > decorated with: > pragma omp declare simd > that return void via a typedef would crash > GCC with an ICE while compiling a program > containing such a function, by using > VOID_TYPE_P instead of directly comparing > to void_type_node. New testcase added. > > PR middle-end/111856 > > gcc/ChangeLog: > > * omp-simd-clone.cc (simd_clone_adjust_return_type): Use VOID_TYPE_P > when checking for void return type in adjusted functions. > (simd_clone_adjust): Likewise. > > gcc/testsuite/ChangeLog: > > * gcc.dg/gomp/pr111856.c: New test. Pushed as r17-3156-ge212f5ef86f1a87c4471f8076a2cc6843ad10a20. Thanks again for fixing this. > > Signed-off-by: Kevin Stefanov <[email protected]> > --- > > I have replaced my previous use of > TREE_CODE with VOID_TYPE_P as per > the review and added a new test case > to compile the example openMP program > and ensure no ICE. > > Bugzilla link: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111856 > > I have been unable to check for merge > conflicts with trunk. Upon running: > git pull --rebase origin master > I get the following error: > fatal: unable to access 'https://gcc.gnu.org/git/gcc.git/': The requested URL returned error: 429 > I'm guessing this has to do with the > recently strengthened security measures > against LLM-related scraping bots? > > Bootstrapped and regression tested on > x86_64-pc-linux-gnu with enable-languages=all. > > > gcc/omp-simd-clone.cc | 4 ++-- > gcc/testsuite/gcc.dg/gomp/pr111856.c | 11 +++++++++++ > 2 files changed, 13 insertions(+), 2 deletions(-) > create mode 100644 gcc/testsuite/gcc.dg/gomp/pr111856.c > > diff --git a/gcc/omp-simd-clone.cc b/gcc/omp-simd-clone.cc > index 7564846fac4..4f189f243a0 100644 > --- a/gcc/omp-simd-clone.cc > +++ b/gcc/omp-simd-clone.cc > @@ -715,7 +715,7 @@ simd_clone_adjust_return_type (struct cgraph_node *node) > tree t; > > /* Adjust the function return type. */ > - if (orig_rettype == void_type_node) > + if (VOID_TYPE_P (orig_rettype)) > return; > t = TREE_TYPE (TREE_TYPE (fndecl)); > if (INTEGRAL_TYPE_P (t) || POINTER_TYPE_P (t)) > @@ -1370,7 +1370,7 @@ simd_clone_adjust (struct cgraph_node *node) > simd_clone_adjust_argument_types (node); > targetm.simd_clone.adjust (node); > tree retval = NULL_TREE; > - if (orig_rettype != void_type_node) > + if (!VOID_TYPE_P (orig_rettype)) > { > poly_uint64 veclen; > if (INTEGRAL_TYPE_P (orig_rettype) || POINTER_TYPE_P (orig_rettype)) > diff --git a/gcc/testsuite/gcc.dg/gomp/pr111856.c b/gcc/testsuite/gcc.dg/gomp/pr111856.c > new file mode 100644 > index 00000000000..ef162f58531 > --- /dev/null > +++ b/gcc/testsuite/gcc.dg/gomp/pr111856.c > @@ -0,0 +1,11 @@ > +/* PR middle-end/111856 */ > +/* { dg-do compile } */ > +/* { dg-options "-fopenmp-simd -O2" } */ > + > +typedef void T; > +int array[1000]; > +#pragma omp declare simd notinbranch simdlen(4) > +T foo (int i) > +{ > + array[i] = 555; > +} > -- > 2.55.0 >