Closed SixWeining closed 2 years ago
You would probably need to find the offending gcc change and report this to gcc bugtracker.
You would probably need to find the offending gcc change and report this to gcc bugtracker.
Thanks. I will try to use git bisect
to find that change.
I have found the gcc change causing this issue. In case others meet the same issue, post it here:
87dd4c8c83768aafad92588853fd84a6070553d6 is the first bad commit
commit 87dd4c8c83768aafad92588853fd84a6070553d6
Author: Andrew MacLeod <amacleod@redhat.com>
Date: Fri Jul 29 12:05:38 2022 -0400
Check equivalencies when calculating range on entry.
When propagating on-entry values in the cache, checking if any equivalence
has a known value can improve results. No new calculations are made.
Only queries via dominators which do not populate the cache are checked.
PR tree-optimization/106474
gcc/
* gimple-range-cache.cc (ranger_cache::fill_block_cache): Query
range of equivalences that may contribute to the range.
gcc/testsuite/
* g++.dg/pr106474.C: New.
Hmm this is still the case with latest gcc and clang. @SixWeining could you post the respective gcc bugzilla link so people could track the progress and hopefully get this fixed before the gcc 13.1 release?
Hmm this is still the case with latest gcc and clang. @SixWeining could you post the respective gcc bugzilla link so people could track the progress and hopefully get this fixed before the gcc 13.1 release?
I have not filed this bug in gcc bugzilla because I find it's hard to meet the writing guidelines. "build llvm and check-clang" seems not a good bug report. I'm not sure is there a simpler way to describe the issue that can help troubleshooting.
I'm still hitting this with GCC 13 (13.0.1 202304020) and reverting 87dd4c8c83768aafad92588853fd84a6070553d6 "fixes" the failure.
@tstellar has kindly pinged Andrew, so let's see what happens. I'm also reluctant to report myself without more information just because I've already got one open bug where I need to reduce it (another LLVM issue, actually, but on ppc).
(FWIW though, if you genuinely can't reduce something, it's still better to file something rather than not. I only found this bug by chance.)
My cheesy revert (it didn't revert cleanly):
--- a/gcc/gimple-range-cache.cc
+++ b/gcc/gimple-range-cache.cc
@@ -1211,79 +1211,14 @@ ranger_cache::fill_block_cache (tree name, basic_block bb, basic_block def_bb)
// Check if a dominators can supply the range.
if (range_from_dom (block_result, name, bb, RFD_FILL))
{
+ m_on_entry.set_bb_range (name, bb, block_result);
if (DEBUG_RANGE_CACHE)
{
fprintf (dump_file, "Filled from dominator! : ");
block_result.dump (dump_file);
fprintf (dump_file, "\n");
}
- // See if any equivalences can refine it.
- if (m_oracle)
- {
- tree equiv_name;
- relation_kind rel;
- int prec = TYPE_PRECISION (type);
- FOR_EACH_PARTIAL_AND_FULL_EQUIV (m_oracle, bb, name, equiv_name, rel)
- {
- basic_block equiv_bb = gimple_bb (SSA_NAME_DEF_STMT (equiv_name));
-
- // Ignore partial equivs that are smaller than this object.
- if (rel != VREL_EQ && prec > pe_to_bits (rel))
- continue;
-
- // Check if the equiv has any ranges calculated.
- if (!m_gori.has_edge_range_p (equiv_name))
- continue;
-
- // PR 108139. It is hazardous to assume an equivalence with
- // a PHI is the same value. The PHI may be an equivalence
- // via UNDEFINED arguments which is really a one way equivalence.
- // PHIDEF == name, but name may not be == PHIDEF.
- if (is_a<gphi *> (SSA_NAME_DEF_STMT (equiv_name)))
- continue;
-
- // Check if the equiv definition dominates this block
- if (equiv_bb == bb ||
- (equiv_bb && !dominated_by_p (CDI_DOMINATORS, bb, equiv_bb)))
- continue;
-
- if (DEBUG_RANGE_CACHE)
- {
- if (rel == VREL_EQ)
- fprintf (dump_file, "Checking Equivalence (");
- else
- fprintf (dump_file, "Checking Partial equiv (");
- print_relation (dump_file, rel);
- fprintf (dump_file, ") ");
- print_generic_expr (dump_file, equiv_name, TDF_SLIM);
- fprintf (dump_file, "\n");
- }
- Value_Range equiv_range (TREE_TYPE (equiv_name));
- if (range_from_dom (equiv_range, equiv_name, bb, RFD_READ_ONLY))
- {
- if (rel != VREL_EQ)
- range_cast (equiv_range, type);
- if (block_result.intersect (equiv_range))
- {
- if (DEBUG_RANGE_CACHE)
- {
- if (rel == VREL_EQ)
- fprintf (dump_file, "Equivalence update! : ");
- else
- fprintf (dump_file, "Partial equiv update! : ");
- print_generic_expr (dump_file, equiv_name, TDF_SLIM);
- fprintf (dump_file, " has range : ");
- equiv_range.dump (dump_file);
- fprintf (dump_file, " refining range to :");
- block_result.dump (dump_file);
- fprintf (dump_file, "\n");
- }
- }
- }
- }
- }
- m_on_entry.set_bb_range (name, bb, block_result);
gcc_checking_assert (m_workback.length () == 0);
return;
@jakubjelinek has reported this at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109462. Thank you!
When I use latest gcc-13 to build clang/llvm,
Clang :: Analysis/localization-aggressive.m
test fails with release build while it's OK with debug build.Environment:
As a comparison, gcc-12.2.0 works well.
gcc source code
llvm source code
How to build gcc
How to build clang/llvm
Test