From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.155]) by sourceware.org (Postfix) with ESMTPS id 4F6C93846410 for ; Fri, 5 Apr 2024 13:34:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F6C93846410 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 4F6C93846410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.103.80.155 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712324095; cv=none; b=myU06uPNB+9EGXfdVhFi+q51Y6ySFMIwqNK3ttv+p5VaZ8FpkLGHuj1457YjgnBQ5IfMX38OC9awwWMtU1qFSgfQJWp85oNnL9xRXIXF4ri8nVVd/xL9oJ4YSInWwStErmnVIUGPGZ4/UxbRaIl5DwC/bTfEW6P/4j1P2IQQ/y0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1712324095; c=relaxed/simple; bh=rjm7uRAqjezRwjFUqtaqpSQTJnD4a1EGxFP0ZZWrIPQ=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=AWbPjLZ+eXfb1ac65TEllhVMtTER2gwBsOB9/VCbRlIDJMMltaGld+f1JVNo3gjc8PcfijAQTCsNM7OR3evlA+l0FRFvVco/1mWe0wwtUCSWDIV04g1U5g1tzEZQjXRfnFkm3ldvuHfp/yMcRZaz+UotVL1Yxf62v8wyzKKF0ZI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 051D02095C34; Fri, 5 Apr 2024 15:34:51 +0200 (CEST) Authentication-Results: ext-mx-out011.mykolab.com (amavis); dkim=pass (4096-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:in-reply-to :from:from:content-language:references:subject:subject :mime-version:date:date:message-id:received:received:received; s=dkim20160331; t=1712324087; x=1714138488; bh=+xpJttqiIoDUpbTu fnHQ1gXknWLcnDYJB/FwUPHvItc=; b=lmDaVyjEkJe2DJumIR5WRPA7Xlajtlgj cpEL/uDFCT3/e440Nt0NIHroSQaZXx66FnnNS4mT1LmmMpivq3bdW8A6UbFoXYhV lzuJA6lnNaAs2B83TIwJEUNO/IPWx3+3aHeQf80J6GVVx/OQGf2YzX0czAjzUqML 5UEVmTxgQUFWbqgVQis6Xt/JUx8C8Lienea8VQYbvdz2wDuO3Y5bDK6eoVuqbvzl 4U1LZP+MhAw7ksPoBBoCnsvIY2so7636j5jBe1C38ugjvuoGc0kWsmETFxlQO5Ba QwwmjC528ZC7H0NsNjCUvg7gwaDQI3UPIrYlk1aAK3Z0BzB/KoFsTvGt74xnKuhG 4/dRxl4EmNOK3ICvvyqia4g+kfjuC+XheIBM4iEf/usDoqdI5myxZsEJSHYYjwXr Gj4/pPiU8NeQg/BRz0Ify+Yp+TLCtnsLfdvEEvyXmL3bCTX1TjSXArdqHDiA5Zl3 kyFCm52iCPgtNCI0eUNe3kno2WWcwmyAAJY2ye4e5I/gns7LqRoMxa2s7xh4VD+0 zjHr/5XuePPW7rfms/L+UpsHWUiKLOMKmwzJaVOFfX/QpD7J6ixwqlvl3Ph4jRX/ FmXIL6Hn2WblqBucwJPAI9G2MwuWszQEZ8GpHvaZ8AXMHVb82jsUgwcvvYu+HYHl qID0pB4ngGA= X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -0.999 X-Spam-Level: X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out011.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id 0-UTb2uB_4bj; Fri, 5 Apr 2024 15:34:47 +0200 (CEST) Received: from int-mx009.mykolab.com (unknown [10.9.13.9]) by mx.kolabnow.com (Postfix) with ESMTPS id 5A31C2096DCD; Fri, 5 Apr 2024 15:34:44 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx009.mykolab.com (Postfix) with ESMTPS id D534820E33CB; Fri, 5 Apr 2024 15:34:44 +0200 (CEST) Message-ID: Date: Fri, 5 Apr 2024 15:34:43 +0200 MIME-Version: 1.0 Subject: Re: [PATCH v10 1/2] Add condition coverage (MC/DC) To: Rainer Orth Cc: Jan Hubicka , gcc-patches@gcc.gnu.org, richard.guenther@gmail.com References: <20240223111800.1209438-1-j@lambda.is> <7033a2f7-42de-4bb3-a99a-28a35995c4a2@lambda.is> Content-Language: en-US From: =?UTF-8?Q?J=C3=B8rgen_Kvalsvik?= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 05/04/2024 15:00, Rainer Orth wrote: > Hi Jørgen, > >> 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 coverage >>>> 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)) == NULL_TREE) >>>> != (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. > > this patch fails badly on Solaris (and probably all non-Linux targets): > > +FAIL: gcc.misc-tests/gcov-19.c (test for excess errors) > +UNRESOLVED: gcc.misc-tests/gcov-19.c compilation failed to produce executable > +FAIL: gcc.misc-tests/gcov-19.c gcov: 0 failures in line counts, 0 in branch percentages, 796 in condition/decision, 0 in return percentages, 0 in intermediate format > +FAIL: gcc.misc-tests/gcov-19.c line 1006: unexpected summary - expected 1/24, got 0/24 > > and almost 1000 more lines. > > gcov-19.exe doesn't link due to use of a Linux implementation detail: > > Undefined first referenced > symbol in file > __sigsetjmp /var/tmp//cc.8e7Qc.o > ld: fatal: symbol referencing errors > collect2: error: ld returned 1 exit status > > Either switch the testcase to use sigsetjmp or restrict it to Linux. > Besides, emitting many hundreds of FAILs if the testcase doesn't compile > is very bad style. I could never reproduce the CFG that caused the ICE for that test case which Martin Liška found back in an earlier iteration of this patch - using setsigjmp did not trigger the problem. Since then, the CFG walk has been much improved and I am honestly not sure the test case makes sense anymore. I think simply removing it should be fine, I can submit a patch. As for emitting FAILs when it does not compile, I'll see if my check-conditions is different from the rest of check-gcov, maybe it should be handled there. Sorry for the noise. > > Please fix. > > Rainer >