public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Could __builtin_printf parameters be optimized when being compiled
@ 2023-02-15 14:18 Jonny Grant
  2023-02-15 14:30 ` Richard Earnshaw
  0 siblings, 1 reply; 8+ messages in thread
From: Jonny Grant @ 2023-02-15 14:18 UTC (permalink / raw)
  To: gcc-help

Hi
Has GCC considered an improvement to "compile out" from the builtin printf the strings? That being to change it to just be something like puts("file /app/example.cpp:4")
I had a look, but couldn't find it being asked before.

This is just a short example to demonstrate.
It would be useful to see the exact string in the debugger "file /app/example.cpp:4", also it saves a few lines of asm.

https://godbolt.org/z/aKz3o6aPd


int main()
{
    __builtin_printf("file %s:%d", __FILE__, __LINE__);
}


.LC0:
        .string "/app/example.cpp"
.LC1:
        .string "file %s:%d"
main:
        subq    $8, %rsp
        movl    $4, %edx
        movl    $.LC0, %esi
        xorl    %eax, %eax
        movl    $.LC1, %edi
        call    printf
        xorl    %eax, %eax
        addq    $8, %rsp
        ret

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

end of thread, other threads:[~2023-02-16 13:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-15 14:18 Could __builtin_printf parameters be optimized when being compiled Jonny Grant
2023-02-15 14:30 ` Richard Earnshaw
2023-02-15 15:10   ` Jonny Grant
2023-02-15 15:27     ` Richard Earnshaw
2023-02-16 13:47       ` Jonny Grant
2023-02-15 15:49     ` Segher Boessenkool
2023-02-15 16:42       ` Richard Earnshaw
2023-02-16 13:48       ` Jonny Grant

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