From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x1131.google.com (mail-yw1-x1131.google.com [IPv6:2607:f8b0:4864:20::1131]) by sourceware.org (Postfix) with ESMTPS id F31253858C98 for ; Fri, 5 Apr 2024 14:04:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F31253858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F31253858C98 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::1131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712325861; cv=none; b=aKfhAbFxpMho3ng8sHvBHfKA4ZvBQta7TBg65ipJHr1pqQmMFkqLXgrhLegUxXDV/GwdPl2JIupUsh5bkR4AVrk/E4E1NcnvD1+Cep9FdwirytDndKrk1PuKYkJNCZsJq/Df62TYXtOpovPG6TG13SIsDdRDDDbFKpDd2qKCo8U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712325861; c=relaxed/simple; bh=OsFVYIRvhQZYyMcc6KSwSdAEJKWFOY7JNtvXS/6rslo=; h=DKIM-Signature:MIME-Version:From:Date:Message-ID:Subject:To; b=Ht2GTGLHM1hVeJf/K+D11jfI+7Pvx8xmhdfSm8xO8UxYRWZFbtWAsO+eIE9VJKeLBpS8KlOpHz20Hr6fKRVccTOkOGopXoWn1s3lQfVAoin/SeZ+q/8fNMFIP9lJCK+P2l0DaLqFTMU8uj4lLQSfvM8TeYO/j+Sl2g3gp/MDcng= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-yw1-x1131.google.com with SMTP id 00721157ae682-617cd7bd929so7576627b3.3 for ; Fri, 05 Apr 2024 07:04:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712325858; x=1712930658; darn=gcc.gnu.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Bq2+LCJ+0nN23KZchJlpFvhF1UkXZKVugjrOMdfMoWs=; b=Nu1qy8ApwpRSsIH6us4oZL9qaGu6UAhIoWx+1+hDvF7+Ls63FB2XVvYSRNLNkJtO8L WTMSSlLqgP0sERAJRvvIQw0BWqbDtlGTziKjXbdrI1rEaGA1dU433Kt0n27miJMSz+DZ JNIvw+jjPeCb00H6tzrO6LRtNXBjgSvdL2o1MMYmlCctMptRJbzBkmzWhb7QwrLGNkpi s8xDFlFBDnl8XdNpUAoDfBFKKjC9n3REez8UBPrpRUIrkIalSj9bSBNfIW8kt7Cf++KD tqDPWQGZ56+mQwLzncCx2iVym2bihbsp0z3X4rgpn5oxn4kXZ/WHa+Ab2E0KwDKhlRKi xwXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712325858; x=1712930658; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Bq2+LCJ+0nN23KZchJlpFvhF1UkXZKVugjrOMdfMoWs=; b=lOpiAZSV3ct8zZJJb//PtOpOXGbPyMXx08k5Yn9vz36lJEUt2wkf3oVuNIZvVyVOPd dxcH4WX020yfM0eoCPrc9w+BL+cF7KQ+4gAirvvJ6kVNeiXiYvRxZiVpJ0zH7+5jVydZ gfb7jQ4Ck6F8ikm7qLfessOdKyFI0QIxikZ7ooqoDRY732atOO5nUXLxkpXAXy1Gg2T7 wSHNvv8BjRm1Idby2sVgbLsmzXZEwD8YgnmVZ2e2NreQz3YKL5T09k5Jjp05ydCigP3j jYaKeXVh/cel+UehRgbXmOMDCZQv3dzqBff3BtW+yYWYK587Z0RSMWSwOYUFp7stIjhG 6Ueg== X-Forwarded-Encrypted: i=1; AJvYcCV0WaYOnr9wv4Ctlf7XciXiqAuJXGz9oxlW/blaeVW411QZIdYMbMOBC6rPV8xDA4NDPU0wi3BgVqnJ44cr6bmg6k0gL7D+lg== X-Gm-Message-State: AOJu0YxQlE1HN6/IpKFC/sL7mTbQlUwzIb+Kkgv1/s2xpFf9Seltddgy IZzr/5kyWrgwDkTcb6c3jPpCJe7GfbtViPX44qnU0Dd2+VPMfMT4PD99NLUU3immZ9Sa02pfraP 8w7S46ma/PmBGUdWqMRJD8JboIxM= X-Google-Smtp-Source: AGHT+IEzA8cMyOVPbwXIpe8xJWF7com1bAWFBVl/x11DVgEUWNQmwCOSTH5m0mSNpvP3odpK9jWvBkiI5YRq5RCSLeQ= X-Received: by 2002:a25:7086:0:b0:dcc:1449:71ea with SMTP id l128-20020a257086000000b00dcc144971eamr1439341ybc.50.1712325857709; Fri, 05 Apr 2024 07:04:17 -0700 (PDT) MIME-Version: 1.0 References: <20240223111800.1209438-1-j@lambda.is> <7033a2f7-42de-4bb3-a99a-28a35995c4a2@lambda.is> In-Reply-To: <7033a2f7-42de-4bb3-a99a-28a35995c4a2@lambda.is> From: "H.J. Lu" Date: Fri, 5 Apr 2024 07:03:40 -0700 Message-ID: Subject: Re: [PATCH v10 1/2] Add condition coverage (MC/DC) To: =?UTF-8?Q?J=C3=B8rgen_Kvalsvik?= Cc: Jan Hubicka , gcc-patches@gcc.gnu.org, richard.guenther@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-3019.4 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,GIT_PATCH_0,KAM_SHORT,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: On Thu, Apr 4, 2024 at 5:54=E2=80=AFAM J=C3=B8rgen Kvalsvik w= rote: > > On 04/04/2024 14:10, Jan Hubicka wrote: > >> gcc/ChangeLog: > >> > >> * builtins.cc (expand_builtin_fork_or_exec): Check > >> condition_coverage_flag. > >> * collect2.cc (main): Add -fno-condition-coverage to OBSTACK. > >> * common.opt: Add new options -fcondition-coverage and > >> -Wcoverage-too-many-conditions. > >> * doc/gcov.texi: Add --conditions documentation. > >> * doc/invoke.texi: Add -fcondition-coverage documentation. > >> * function.cc (free_after_compilation): Free cond_uids. > >> * function.h (struct function): Add cond_uids. > >> * gcc.cc: Link gcov on -fcondition-coverage. > >> * gcov-counter.def (GCOV_COUNTER_CONDS): New. > >> * gcov-dump.cc (tag_conditions): New. > >> * gcov-io.h (GCOV_TAG_CONDS): New. > >> (GCOV_TAG_CONDS_LENGTH): New. > >> (GCOV_TAG_CONDS_NUM): New. > >> * gcov.cc (class condition_info): New. > >> (condition_info::condition_info): New. > >> (condition_info::popcount): New. > >> (struct coverage_info): New. > >> (add_condition_counts): New. > >> (output_conditions): New. > >> (print_usage): Add -g, --conditions. > >> (process_args): Likewise. > >> (output_intermediate_json_line): Output conditions. > >> (read_graph_file): Read condition counters. > >> (read_count_file): Likewise. > >> (file_summary): Print conditions. > >> (accumulate_line_info): Accumulate conditions. > >> (output_line_details): Print conditions. > >> * gimplify.cc (next_cond_uid): New. > >> (reset_cond_uid): New. > >> (shortcut_cond_r): Set condition discriminator. > >> (tag_shortcut_cond): New. > >> (gimple_associate_condition_with_expr): New. > >> (shortcut_cond_expr): Set condition discriminator. > >> (gimplify_cond_expr): Likewise. > >> (gimplify_function_tree): Call reset_cond_uid. > >> * ipa-inline.cc (can_early_inline_edge_p): Check > >> condition_coverage_flag. > >> * ipa-split.cc (pass_split_functions::gate): Likewise. > >> * passes.cc (finish_optimization_passes): Likewise. > >> * profile.cc (struct condcov): New declaration. > >> (cov_length): Likewise. > >> (cov_blocks): Likewise. > >> (cov_masks): Likewise. > >> (cov_maps): Likewise. > >> (cov_free): Likewise. > >> (instrument_decisions): New. > >> (read_thunk_profile): Control output to file. > >> (branch_prob): Call find_conditions, instrument_decisions. > >> (init_branch_prob): Add total_num_conds. > >> (end_branch_prob): Likewise. > >> * tree-core.h (struct tree_exp): Add condition_uid. > >> * tree-profile.cc (struct conds_ctx): New. > >> (CONDITIONS_MAX_TERMS): New. > >> (EDGE_CONDITION): New. > >> (topological_cmp): New. > >> (index_of): New. > >> (single_p): New. > >> (single_edge): New. > >> (contract_edge_up): New. > >> (struct outcomes): New. > >> (conditional_succs): New. > >> (condition_index): New. > >> (condition_uid): New. > >> (masking_vectors): New. > >> (emit_assign): New. > >> (emit_bitwise_op): New. > >> (make_top_index_visit): New. > >> (make_top_index): New. > >> (paths_between): New. > >> (struct condcov): New. > >> (cov_length): New. > >> (cov_blocks): New. > >> (cov_masks): New. > >> (cov_maps): New. > >> (cov_free): New. > >> (find_conditions): New. > >> (struct counters): New. > >> (find_counters): New. > >> (resolve_counter): New. > >> (resolve_counters): New. > >> (instrument_decisions): New. > >> (tree_profiling): Check condition_coverage_flag. > >> (pass_ipa_tree_profile::gate): Likewise. > >> * tree.h (SET_EXPR_UID): New. > >> (EXPR_COND_UID): New. > >> > >> libgcc/ChangeLog: > >> > >> * libgcov-merge.c (__gcov_merge_ior): New. > >> > >> gcc/testsuite/ChangeLog: > >> > >> * lib/gcov.exp: Add condition coverage test function. > >> * g++.dg/gcov/gcov-18.C: New test. > >> * gcc.misc-tests/gcov-19.c: New test. > >> * gcc.misc-tests/gcov-20.c: New test. > >> * gcc.misc-tests/gcov-21.c: New test. > >> * gcc.misc-tests/gcov-22.c: New test. > >> * gcc.misc-tests/gcov-23.c: New test. > >> --- > >> gcc/builtins.cc | 2 +- > >> gcc/collect2.cc | 7 +- > >> gcc/common.opt | 9 + > >> gcc/doc/gcov.texi | 38 + > >> gcc/doc/invoke.texi | 21 + > >> gcc/function.cc | 1 + > >> gcc/function.h | 4 + > >> gcc/gcc.cc | 4 +- > >> gcc/gcov-counter.def | 3 + > >> gcc/gcov-dump.cc | 24 + > >> gcc/gcov-io.h | 3 + > >> gcc/gcov.cc | 209 ++- > >> gcc/gimplify.cc | 123 +- > >> gcc/ipa-inline.cc | 2 +- > >> gcc/ipa-split.cc | 2 +- > >> gcc/passes.cc | 3 +- > >> gcc/profile.cc | 76 +- > >> gcc/testsuite/g++.dg/gcov/gcov-18.C | 282 ++++ > >> gcc/testsuite/gcc.misc-tests/gcov-19.c | 1737 ++++++++++++++++++++++= ++ > >> gcc/testsuite/gcc.misc-tests/gcov-20.c | 22 + > >> gcc/testsuite/gcc.misc-tests/gcov-21.c | 16 + > >> gcc/testsuite/gcc.misc-tests/gcov-22.c | 103 ++ > >> gcc/testsuite/gcc.misc-tests/gcov-23.c | 361 +++++ > >> gcc/testsuite/lib/gcov.exp | 259 +++- > >> gcc/tree-core.h | 3 + > >> gcc/tree-profile.cc | 1058 ++++++++++++++- > >> gcc/tree.h | 4 + > >> libgcc/libgcov-merge.c | 5 + > >> 28 files changed, 4339 insertions(+), 42 deletions(-) > >> create mode 100644 gcc/testsuite/g++.dg/gcov/gcov-18.C > >> create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-19.c > >> create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-20.c > >> create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-21.c > >> create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-22.c > >> create mode 100644 gcc/testsuite/gcc.misc-tests/gcov-23.c > >> > >> --- > >> Changes since v9: > >> > >> * function->cond_uid is no longer in ggc memory > >> * function->cond_uid and condition annotation is only done when covera= ge > >> is requested > >> * A few new test cases, notably interactions with C++ constexpr > >> * Updated comments based on review feedback > >> --- > >> > > > >> diff --git a/gcc/ipa-inline.cc b/gcc/ipa-inline.cc > >> index dc120e6da5a..9502a21c741 100644 > >> --- a/gcc/ipa-inline.cc > >> +++ b/gcc/ipa-inline.cc > >> @@ -682,7 +682,7 @@ can_early_inline_edge_p (struct cgraph_edge *e) > >> } > >> gcc_assert (gimple_in_ssa_p (DECL_STRUCT_FUNCTION (e->caller->decl= )) > >> && gimple_in_ssa_p (DECL_STRUCT_FUNCTION (callee->decl))); > >> - if (profile_arc_flag > >> + if ((profile_arc_flag || condition_coverage_flag) > >> && ((lookup_attribute ("no_profile_instrument_function", > >> DECL_ATTRIBUTES (caller->decl)) =3D=3D NULL_T= REE) > >> !=3D (lookup_attribute ("no_profile_instrument_function", > > > > tree-inline should also copy the cond tags, since always_inline > > functions are inlined even at -O0. But I think this can be done > > incrementally. > > > > Patch is OK. > > Thanks a lot and sorry for taking so long on this one. > > Honza > > I guess you mean that since tree-inlining happen after gimplification > (does it?) that the basic condition -> condition expression association > should also fold in the now-inlined conditions? > > Thanks for the review - I'll do a final test run and install the patch. The new -fcondition-coverage segfaults: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114599#c5 --=20 H.J.