From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B3E6AC48BCF for ; Sun, 13 Jun 2021 18:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 949FF611CA for ; Sun, 13 Jun 2021 18:08:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232018AbhFMSKl (ORCPT ); Sun, 13 Jun 2021 14:10:41 -0400 Received: from mail-ej1-f50.google.com ([209.85.218.50]:34631 "EHLO mail-ej1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232017AbhFMSKk (ORCPT ); Sun, 13 Jun 2021 14:10:40 -0400 Received: by mail-ej1-f50.google.com with SMTP id g8so12680210ejx.1 for ; Sun, 13 Jun 2021 11:08:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fDsNnaB5ppj4g5MtFY0m5Kbx3wK4L7HQC7af0yYbm7Q=; b=TM9DZ6gSH7CwAVJC0+D0OIC5LCLgVzSXL3kIybCqHfM62NH7+HUlM8BHmPjTYen7QA 6PZTPAf97gTVU/Ewynu3DCMbRiEFFgk0QLEqT3HoWUR5EapfuXetZOvJJHj66pHFpO2/ GI3DVGYz6w3AUF06FKeDvFThQf71sweoJQ07ojJbb2N29KJzR9EOlK+09Hj02MEvU5EJ 4WKM2Kkf9BWODFpihsegzuyQxHZnweedlYD7zbL1XuPzV+/m6EERQaB69gurEZ5YpYy8 C8khzBmvDbIXPC+HaqP1dNjLY/W5Ppe3CwgWXxclcmy43fFY3nOpt+F2vZCxOd1Dxo/R /HSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fDsNnaB5ppj4g5MtFY0m5Kbx3wK4L7HQC7af0yYbm7Q=; b=ffJzbHeKh+YQ1V+hy4wtV/bFw04nh+ndNniIsDZl9Pet2UAxvDD0yprxfuAfSHa6mj WjaFkYQPMG4Sn+a04Pj40SAIUUyLMOgTDf8M31dMgkLkXfokOktBbOSv5MfiIFRQa941 NuKa5esCqPrpWs9wKQNXW4gS1srGbNi+V+Wgxkxye8/Tck+tzkWJqDqtdp9Bw2CGc24b p3hDELbp9eWtV7u3HoPm2GJgD7Agx7ccKZmsHz2qL2+/tYg7wOMHPil+ymskIYAz/cRG +a6JPtsI7EpfbqvLF5DyxyeSJmZidkNe724FaTgifB0IdQ5Krtwj//3ASILN9C88ZyfN /JdQ== X-Gm-Message-State: AOAM532FHZ2vAdX1FLJ6epS5QajWdfg5jOcijG3BdLawXhPSYSg/UKHQ eDuGBRxJxUcvBziOzUgXFpAAc5oV6EzpraCM8YMl X-Google-Smtp-Source: ABdhPJw/qSH3tHFNLGhO6GQYyeUxfFg+hUhkSrkizMSt3oBgvCASIk/F6h3Mrnpy58OUlVunK56cx50hHTOQ/2wYiig= X-Received: by 2002:a17:907:2d88:: with SMTP id gt8mr2394107ejc.449.1623607658177; Sun, 13 Jun 2021 11:07:38 -0700 (PDT) MIME-Version: 1.0 References: <20210111081821.3041587-1-morbo@google.com> <20210407211704.367039-1-morbo@google.com> <20210612202505.GG68208@worktop.programming.kicks-ass.net> In-Reply-To: From: Bill Wendling Date: Sun, 13 Jun 2021 11:07:26 -0700 Message-ID: Subject: Re: [PATCH v9] pgo: add clang's Profile Guided Optimization infrastructure To: Peter Zijlstra Cc: Kees Cook , Jonathan Corbet , Masahiro Yamada , Linux Doc Mailing List , LKML , Linux Kbuild mailing list , clang-built-linux , Andrew Morton , Nathan Chancellor , Nick Desaulniers , Sami Tolvanen , Fangrui Song , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-doc@vger.kernel.org On Sat, Jun 12, 2021 at 3:47 PM Bill Wendling wrote: > > On Sat, Jun 12, 2021 at 1:56 PM Bill Wendling wrote: > > On Sat, Jun 12, 2021 at 1:25 PM Peter Zijlstra wrote: > > > On Sat, Jun 12, 2021 at 12:10:03PM -0700, Bill Wendling wrote: > > > Yes it is, but is that sufficient in this case? It very much isn't for > > > KASAN, UBSAN, and a whole host of other instrumentation crud. They all > > > needed their own 'bugger-off' attributes. > > > > > Now, for the "nointr" issue. I'll see if we need an additional change for that. > > > The GCOV implementation disables profiling in those directories where > instrumentation would fail. We do the same. Both clang and gcc seem to > treat the no_instrument_function attribute similarly. > An example: $ cat n.c int g(int); int __attribute__((__no_instrument_function__)) __attribute__((no_instrument_function)) no_instr(int a) { int sum = 0; for (int i = 0; i < a; i++) sum += g(i); return sum; } int instr(int a) { int sum = 0; for (int i = 0; i < a; i++) sum += g(i); return sum; } $ gcc -S -o - n.c -fprofile-arcs -ftest-coverage -O2 .globl no_instr .type no_instr, @function no_instr: .LFB0: ... addq $1, __gcov0.no_instr(%rip) pushq %rbp ... .L3: ... addq $1, 8+__gcov0.no_instr(%rip) ... addq $1, 16+__gcov0.no_instr(%rip) ... addq $1, 16+__gcov0.no_instr(%rip) ... ret .globl instr .type instr, @function instr: .LFB1: ... addq $1, __gcov0.instr(%rip) ... addq $1, 8+__gcov0.instr(%rip) ... addq $1, 16+__gcov0.instr(%rip) ... addq $1, 16+__gcov0.instr(%rip) ... ret $ clang -S -o - n.c -fprofile-generate -O2 .globl no_instr # -- Begin function no_instr .p2align 4, 0x90 .type no_instr,@function no_instr: # @no_instr ... addq $1, .L__profc_no_instr+8(%rip) ... movq .L__profc_no_instr(%rip), %rax ... movq %rax, .L__profc_no_instr(%rip) ... retq .globl instr # -- Begin function instr .p2align 4, 0x90 .type instr,@function instr: # @instr ... addq $1, .L__profc_instr+8(%rip) ... movq .L__profc_instr(%rip), %rax ... movq %rax, .L__profc_instr(%rip) ... retq .Lfunc_end1: