From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 705E03858D37; Sun, 9 Oct 2022 20:02:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 705E03858D37 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1665345727; bh=mQWqIgsboDBhAei7/RHXOpIiBc8remJOaJ4mKGZmriE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZVhbyvMu9D74IH8ykoHbOVVr9D6mku/jB4L3NryP6VsUdOc4pBKdh2B5ExA617dCt U4Z3Ene3+HLmWEZECqnA4Tv+8reb7EVCZBQHt/RvQIlL6KCgrvzaVwakdxD7KwDC3K nS+cq7E4D246+IvLM7fkcmGBJpeaMXVuqwBF3biI= From: "slyfox at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug ipa/107196] [13 Regression] llvm-14.0.6 is miscompiles by gcc-13 in -O3: hangs llvm testsuite (inliner seems to break it) Date: Sun, 09 Oct 2022 20:02:06 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: ipa X-Bugzilla-Version: 13.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: slyfox at gcc dot gnu.org X-Bugzilla-Status: WAITING X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107196 --- Comment #6 from Sergei Trofimovich --- (In reply to Andrew Pinski from comment #4) > llvm/lib/Target/RISCV/RISCVISelLowering.cpp is huge source and it might h= ave > undefined code in it. > Maybe narrow down which function is going wrong. What would be the best way to do it? I initially tried '#pragma GCC push_options/#pragma GCC optimize(0)/#pragma GCC pop_options', but the final result still requires a few headers and RISCVISelLowering.cpp functions to = be outside optimize(0). I'm afraid I spent on in a few days and filed the bug in hopes there is a n= icer technique to nail down the specific transformation that changes the behavio= ur. If there is no better way to do it I'll start sprinkling __attribute__((noinline, noipa)) around to get broken and working variants closer. > Maybe fire up gdb and see where the infinite loop is located too. Looking at gdb the problem is not very clear: generic (not RISCV-specific c= ode) at '#8 Run () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1538' implements some instruction selection logic to pick better instructions (DAGCombiner). Normally it stabilizes, but in this case it does not finish. Heavy use of STL-like data structures do not make it easier to trace throug= h in gdb to see where first deviation bet ween good/bad happens. llvm has debugg= ing mode to dump the transformations applied but enabling it at build time make= the bug to go away. Full backtrace: llvm::DenseMapBase, llvm::detail::DenseMapPair >, llvm::SDNode*, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair >::LookupBucketFor () at llvm/include/llvm/ADT/DenseMap.h:632 632 if (LLVM_LIKELY(KeyInfoT::isEqual(Val, ThisBucket->getFirst()= ))) { (gdb) bt #0 llvm::DenseMapBase, llvm::detail::DenseMapPair >, llvm::SDNode*, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair >::LookupBucketFor () at llvm/include/llvm/ADT/DenseMap.h:632 #1 llvm::DenseMapBase, llvm::detail::DenseMapPair >, llvm::SDNode*, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair >::LookupBucketFor () at llvm/include/llvm/ADT/DenseMap.h:663 #2 llvm::DenseMapBase, llvm::detail::DenseMapPair >, llvm::SDNode*, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair >::try_emplace () at llvm/include/llvm/ADT/DenseMap.h:225 #3 llvm::DenseMapBase, llvm::detail::DenseMapPair >, llvm::SDNode*, unsigned int, llvm::DenseMapInfo, llvm::detail::DenseMapPair >::insert () at llvm/include/llvm/ADT/DenseMap.h:216 #4 AddToWorklist () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:273 #5 0x00000000014f12e8 in AddToWorklist () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:268 #6 AddUsersToWorklist () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:= 195 #7 AddToWorklistWithUsers () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:200 #8 Run () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:1538 #9 llvm::SelectionDAG::Combine () at llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp:24210 #10 0x00000000015ea7bf in llvm::SelectionDAGISel::CodeGenAndEmitDAG () at llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:958 #11 0x00000000015ed2c5 in llvm::SelectionDAGISel::SelectAllBasicBlocks () at llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:1634 #12 0x00000000015efd8b in llvm::SelectionDAGISel::runOnMachineFunction () at llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp:515 #13 0x0000000000ba4f34 in llvm::MachineFunctionPass::runOnFunction () at llvm/lib/CodeGen/MachineFunctionPass.cpp:72 #14 llvm::MachineFunctionPass::runOnFunction () at llvm/lib/CodeGen/MachineFunctionPass.cpp:37 #15 0x0000000000ff87b0 in llvm::FPPassManager::runOnFunction () at llvm/lib/IR/LegacyPassManager.cpp:1434 #16 0x0000000000ff8b3c in llvm::FPPassManager::runOnModule () at llvm/lib/IR/LegacyPassManager.cpp:1480 #17 0x0000000000ffa39e in runOnModule () at llvm/lib/IR/LegacyPassManager.cpp:1549 #18 llvm::legacy::PassManagerImpl::run () at llvm/lib/IR/LegacyPassManager.cpp:539 #19 0x000000000065a38a in compileModule () at llvm/tools/llc/llc.cpp:719 #20 main () at llvm/tools/llc/llc.cpp:417=