[llvm] [HashRecognize] Don't const-qualify Values in result (PR #144752)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 18 09:45:58 PDT 2025
https://github.com/artagnon created https://github.com/llvm/llvm-project/pull/144752
Const-qualifying Values in the analysis result makes them unusable with IRBuilder. The issue was discovered when attempting to use the result of the analysis for a transform.
>From b5f20469bb67f91fb80d215dbec7b7dab90a0eae Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Wed, 18 Jun 2025 17:16:00 +0100
Subject: [PATCH] [HashRecognize] Don't const-qualify Values in result
Const-qualifying Values in the analysis result makes them unusable with
IRBuilder. The issue was discovered when attempting to use the result of
the analysis for a transform.
---
llvm/include/llvm/Analysis/HashRecognize.h | 12 ++++++------
llvm/lib/Analysis/HashRecognize.cpp | 8 ++++----
2 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/llvm/include/llvm/Analysis/HashRecognize.h b/llvm/include/llvm/Analysis/HashRecognize.h
index 8ab68a5dc2cb1..c169383bf7b08 100644
--- a/llvm/include/llvm/Analysis/HashRecognize.h
+++ b/llvm/include/llvm/Analysis/HashRecognize.h
@@ -53,7 +53,7 @@ struct PolynomialInfo {
// division in the case of CRC. Since polynomial division is an XOR in
// GF(2^m), this variable must be XOR'ed with RHS in a loop to yield the
// ComputedValue.
- const Value *LHS;
+ Value *LHS;
// The generating polynomial, or the RHS of the polynomial division in the
// case of CRC.
@@ -61,7 +61,7 @@ struct PolynomialInfo {
// The final computed value. This is a remainder of a polynomial division in
// the case of CRC, which must be zero.
- const Value *ComputedValue;
+ Value *ComputedValue;
// Set to true in the case of big-endian.
bool ByteOrderSwapped;
@@ -69,11 +69,11 @@ struct PolynomialInfo {
// An optional auxiliary checksum that augments the LHS. In the case of CRC,
// it is XOR'ed with the LHS, so that the computation's final remainder is
// zero.
- const Value *LHSAux;
+ Value *LHSAux;
- PolynomialInfo(unsigned TripCount, const Value *LHS, const APInt &RHS,
- const Value *ComputedValue, bool ByteOrderSwapped,
- const Value *LHSAux = nullptr);
+ PolynomialInfo(unsigned TripCount, Value *LHS, const APInt &RHS,
+ Value *ComputedValue, bool ByteOrderSwapped,
+ Value *LHSAux = nullptr);
};
/// The analysis.
diff --git a/llvm/lib/Analysis/HashRecognize.cpp b/llvm/lib/Analysis/HashRecognize.cpp
index 1edb8b3bdc9a8..f7ac02be2e039 100644
--- a/llvm/lib/Analysis/HashRecognize.cpp
+++ b/llvm/lib/Analysis/HashRecognize.cpp
@@ -442,9 +442,9 @@ getRecurrences(BasicBlock *LoopLatch, const PHINode *IndVar, const Loop &L) {
return std::make_pair(SimpleRecurrence, ConditionalRecurrence);
}
-PolynomialInfo::PolynomialInfo(unsigned TripCount, const Value *LHS,
- const APInt &RHS, const Value *ComputedValue,
- bool ByteOrderSwapped, const Value *LHSAux)
+PolynomialInfo::PolynomialInfo(unsigned TripCount, Value *LHS, const APInt &RHS,
+ Value *ComputedValue, bool ByteOrderSwapped,
+ Value *LHSAux)
: TripCount(TripCount), LHS(LHS), RHS(RHS), ComputedValue(ComputedValue),
ByteOrderSwapped(ByteOrderSwapped), LHSAux(LHSAux) {}
@@ -623,7 +623,7 @@ HashRecognize::recognizeCRC() const {
if (!checkExtractBits(ResultBits, TC, IsZero, *ByteOrderSwapped))
return ErrBits(ResultBits, TC, *ByteOrderSwapped);
- const Value *LHSAux = SimpleRecurrence ? SimpleRecurrence.Start : nullptr;
+ Value *LHSAux = SimpleRecurrence ? SimpleRecurrence.Start : nullptr;
return PolynomialInfo(TC, ConditionalRecurrence.Start, GenPoly, ComputedValue,
*ByteOrderSwapped, LHSAux);
}
More information about the llvm-commits
mailing list