[llvm] a53d940 - [SCEV] Fix FoldID::addInteger(unsigned long I)
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 18 12:29:22 PST 2023
Author: Vitaly Buka
Date: 2023-02-18T12:29:17-08:00
New Revision: a53d940cee6f281ef1a20d4f0fb39b23b4e98614
URL: https://github.com/llvm/llvm-project/commit/a53d940cee6f281ef1a20d4f0fb39b23b4e98614
DIFF: https://github.com/llvm/llvm-project/commit/a53d940cee6f281ef1a20d4f0fb39b23b4e98614.diff
LOG: [SCEV] Fix FoldID::addInteger(unsigned long I)
"unsigned long" can be 8 bytes, but the code assumes 4.
This this the real root cause D122215 was reverted.
Reviewed By: fhahn
Differential Revision: https://reviews.llvm.org/D144316
Added:
Modified:
llvm/include/llvm/Analysis/ScalarEvolution.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h
index c4bd0fa3e07c0..57107cb8d367c 100644
--- a/llvm/include/llvm/Analysis/ScalarEvolution.h
+++ b/llvm/include/llvm/Analysis/ScalarEvolution.h
@@ -1300,7 +1300,14 @@ class ScalarEvolution {
SmallVector<unsigned, 4> Bits;
public:
- void addInteger(unsigned long I) { Bits.push_back(I); }
+ void addInteger(unsigned long I) {
+ if (sizeof(long) == sizeof(int))
+ addInteger(unsigned(I));
+ else if (sizeof(long) == sizeof(long long))
+ addInteger((unsigned long long)I);
+ else
+ llvm_unreachable("unexpected sizeof(long)");
+ }
void addInteger(unsigned I) { Bits.push_back(I); }
void addInteger(int I) { Bits.push_back(I); }
More information about the llvm-commits
mailing list