From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id 36E223858D35 for ; Wed, 15 Feb 2023 14:18:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 36E223858D35 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=jguk.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jguk.org Received: by mail-wm1-x330.google.com with SMTP id g6-20020a05600c310600b003e1f6dff952so1703087wmo.1 for ; Wed, 15 Feb 2023 06:18:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jguk.org; s=google; h=content-transfer-encoding:to:subject:from:content-language :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=9VQna4cngNWUXrNS3H4+6G3la7ocGXFzFo/luxoDtLM=; b=fqfj6VItxSJIY9OJXuHruU0ZjoagHPOY+5N5VOoQ0Z5Yx8Z2C2vap+4TN2RkfGcQEZ Gj8ruB62Qm2yaRRSH9ozKES3SDU3lfMwFRAukHP02FwjVaEy+N3sEWGzudDvrxeungXq 0XCzdZ3+YpzmHCzHa7Aalc5h02BvpOL3USeEdS1VaGx+2PI9a4Jc/4OpZMl8IU3f6pxQ zl5T44G+Zxg27/1JnMTQuhsferlJs5Dzh2fK7eixYHmzyuqEYxl+EcUi+5hYIiYycYVj xzTnaZ2rAyPOtj+QdRBzoXMJHxWs41BUJVoqBlVoHm6g7p04svG9MUqKp/VXt54DmJbL 0L/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:to:subject:from:content-language :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=9VQna4cngNWUXrNS3H4+6G3la7ocGXFzFo/luxoDtLM=; b=0UFaO8F7Bb0B7nXuh/WodZIKMpebx+DRZG6Oh1Yy06cPFjWLH9tq4I9NvY0U8PZShc aowbTMLEPV4bPWfhwW2pCUcwS3z6bhqvkFpKgI5HaIiYX+SDPm8OuajeihsHA0bE2JMl 0Y2+h82iIhnBgokQ6QdtGK7PuQGzl2H1ibEHao9pNN/mhg2CE3CXRC/LriJhV2nok18r VDX5JVSSbl/+IVHnL0HKDGCtGPrmOauwmhRg5iEo+F63Is1RIyysYC9hm7/fWcsXhh3+ nHTJBbrJElEtK1bGAoJz6/7lVRv8hchUB2/C3qmpB6fEp1Omt+azKObm6mKNAZFk1KGE 2yLg== X-Gm-Message-State: AO0yUKUZPAU+0L+sFImV3A5o0tG9ohy9WMbRaMXq1FyGdFvcHaovkDjm Osh3uhlM9LNwZOw7aypDRo/hHLzY3RT7VwQy X-Google-Smtp-Source: AK7set8FPl4Ks8zRHzX6BJ0JaqwvbSHfMj2HCSZyyJKTx4bxw/dmEwXC3OZuCjTdaizQ6sxEoWVtOg== X-Received: by 2002:a05:600c:1656:b0:3df:e1e9:200e with SMTP id o22-20020a05600c165600b003dfe1e9200emr1999235wmn.39.1676470719022; Wed, 15 Feb 2023 06:18:39 -0800 (PST) Received: from [192.168.0.12] (cpc87345-slou4-2-0-cust172.17-4.cable.virginm.net. [81.101.252.173]) by smtp.gmail.com with ESMTPSA id hu22-20020a05600ca29600b003dc3f3d77e3sm2136570wmb.7.2023.02.15.06.18.38 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 15 Feb 2023 06:18:38 -0800 (PST) Message-ID: <03717f06-9818-0c2a-6625-429887c55a17@jguk.org> Date: Wed, 15 Feb 2023 14:18:37 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-GB From: Jonny Grant Subject: Could __builtin_printf parameters be optimized when being compiled To: gcc-help Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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