Skip to content

Commit f13b9e3

Browse files
authored
[HashRecognize] Don't const-qualify Values in result (#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.
1 parent a94eb27 commit f13b9e3

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

llvm/include/llvm/Analysis/HashRecognize.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,27 @@ struct PolynomialInfo {
5353
// division in the case of CRC. Since polynomial division is an XOR in
5454
// GF(2^m), this variable must be XOR'ed with RHS in a loop to yield the
5555
// ComputedValue.
56-
const Value *LHS;
56+
Value *LHS;
5757

5858
// The generating polynomial, or the RHS of the polynomial division in the
5959
// case of CRC.
6060
APInt RHS;
6161

6262
// The final computed value. This is a remainder of a polynomial division in
6363
// the case of CRC, which must be zero.
64-
const Value *ComputedValue;
64+
Value *ComputedValue;
6565

6666
// Set to true in the case of big-endian.
6767
bool ByteOrderSwapped;
6868

6969
// An optional auxiliary checksum that augments the LHS. In the case of CRC,
7070
// it is XOR'ed with the LHS, so that the computation's final remainder is
7171
// zero.
72-
const Value *LHSAux;
72+
Value *LHSAux;
7373

74-
PolynomialInfo(unsigned TripCount, const Value *LHS, const APInt &RHS,
75-
const Value *ComputedValue, bool ByteOrderSwapped,
76-
const Value *LHSAux = nullptr);
74+
PolynomialInfo(unsigned TripCount, Value *LHS, const APInt &RHS,
75+
Value *ComputedValue, bool ByteOrderSwapped,
76+
Value *LHSAux = nullptr);
7777
};
7878

7979
/// The analysis.

llvm/lib/Analysis/HashRecognize.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -442,9 +442,9 @@ getRecurrences(BasicBlock *LoopLatch, const PHINode *IndVar, const Loop &L) {
442442
return std::make_pair(SimpleRecurrence, ConditionalRecurrence);
443443
}
444444

445-
PolynomialInfo::PolynomialInfo(unsigned TripCount, const Value *LHS,
446-
const APInt &RHS, const Value *ComputedValue,
447-
bool ByteOrderSwapped, const Value *LHSAux)
445+
PolynomialInfo::PolynomialInfo(unsigned TripCount, Value *LHS, const APInt &RHS,
446+
Value *ComputedValue, bool ByteOrderSwapped,
447+
Value *LHSAux)
448448
: TripCount(TripCount), LHS(LHS), RHS(RHS), ComputedValue(ComputedValue),
449449
ByteOrderSwapped(ByteOrderSwapped), LHSAux(LHSAux) {}
450450

@@ -623,7 +623,7 @@ HashRecognize::recognizeCRC() const {
623623
if (!checkExtractBits(ResultBits, TC, IsZero, *ByteOrderSwapped))
624624
return ErrBits(ResultBits, TC, *ByteOrderSwapped);
625625

626-
const Value *LHSAux = SimpleRecurrence ? SimpleRecurrence.Start : nullptr;
626+
Value *LHSAux = SimpleRecurrence ? SimpleRecurrence.Start : nullptr;
627627
return PolynomialInfo(TC, ConditionalRecurrence.Start, GenPoly, ComputedValue,
628628
*ByteOrderSwapped, LHSAux);
629629
}

0 commit comments

Comments
 (0)