Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2177017pxj; Sun, 13 Jun 2021 11:11:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzS5mhKj3c4E76ZPeIhiM1GN0BuaVZ88yOH5+yArh46xRfoZTuATjmevWD/zFw0lQfRNc+t X-Received: by 2002:a17:906:6c88:: with SMTP id s8mr12196097ejr.129.1623607867770; Sun, 13 Jun 2021 11:11:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623607867; cv=none; d=google.com; s=arc-20160816; b=InVnzViw79yDfuRmpByxNhfx5vFWMjpLkNCkqourQAbk2BihKKj+bmKdrEciBr35vr GS+Emr9sJbLod8jqBijrx6BoaC9jtexrTPSYadrSg6FzrbSul2fCO1CGfC0TMRWC3Wfu YZ+VBc1P2XRBBMHTjt/WLpH25WX8oub9P52C3ciFm23CSZQRK5nePwzkLRNRWmGF3ZMH kgkaACjYQx0uMRnV194FqjrVPoTFRy0qqmv4h4jsGhw8GjcfQxiYco0esAoZhTOIRWPP RO8xLQ9vt8sF7v8b0X+puRTpNyUlVae7swLCsDqu0vM1wdTpjoRuIhK87wdyv9/mGBLA UNPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=fDsNnaB5ppj4g5MtFY0m5Kbx3wK4L7HQC7af0yYbm7Q=; b=LHCHGQxRmAtB/cXn+rGL5COMT5UAWWhxolY2qYBLuqUgXlWkrcxCYAorFX/9AUpVVq 2NwVUp+D6CykSIq97QP6nXtPU3yFR455yDtWGc8GOY4i9x9rVKwF+kRem5nTQMitwkas mpp9DkYmen6UAa6KT2uewl7lBufzJ08AUEYldmYA6j42wKYsNCsGf0a/ByWiz0nj5A38 H2D8lf531aRbSeD37pyWBj45VFQW3lnkwo6W1V0dTanN9IUAUb2JGVvHjNaBwxf120fj pV2PdDW5vckYSVMFLGbCxkzwhtnrsfGHnU3IOzoj1E2h18PGiiRTs2/Ms8P0VqGqTHu4 WtRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TM9DZ6gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b15si9819958eds.298.2021.06.13.11.10.36; Sun, 13 Jun 2021 11:11:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=TM9DZ6gS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232017AbhFMSKl (ORCPT + 99 others); Sun, 13 Jun 2021 14:10:41 -0400 Received: from mail-ej1-f54.google.com ([209.85.218.54]:45622 "EHLO mail-ej1-f54.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232007AbhFMSKk (ORCPT ); Sun, 13 Jun 2021 14:10:40 -0400 Received: by mail-ej1-f54.google.com with SMTP id k7so12641684ejv.12 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=qQ6V9mofPVJDt7zEZCDNSMMCLN31BBnz1KBuVVIyVwSmRz3LoPBmmqB43FWxMaV+/1 l90yh8LJwty+uruvlZ5mQGwNvQWZNLjI2E+WHzYrpy3REoIHj6qlWPqB5brcKo/JOJ2A mtXG9eb0QnRLTiRdwU+y9xHQKpd+G8jfBnumIpFpWP19OO9mATsHFF9Gccu2TiS2CiD+ XarXhF2xARgDe/HB2OwWK4UIL9FBWeRnY+00Kjfvxr+RsFKRtCG84sAMcjc0N8GUo55q OqR1bPaV4LS/y1H3vhIouP2fvJuL+RXJ8N+pm2N2kE53Vvi5VunyR1ICDMZ7ZAsvy0g6 I+8A== X-Gm-Message-State: AOAM533kU/Rc+hi3F+bldgsVnWaWDr9GoPU02K/krruVb87O91PD7Kg/ 2vlaPmqRAsGcHDaWnS34NHQeDkLXEKtwUHCI4dLJyr6iGunV 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-kernel@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: