Re: [RFC PATCH v2 2/6] kcov: add build system support for dataflow instrumentation

From: Nathan Chancellor

Date: Thu Jun 04 2026 - 17:49:10 EST


On Thu, Jun 04, 2026 at 10:45:19AM +0200, Peter Zijlstra wrote:
> On Wed, Jun 03, 2026 at 07:43:29PM +0200, Yunseong Kim wrote:
> > Add CFLAGS_KCOV_DATAFLOW and RUSTFLAGS_KCOV_DATAFLOW exports to
> > scripts/Makefile.kcov, containing:
> > -fsanitize-coverage=dataflow-args,dataflow-ret -g
> > (with optional -fno-inline via CONFIG_KCOV_DATAFLOW_NO_INLINE)
> >
> > scripts/Makefile.lib applies these flags when a module's Makefile sets:
> > KCOV_DATAFLOW_file.o := y (per-file)
> > KCOV_DATAFLOW := y (per-directory)
> >
> > Also supports CONFIG_KCOV_DATAFLOW_INSTRUMENT_ALL for global enablement.
> > The flags are only applied to kernel objects (same guard as basic KCOV).
> >
> > Signed-off-by: Yunseong Kim <yunseong.kim@xxxxxxxx>
> > ---
> > scripts/Makefile.kcov | 6 ++++++
> > scripts/Makefile.lib | 7 +++++++
> > 2 files changed, 13 insertions(+)
> >
> > diff --git a/scripts/Makefile.kcov b/scripts/Makefile.kcov
> > index 78305a84ba9d..101173fe194b 100644
> > --- a/scripts/Makefile.kcov
> > +++ b/scripts/Makefile.kcov
> > @@ -2,10 +2,16 @@
> > kcov-flags-y += -fsanitize-coverage=trace-pc
> > kcov-flags-$(CONFIG_KCOV_ENABLE_COMPARISONS) += -fsanitize-coverage=trace-cmp
> >
> > +# KCOV dataflow: trace function args and return values
> > +kcov-dataflow-flags-y := -fsanitize-coverage=dataflow-args,dataflow-ret -g
> > +kcov-dataflow-flags-$(CONFIG_KCOV_DATAFLOW_NO_INLINE) += -fno-inline
>
> https://clang.llvm.org/docs/ClangCommandLineReference.html
>
> Has no mention of -fno-inline, furthermore, what are the exact
> semantics? Does it inhibit __always_inline?
>

Based on clang/test/CodeGen/always-inline.c [1], I believe the semantics
are the same as GCC's '-fno-inline' [2], which avoids inlining except
for always_inline functions.

[1]: https://github.com/llvm/llvm-project/blob/1d13b74cf086629d5cdae5f44ef4a62cebcaf3ff/clang/test/CodeGen/always-inline.c
[2]: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fno-inline

--
Cheers,
Nathan