public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi
@ 2021-03-26 12:07 unlvsur at live dot com
  2021-03-26 12:10 ` [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi jakub at gcc dot gnu.org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:07 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

            Bug ID: 99789
           Summary: std::span or std::string_view are not zero-overhead on
                    MS abi
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: unlvsur at live dot com
  Target Milestone: ---

The issue is that on Microsoft abi, any trivially copyable type whose size is
not 1,2,4,8 bytes will be passed by pointer instead of value.

The empty object will also waste one precious register even it does nothing.

That means std::span, std::string_view etc incur extremely large overhead.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
@ 2021-03-26 12:10 ` jakub at gcc dot gnu.org
  2021-03-26 12:11 ` unlvsur at live dot com
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-26 12:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
And what can libstdc++ do about that?
Just use a different OS with better ABIs...

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
  2021-03-26 12:10 ` [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi jakub at gcc dot gnu.org
@ 2021-03-26 12:11 ` unlvsur at live dot com
  2021-03-26 12:11 ` unlvsur at live dot com
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #2 from cqwrteur <unlvsur at live dot com> ---
Created attachment 50476
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50476&action=edit
demo source file

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
  2021-03-26 12:10 ` [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi jakub at gcc dot gnu.org
  2021-03-26 12:11 ` unlvsur at live dot com
@ 2021-03-26 12:11 ` unlvsur at live dot com
  2021-03-26 12:13 ` unlvsur at live dot com
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:11 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #3 from cqwrteur <unlvsur at live dot com> ---
Created attachment 50477
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=50477&action=edit
demo assembly

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (2 preceding siblings ...)
  2021-03-26 12:11 ` unlvsur at live dot com
@ 2021-03-26 12:13 ` unlvsur at live dot com
  2021-03-26 12:15 ` unlvsur at live dot com
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:13 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #4 from cqwrteur <unlvsur at live dot com> ---
(In reply to Jakub Jelinek from comment #1)
> And what can libstdc++ do about that?
> Just use a different OS with better ABIs...

Well, I tested that with Rust on windows, the parameters are passed by
registers.

If changing that in libstdc++ is impossible, can we provide another attribute
to do this in some part of code? For example use "sysv_abi" but do not clean
the SIMD registers.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (3 preceding siblings ...)
  2021-03-26 12:13 ` unlvsur at live dot com
@ 2021-03-26 12:15 ` unlvsur at live dot com
  2021-03-26 12:25 ` redi at gcc dot gnu.org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:15 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #5 from cqwrteur <unlvsur at live dot com> ---
(In reply to Jakub Jelinek from comment #1)
> And what can libstdc++ do about that?
> Just use a different OS with better ABIs...

I use a lot of different systems. FreeBSD, MSDOS, Linux, Windows, etc. Using
different OS is not an option tbh since I am a library author I cannot control
how my users are going to use the library.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (4 preceding siblings ...)
  2021-03-26 12:15 ` unlvsur at live dot com
@ 2021-03-26 12:25 ` redi at gcc dot gnu.org
  2021-03-26 12:28 ` unlvsur at live dot com
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-26 12:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |WONTFIX
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Users of your library on Window will be affected by the ABI on Windows. That's
not a libstdc++ problem.

Nobody said that std::span and std::string_view are guaranteed to always be
zero-overhead.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (5 preceding siblings ...)
  2021-03-26 12:25 ` redi at gcc dot gnu.org
@ 2021-03-26 12:28 ` unlvsur at live dot com
  2021-03-26 12:35 ` jakub at gcc dot gnu.org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:28 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #7 from cqwrteur <unlvsur at live dot com> ---
(In reply to Jonathan Wakely from comment #6)
> Users of your library on Window will be affected by the ABI on Windows.
> That's not a libstdc++ problem.
> 
> Nobody said that std::span and std::string_view are guaranteed to always be
> zero-overhead.

yeah. So what's the solution if I am writing something else instead of using
std::string_view or std::span without paying for the overhead. Do you have any
attributes for that?

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (6 preceding siblings ...)
  2021-03-26 12:28 ` unlvsur at live dot com
@ 2021-03-26 12:35 ` jakub at gcc dot gnu.org
  2021-03-26 12:36 ` unlvsur at live dot com
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-03-26 12:35 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #8 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Bugzilla is for reporting bugs, not for general programming advices.

There is no bug here, the C++ standard for 64-bit architectures with its
requirements on std::string_view etc. effectively mandates that the class
stores a pointer and size which better should be also size_t and not something
narrower.
And you or your users made a choice of some ABI where passing this by value
means it is not passed in registers.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (7 preceding siblings ...)
  2021-03-26 12:35 ` jakub at gcc dot gnu.org
@ 2021-03-26 12:36 ` unlvsur at live dot com
  2021-03-26 12:50 ` redi at gcc dot gnu.org
  2021-03-26 20:19 ` unlvsur at live dot com
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 12:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #9 from cqwrteur <unlvsur at live dot com> ---
(In reply to Jakub Jelinek from comment #8)
> Bugzilla is for reporting bugs, not for general programming advices.
> 
> There is no bug here, the C++ standard for 64-bit architectures with its
> requirements on std::string_view etc. effectively mandates that the class
> stores a pointer and size which better should be also size_t and not
> something narrower.
> And you or your users made a choice of some ABI where passing this by value
> means it is not passed in registers.

but how rust works with that? Rust did pass them by registers even on msvc abi
which makes me curious.

I think I can send you the assembly file.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (8 preceding siblings ...)
  2021-03-26 12:36 ` unlvsur at live dot com
@ 2021-03-26 12:50 ` redi at gcc dot gnu.org
  2021-03-26 20:19 ` unlvsur at live dot com
  10 siblings, 0 replies; 12+ messages in thread
From: redi at gcc dot gnu.org @ 2021-03-26 12:50 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #10 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We don't want the assembly file. If you want to investigate what Rust does, you
are free to do that. But stop asking us to do that for you. There is no GCC bug
here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi
  2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
                   ` (9 preceding siblings ...)
  2021-03-26 12:50 ` redi at gcc dot gnu.org
@ 2021-03-26 20:19 ` unlvsur at live dot com
  10 siblings, 0 replies; 12+ messages in thread
From: unlvsur at live dot com @ 2021-03-26 20:19 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99789

--- Comment #11 from cqwrteur <unlvsur at live dot com> ---
(In reply to Jonathan Wakely from comment #10)
> We don't want the assembly file. If you want to investigate what Rust does,
> you are free to do that. But stop asking us to do that for you. There is no
> GCC bug here.

Well. Is that any attribute for my custom types to make them spreads for
multiple registers? I am not asking std::span or std::string_view here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-03-26 20:19 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-26 12:07 [Bug libstdc++/99789] New: std::span or std::string_view are not zero-overhead on MS abi unlvsur at live dot com
2021-03-26 12:10 ` [Bug libstdc++/99789] std::span or std::string_view are not zero-overhead on microsoft abi jakub at gcc dot gnu.org
2021-03-26 12:11 ` unlvsur at live dot com
2021-03-26 12:11 ` unlvsur at live dot com
2021-03-26 12:13 ` unlvsur at live dot com
2021-03-26 12:15 ` unlvsur at live dot com
2021-03-26 12:25 ` redi at gcc dot gnu.org
2021-03-26 12:28 ` unlvsur at live dot com
2021-03-26 12:35 ` jakub at gcc dot gnu.org
2021-03-26 12:36 ` unlvsur at live dot com
2021-03-26 12:50 ` redi at gcc dot gnu.org
2021-03-26 20:19 ` unlvsur at live dot com

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).