From a53d940cee6f281ef1a20d4f0fb39b23b4e98614 Mon Sep 17 00:00:00 2001 From: Vitaly Buka Date: Fri, 17 Feb 2023 18:29:42 -0800 Subject: [PATCH] [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 --- llvm/include/llvm/Analysis/ScalarEvolution.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/Analysis/ScalarEvolution.h b/llvm/include/llvm/Analysis/ScalarEvolution.h index c4bd0fa..57107cb 100644 --- a/llvm/include/llvm/Analysis/ScalarEvolution.h +++ b/llvm/include/llvm/Analysis/ScalarEvolution.h @@ -1300,7 +1300,14 @@ public: SmallVector 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); } -- 2.7.4