/*========================== begin_copyright_notice ============================ Copyright (C) 2024 Intel Corporation SPDX-License-Identifier: MIT ============================= end_copyright_notice ===========================*/ /*========================== begin_copyright_notice ============================ Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. See https://llvm.org/LICENSE.txt for license information. SPDX-License-Identifier: Apache-2.0 with LLVM-exception ============================= end_copyright_notice ===========================*/ From e151e07932d68201fe228508fe776f7550150665 Mon Sep 17 00:00:00 2001 From: Max Kazantsev Date: Mon, 19 Sep 2022 17:37:17 +0700 Subject: [PATCH 1/5] [SCEV] Verify contents of loop disposition cache It seems that it is sometimes broken. Initial motivation for this was investigation of https://github.com/llvm/llvm-project/issues/56260, but it also seems that we have found an unrelated bug in LoopFusion that leaves broken caches. Differential Revision: https://reviews.llvm.org/D134158 Reviewed By: nikic --- llvm/lib/Analysis/ScalarEvolution.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index 977fc0911355..1d887d4b60c9 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -13449,6 +13449,24 @@ void ScalarEvolution::verify() const { }; VerifyBECountUsers(/* Predicated */ false); VerifyBECountUsers(/* Predicated */ true); + + // Verify intergity of loop disposition cache. + for (const auto &It : LoopDispositions) { + const SCEV *S = It.first; + auto &Values = It.second; + for (auto &V : Values) { + auto CachedDisposition = V.getInt(); + const auto *Loop = V.getPointer(); + const auto RecomputedDisposition = SE2.getLoopDisposition(S, Loop); + if (CachedDisposition != RecomputedDisposition) { + dbgs() << "Cached disposition of " << *S << " for loop " << *Loop + << " is incorrect: cached " + << loopDispositionToStr(CachedDisposition) << ", actual " + << loopDispositionToStr(RecomputedDisposition) << "\n"; + std::abort(); + } + } + } } bool ScalarEvolution::invalidate( -- 2.34.1