[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-07-01 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Richard Biener  changed:

   What|Removed |Added

 Resolution|--- |INVALID
 Status|NEW |RESOLVED

--- Comment #16 from Richard Biener  ---
Thanks Jonathan.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-07-01 Thread redi at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #15 from Jonathan Wakely  ---
[expr.new] p14:

  An implementation is allowed to omit a call to a replaceable global
allocation
  function (17.6.3.2, 17.6.3.3). When it does so, the storage is instead
provided
  by the implementation or provided by extending the allocation of another
  new-expression.

So the testcase is invalid, and HJ's patch in comment 13 is needed (although
see https://inbox.sourceware.org/binutils/zojsfb_1fcmpf...@zen.kayari.org/ as I
think that has a different problem).

So I agree with INVALID.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-30 Thread rguenth at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Richard Biener  changed:

   What|Removed |Added

Version|unknown |15.0
 CC||jwakely at redhat dot com

--- Comment #14 from Richard Biener  ---
While we now take into account that new/delete might clobber global memory
(without -fassume-sane-operator-new being implemented) we still elide
new/delete pairs.  I think that is something the C++ standard allows
(even with insane new/delete operator), so I think this is a testsuite bug.

But I'm not really a C++ expert here (I'd close the bug as INVALID).

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-29 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #13 from H.J. Lu  ---
A binutils patch is posted at

https://sourceware.org/pipermail/binutils/2024-June/135259.html

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=110137

--- Comment #12 from Andrew Pinski  ---
See PR 110137 really.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-29 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

H.J. Lu  changed:

   What|Removed |Added

 Ever confirmed|0   |1
   Keywords||wrong-code
 Status|UNCONFIRMED |NEW
   Last reconfirmed||2024-06-30

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-29 Thread hjl.tools at gmail dot com via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #11 from H.J. Lu  ---
Created attachment 58541
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58541&action=edit
A testcase

[hjl@gnu-tgl-3 tmp]$ g++ -c -O2 x.cc -ansi
[hjl@gnu-tgl-3 tmp]$ readelf -rW x.o | c++filt | grep -E "(new|delete)"
000a  000c0004 R_X86_64_PLT32 
operator new[](unsigned long) - 4
0019  000d0004 R_X86_64_PLT32 
operator delete[](void*) - 4
0028  000f0004 R_X86_64_PLT32 
operator new[](unsigned long, std::nothrow_t const&) - 4
003c  000d0004 R_X86_64_PLT32 
operator delete[](void*) - 4
[hjl@gnu-tgl-3 tmp]$ /usr/gcc-15.0.0-x86-64/bin/g++ -c -O2 x.cc -ansi
[hjl@gnu-tgl-3 tmp]$ readelf -rW x.o | c++filt | grep -E "(new|delete)"
000f  000d0004 R_X86_64_PLT32 
operator new[](unsigned long, std::nothrow_t const&) - 4
001c  000e0004 R_X86_64_PLT32 
operator delete[](void*) - 4
[hjl@gnu-tgl-3 tmp]$ 

new and delete update "pass".  They can't be folded without updating "pass".

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Andrew Pinski  changed:

   What|Removed |Added

   Keywords|wrong-code  |

--- Comment #10 from Andrew Pinski  ---
Removing wrong-code since I don't think this is wrong code, I just think the
testcase is incorrect.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so) since r15-571-g1e0ae1f52741f7

2024-06-29 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Sam James  changed:

   What|Removed |Added

Summary|[15 regression] Binutils|[15 regression] Binutils
   |testsuite fails 2 tests |testsuite fails 2 tests
   |(libnew1a.so, libnew1b.so)  |(libnew1a.so, libnew1b.so)
   ||since
   ||r15-571-g1e0ae1f52741f7
   See Also||https://sourceware.org/bugz
   ||illa/show_bug.cgi?id=3831
 CC||hjl.tools at gmail dot com,
   ||rguenth at gcc dot gnu.org

--- Comment #9 from Sam James  ---
r15-571-g1e0ae1f52741f7

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=78104

--- Comment #8 from Andrew Pinski  ---
operator new/delete pairs have been optimized since PR 78104 was fixed in GCC
10. Just in this case the array makes the mechanism confused until now.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Andrew Pinski  changed:

   What|Removed |Added

   See Also||https://gcc.gnu.org/bugzill
   ||a/show_bug.cgi?id=104105

--- Comment #7 from Andrew Pinski  ---
Note the reason why the nothrow variant is not optimized away is recorded as PR
104105.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #6 from Andrew Pinski  ---
(In reply to Andrew Pinski from comment #5)
> r15-571-g1e0ae1f52741f7 is my guess.

The reason is the DSE is able to remove the store due to the clobbers and then
dce finally can remove the operator new/operator delete pair.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #5 from Andrew Pinski  ---
r15-571-g1e0ae1f52741f7 is my guess.

But this code is questionable.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread pinskia at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

Andrew Pinski  changed:

   What|Removed |Added

   Target Milestone|--- |15.0
 CC||pinskia at gcc dot gnu.org

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #4 from Sam James  ---
I'm going to bisect it next as C++ semantics with new/delete isn't something
I'm yet very experienced with.

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #3 from Sam James  ---
In cgraph:
```
@@ -1222,16 +1222,7 @@ _ZdaPv/82 (void operator delete [](void*))
   Referring:
   Availability: not_available
   Function flags: replaceable_operator_delete
-  Called by: main/76 (1073312328 (estimated locally),1.00 per call) main/76
(1073741824 (estimated locally),1.00 per call)
-  Calls:
-_Znam/81 (void* operator new [](std::size_t))
-  Type: function
-  Visibility: semantic_interposition external public visibility_specified
-  References:
-  Referring:
-  Availability: not_available
-  Function flags: decl_is_malloc replaceable_operator_new
-  Called by: main/76 (1073741824 (estimated locally),1.00 per call) (can throw
external)
+  Called by: main/76 (1073312328 (estimated locally),1.00 per call)
[...]
```

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #2 from Sam James  ---
Between 14 and 15, the main difference is:
```
│   :
│  main():
│  /tmp/gcc-binutils-PR115712/dl5.cc:45
│   sub$0x8,%rsp
│ -/tmp/gcc-binutils-PR115712/dl5.cc:46
│ - mov$0x58,%edi
│ - call   e 
│ - R_X86_64_PLT32  operator new[](unsigned long)-0x4
│ -/tmp/gcc-binutils-PR115712/dl5.cc:46 (discriminator 1)
│ - movq   $0xa,(%rax)
│ -/tmp/gcc-binutils-PR115712/dl5.cc:46
│ - mov%rax,%rdi
│ -/tmp/gcc-binutils-PR115712/dl5.cc:47
│ - call   1d 
│ - R_X86_64_PLT32  operator delete[](void*)-0x4
│  /tmp/gcc-binutils-PR115712/dl5.cc:48
│   lea0x0(%rip),%rsi
│   R_X86_64_PC32   std::nothrow-0x4
│   mov$0x58,%edi
│ - call   2e 
│ + call   15 
│   R_X86_64_PLT32  operator new[](unsigned long, std::nothrow_t
const&)-0x4
│  /tmp/gcc-binutils-PR115712/dl5.cc:48 (discriminator 1)
│   test   %rax,%rax
│ - je 42 
│ - movq   $0xa,(%rax)
│ -/tmp/gcc-binutils-PR115712/dl5.cc:48 (discriminator 4)
│ + je 22 
```

[Bug tree-optimization/115712] [15 regression] Binutils testsuite fails 2 tests (libnew1a.so, libnew1b.so)

2024-06-29 Thread sjames at gcc dot gnu.org via Gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115712

--- Comment #1 from Sam James  ---
Created attachment 58540
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58540&action=edit
gcc-binutils-PR115712.tar.xz

g++ -g -O2 -D_GNU_SOURCE -ansi -c dl5.cc -o dl5.o
g++ -g -O2 -D_GNU_SOURCE -ansi -fPIC -c del.cc -o del.o
g++ -g -O2 -D_GNU_SOURCE -ansi -fPIC -c new.cc -o new.o
g++ -o libnew1a.so -shared -Wl,-Bsymbolic-functions,--dynamic-list-cpp-new
del.o new.o
g++ o dl5a -Wl,--no-as-needed libnew1a.so dl5.o

# Prints "FAIL" if dl5.o is built with GCC 15, but "PASS" if dl5.o is built
with GCC 14
LD_LIBRARY_PATH=. ./dl5a