public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/115037] New: Unused std::vector is not optimized away.
@ 2024-05-10 15:16 hubicka at gcc dot gnu.org
2024-05-10 15:42 ` [Bug middle-end/115037] " pinskia at gcc dot gnu.org
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-05-10 15:16 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
Bug ID: 115037
Summary: Unused std::vector is not optimized away.
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
Assignee: unassigned at gcc dot gnu.org
Reporter: hubicka at gcc dot gnu.org
Target Milestone: ---
Compiling
#include <vector>
void
test()
{
std::vector<int> test;
test.push_back (1);
}
leads to
_Z4testv:
.LFB1253:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $4, %edi
call _Znwm
movl $4, %esi
movl $1, (%rax)
movq %rax, %rdi
addq $8, %rsp
.cfi_def_cfa_offset 8
jmp _ZdlPvm
while clang optimizes to:
_Z4testv: # @_Z4testv
.cfi_startproc
# %bb.0:
retq
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
@ 2024-05-10 15:42 ` pinskia at gcc dot gnu.org
2024-05-10 16:12 ` hubicka at gcc dot gnu.org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-10 15:42 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
This might be a dup of another bug which talks about the same thing.
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
2024-05-10 15:42 ` [Bug middle-end/115037] " pinskia at gcc dot gnu.org
@ 2024-05-10 16:12 ` hubicka at gcc dot gnu.org
2024-05-10 16:22 ` pinskia at gcc dot gnu.org
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: hubicka at gcc dot gnu.org @ 2024-05-10 16:12 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
Jan Hubicka <hubicka at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |jason at redhat dot com,
| |jwakely at redhat dot com
--- Comment #2 from Jan Hubicka <hubicka at gcc dot gnu.org> ---
I tried to look for duplicates, but did not find one.
However I think the first problem is that we do not optimize away the store of
1 to vector while clang does. I think this is because we do not believe we can
trust that delete operator is safe?
We get:
void test ()
{
int * test$D25839$_M_impl$D25146$_M_start;
struct vector test;
int * _61;
<bb 2> [local count: 1073741824]:
_61 = operator new (4);
<bb 3> [local count: 1063439392]:
*_61 = 1;
operator delete (_61, 4);
test ={v} {CLOBBER};
test ={v} {CLOBBER(eol)};
return;
<bb 4> [count: 0]:
<L1>:
test ={v} {CLOBBER};
resx 2
}
If we can not trust fact that operator delete is good, perhaps we can arrange
explicit clobber before calling it? I think it is up to std::vector to decide
what it will do with the stored array so in this case even instane oprator
delete has no right to expect that the data in vector will be sane :)
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
2024-05-10 15:42 ` [Bug middle-end/115037] " pinskia at gcc dot gnu.org
2024-05-10 16:12 ` hubicka at gcc dot gnu.org
@ 2024-05-10 16:22 ` pinskia at gcc dot gnu.org
2024-05-10 16:24 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-10 16:22 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
Andrew Pinski <pinskia at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=94294
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Pr 94294
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
` (2 preceding siblings ...)
2024-05-10 16:22 ` pinskia at gcc dot gnu.org
@ 2024-05-10 16:24 ` pinskia at gcc dot gnu.org
2024-05-10 17:19 ` xry111 at gcc dot gnu.org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-05-10 16:24 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94293#c4
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
` (3 preceding siblings ...)
2024-05-10 16:24 ` pinskia at gcc dot gnu.org
@ 2024-05-10 17:19 ` xry111 at gcc dot gnu.org
2024-05-10 18:40 ` redi at gcc dot gnu.org
2024-05-11 0:07 ` xry111 at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-05-10 17:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
See Also| |https://gcc.gnu.org/bugzill
| |a/show_bug.cgi?id=109442
CC| |xry111 at gcc dot gnu.org
--- Comment #5 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
Isn't this an exact dup of PR109442?
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
` (4 preceding siblings ...)
2024-05-10 17:19 ` xry111 at gcc dot gnu.org
@ 2024-05-10 18:40 ` redi at gcc dot gnu.org
2024-05-11 0:07 ` xry111 at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: redi at gcc dot gnu.org @ 2024-05-10 18:40 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Yes
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug middle-end/115037] Unused std::vector is not optimized away.
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
` (5 preceding siblings ...)
2024-05-10 18:40 ` redi at gcc dot gnu.org
@ 2024-05-11 0:07 ` xry111 at gcc dot gnu.org
6 siblings, 0 replies; 8+ messages in thread
From: xry111 at gcc dot gnu.org @ 2024-05-11 0:07 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115037
Xi Ruoyao <xry111 at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |DUPLICATE
--- Comment #7 from Xi Ruoyao <xry111 at gcc dot gnu.org> ---
.
*** This bug has been marked as a duplicate of bug 109442 ***
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-05-11 0:07 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-10 15:16 [Bug middle-end/115037] New: Unused std::vector is not optimized away hubicka at gcc dot gnu.org
2024-05-10 15:42 ` [Bug middle-end/115037] " pinskia at gcc dot gnu.org
2024-05-10 16:12 ` hubicka at gcc dot gnu.org
2024-05-10 16:22 ` pinskia at gcc dot gnu.org
2024-05-10 16:24 ` pinskia at gcc dot gnu.org
2024-05-10 17:19 ` xry111 at gcc dot gnu.org
2024-05-10 18:40 ` redi at gcc dot gnu.org
2024-05-11 0:07 ` xry111 at gcc dot gnu.org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).