gcc-14-20250322 is now available

2025-03-22 Thread GCC Administrator via Gcc
Snapshot gcc-14-20250322 is now available on
  https://gcc.gnu.org/pub/gcc/snapshots/14-20250322/
and on various mirrors, see https://gcc.gnu.org/mirrors.html for details.

This snapshot has been generated from the GCC 14 git branch
with the following options: git://gcc.gnu.org/git/gcc.git branch 
releases/gcc-14 revision a3989d8158705975ab72c9167469905cbe7d11cf

You'll find:

 gcc-14-20250322.tar.xz   Complete GCC

  SHA256=23744e8625388d8681d9a722d99dc1fe6bcb2d38c1068085d422fbba21d39943
  SHA1=2cc50237994e40987113b4f92ba4f0645fea8097

Diffs from 14-20250315 are available in the diffs/ subdirectory.

When a particular snapshot is ready for public consumption the LATEST-14
link is updated and a message is sent to the gcc list.  Please do not use
a snapshot before it has been announced that way.


libgcc: Disable building shared objects ?

2025-03-22 Thread Georg-Johann Lay via Gcc

For avr, there is no support for shared objects, yet
when building libgcc, for each module.o there is also module_s.o
that's build with -DSHARED.

How can this be turned off?

What doesn't word is to configure with --disable-shared, and even
without turning it off by hand, there is no use for module_s.o stuff.

These objects are just boosting the build time for the > 60 multilib
variants by 100%.

What also doesn't work it to set libgcc-s-objects to empty in t-avr.

Thanks, Johann


Re: libgcc: Disable building shared objects ?

2025-03-22 Thread Georg-Johann Lay via Gcc

Am 21.03.25 um 08:58 schrieb Richard Biener:

On Thu, Mar 20, 2025 at 8:05 PM Georg-Johann Lay via Gcc
 wrote:


For avr, there is no support for shared objects, yet
when building libgcc, for each module.o there is also module_s.o
that's build with -DSHARED.

How can this be turned off?

What doesn't word is to configure with --disable-shared, and even
without turning it off by hand, there is no use for module_s.o stuff.


--disable-shared should work and ideally also avoid building the object
files.  It sounds like a missed opportunity in libgcc/Makefile.in - that
already guards pieces with ifeq ($(enable_shared),yes), but obviously
not some bits that trigger building the shared objects ...


But where in Makefile.in?  There is this sequence that deals with
LIB1ASMFUNCS + shared:

lib1asmfuncs-s-o = $(patsubst %,%_s$(objext),$(LIB1ASMFUNCS))
$(lib1asmfuncs-s-o): %_s$(objext): $(srcdir)/config/$(LIB1ASMSRC)
$(gcc_s_compile) -DL$* -xassembler-with-cpp -c $<
ifeq ($(enable_shared),yes)

libgcc-s-objects += $(lib1asmfuncs-s-o)

endif

Not adding the objects to libgcc-s-objects should be enough. No?

Johann


These objects are just boosting the build time for the > 60 multilib
variants by 100%.

What also doesn't work it to set libgcc-s-objects to empty in t-avr.

Thanks, Johann


Newcomer seeking Guidance on contributing GCC

2025-03-22 Thread mannem navyasree via Gcc
Hi, I’m Navya sree mannem , new to GCC. I’d like to learn how to
contribute, maybe in improving GCC’s optimization passes to make compiled
code faster. Can anyone suggest a starting point or mentor me?”


Re: Pointer semantics in GIMPLE

2025-03-22 Thread Krister Walfridsson via Gcc

On Thu, 20 Mar 2025, Richard Biener wrote:


Pointer arithmetic -- POINTER_DIFF_EXPR
---
Subtracting a pointer q from a pointer p is done using POINTER_DIFF_EXPR.
  * It is UB if the difference does not fit in a signed integer with the
same precision as the pointers.


Yep.


This implies that an object's size must be less than half the address
space; otherwise, POINTER_DIFF_EXPR cannot be used to compute sizes in C.
But there may be additional restrictions. For example, compiling the
function:

   void foo(int *p, int *q, int n)
   {
 for (int i = 0; i < n; i++)
   p[i] = q[i] + 1;
   }

causes the vectorized code to perform overlap checks like:

   _7 = q_11(D) + 4;
   _25 = p_12(D) - _7;
   _26 = (sizetype) _25;
   _27 = _26 > 8;
   _28 = _27;
   if (_28 != 0)
 goto ;
   else
 goto ;

which takes the difference between two pointers that may point to
different objects. This suggests that all objects must fit within half the
address space.


Interesting detail.  But yes, the above is either incorrect code (I didn't
double-check) or this condition must hold.  For 64bit virtual address-space
it likely holds in practice.  For 32bit virtual address-space it might not.


Question: What are the restrictions on valid address ranges and object
sizes?


The restriction on object size is documented, as well as that objects
may not cross/include 'NULL'.  Can you open a bugreport for the
vectorizer overlap test issue above?  I think we want to track this and
at least document the restriction (we could possibly add a target hook
that can tell whether such a simplified check is OK).


PR119399



Issues
--
The semantics I've described above result in many reports of
miscompilations that I haven't reported yet.

As mentioned earlier, the vectorizer can use POINTER_PLUS_EXPR to generate
pointers that extend up to a vector length past the object (and similarly,
up to one vector length before the object in a backwards loop). This is
invalid if the object is too close to address 0 or 0x.

And this out of bounds distance can be made arbitrarily large, as can be
seen by compiling the following function below for x86_64 with -O3:

void foo(int *p, uint64_t s, int64_t n)
{
   for (int64_t i = 0; i < n; i++)
 {
   int *q = p + i * s;
   for (int j = 0; j < 4; j++)
*q++ = j;
 }
}

Here, the vectorized code add s * 4 to the pointer ivtmp_8 at the end of
each iteration:

:
   bnd.8_38 = (unsigned long) n_10(D);
   _21 = s_11(D) * 4;

:
   # ivtmp_8 = PHI 
   # ivtmp_26 = PHI 
   MEM  [(int *)ivtmp_8] = { 0, 1, 2, 3 };
   ivtmp_7 = ivtmp_8 + _21;
   ivtmp_20 = ivtmp_26 + 1;
   if (ivtmp_20 < bnd.8_38)
 goto ;
   else
 goto ;

:
   goto ;

This means calling foo with a sufficiently large s can guarantee wrapping
or evaluating to 0, even though the original IR before optimization did
not wrap or evaluating to 0. For example, when calling foo as:

   foo(p, -((uintptr_t)p / 4), 1);

I guess this is essentially the same issue as PR113590, and could be fixed
by moving all induction variable updates to the latch.


Yes.

But if that

happens, the motivating examples for needing to handle invalid pointer
values would no longer occur. Would that mean smtgcc should adopt a more
restrictive semantics for pointer values?


In principle yes, but PR113590 blocks this I guess.  Could smtgcc consider
a SSA def to be happening only at the latest possible point, that is,
"virtually"
sink it to the latch?  (I realize when you have two dependent defs that can
be moved together only such "virtual" sinking could be somewhat complicated)


I think it feels a bit strange (and brittle) to define the semantics by 
virtually sinking everything as much as possible. But isn't this sinking 
just another way of saying that the operation is UB only if the value is 
used? That is, we can solve this essentially the same way LLVM does with 
its deferred UB.


The idea is that POINTER_DIFF_EXPR, PLUS_EXPR, etc. are defined for all 
inputs, but the result is a poison value when it doesn't fit in the return 
type. Any use of a poison value is UB.


This is trivial to implement in smtgcc and would solve PR113590.

   /Krister