public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "hiraditya at msn dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/109442] Dead local copy of std::vector not removed from function
Date: Thu, 15 Jun 2023 18:38:32 +0000 [thread overview]
Message-ID: <bug-109442-4-LKdlbXg3FH@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109442-4@http.gcc.gnu.org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109442
--- Comment #17 from AK <hiraditya at msn dot com> ---
With recent changes in libc++ (https://reviews.llvm.org/D147741) clang
optimizes away the new-delete pair. https://godbolt.org/z/a6PG54Pvb
$ clang++ -O3 -stdlib=libc++ -fno-exceptions
vat1(std::__1::vector<int, std::__1::allocator<int> >): #
@vat1(std::__1::vector<int, std::__1::allocator<int> >)
sub rsp, 24
xorps xmm0, xmm0
movaps xmmword ptr [rsp], xmm0
mov qword ptr [rsp + 16], 0
mov rax, qword ptr [rdi + 8]
sub rax, qword ptr [rdi]
je .LBB0_2
js .LBB0_3
.LBB0_2:
mov eax, 10
add rsp, 24
ret
.LBB0_3:
mov rdi, rsp
call std::__1::vector<int, std::__1::allocator<int>
>::__throw_length_error[abi:v170000]() const
.L.str:
.asciz "vector"
.L.str.1:
.asciz "length_error was thrown in -fno-exceptions mode with message \"%s\""
Previously clang couldn't even convert the copy to a memmove and would generate
a raw loop e.g., https://godbolt.org/z/G8ax1o5bc
.LBB0_6: # =>This Inner Loop Header: Depth=1
movups xmm0, xmmword ptr [r15 + 4*rdi]
movups xmm1, xmmword ptr [r15 + 4*rdi + 16]
movups xmmword ptr [rax + 4*rdi], xmm0
movups xmmword ptr [rax + 4*rdi + 16], xmm1
add rdi, 8
cmp rsi, rdi
jne .LBB0_6
cmp rbx, rsi
jne .LBB0_8
jmp .LBB0_9
.LBB0_3:
next prev parent reply other threads:[~2023-06-15 18:38 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-06 19:00 [Bug tree-optimization/109442] New: " hiraditya at msn dot com
2023-04-11 13:28 ` [Bug tree-optimization/109442] " rguenth at gcc dot gnu.org
2023-04-11 13:33 ` redi at gcc dot gnu.org
2023-04-11 13:38 ` redi at gcc dot gnu.org
2023-04-12 7:40 ` [Bug libstdc++/109442] " rguenth at gcc dot gnu.org
2023-04-12 9:29 ` redi at gcc dot gnu.org
2023-04-12 9:45 ` rguenth at gcc dot gnu.org
2023-04-12 10:01 ` redi at gcc dot gnu.org
2023-04-12 10:13 ` redi at gcc dot gnu.org
2023-04-12 10:22 ` rguenth at gcc dot gnu.org
2023-04-12 10:29 ` redi at gcc dot gnu.org
2023-04-12 10:35 ` redi at gcc dot gnu.org
2023-04-12 11:52 ` rguenther at suse dot de
2023-04-12 11:55 ` redi at gcc dot gnu.org
2023-04-16 18:38 ` richard-gccbugzilla at metafoo dot co.uk
2023-04-17 6:49 ` rguenth at gcc dot gnu.org
2023-04-18 2:15 ` richard-gccbugzilla at metafoo dot co.uk
2023-06-15 18:38 ` hiraditya at msn dot com [this message]
2024-05-11 0:07 ` xry111 at gcc dot gnu.org
2024-05-11 16:05 ` hubicka at gcc dot gnu.org
2024-05-14 13:47 ` Jan Hubicka
2024-05-11 16:44 ` redi at gcc dot gnu.org
2024-05-14 13:47 ` hubicka at ucw dot cz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bug-109442-4-LKdlbXg3FH@http.gcc.gnu.org/bugzilla/ \
--to=gcc-bugzilla@gcc.gnu.org \
--cc=gcc-bugs@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).