mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
SCEV validator: Add workarounds for some common false positives due to the way it handles strings.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@166872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -6941,6 +6941,16 @@ void ScalarEvolution::forgetMemoizedResults(const SCEV *S) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
typedef DenseMap<const Loop *, std::string> VerifyMap;
|
typedef DenseMap<const Loop *, std::string> VerifyMap;
|
||||||
|
|
||||||
|
/// replaceSubString - Replaces all occurences of From in Str with To.
|
||||||
|
static void replaceSubString(std::string &Str, StringRef From, StringRef To) {
|
||||||
|
size_t Pos = 0;
|
||||||
|
while ((Pos = Str.find(From, Pos)) != std::string::npos) {
|
||||||
|
Str.replace(Pos, From.size(), To.data(), To.size());
|
||||||
|
Pos += To.size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// getLoopBackedgeTakenCounts - Helper method for verifyAnalysis.
|
/// getLoopBackedgeTakenCounts - Helper method for verifyAnalysis.
|
||||||
static void
|
static void
|
||||||
getLoopBackedgeTakenCounts(Loop *L, VerifyMap &Map, ScalarEvolution &SE) {
|
getLoopBackedgeTakenCounts(Loop *L, VerifyMap &Map, ScalarEvolution &SE) {
|
||||||
@ -6951,6 +6961,14 @@ getLoopBackedgeTakenCounts(Loop *L, VerifyMap &Map, ScalarEvolution &SE) {
|
|||||||
if (S.empty()) {
|
if (S.empty()) {
|
||||||
raw_string_ostream OS(S);
|
raw_string_ostream OS(S);
|
||||||
SE.getBackedgeTakenCount(L)->print(OS);
|
SE.getBackedgeTakenCount(L)->print(OS);
|
||||||
|
|
||||||
|
// false and 0 are semantically equivalent. This can happen in dead loops.
|
||||||
|
replaceSubString(OS.str(), "false", "0");
|
||||||
|
// Remove wrap flags, their use in SCEV is highly fragile.
|
||||||
|
// FIXME: Remove this when SCEV gets smarter about them.
|
||||||
|
replaceSubString(OS.str(), "<nw>", "");
|
||||||
|
replaceSubString(OS.str(), "<nsw>", "");
|
||||||
|
replaceSubString(OS.str(), "<nuw>", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user