Skip to content

Commit d8a4541

Browse files
committed
Revert FitsInDWord implementation
Use the IntConstType to check for IsLargeConstant in Security instead of casting it to an int32
1 parent 75f2cd2 commit d8a4541

3 files changed

Lines changed: 4 additions & 13 deletions

File tree

lib/Backend/Security.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ Security::EncodeOpnd(IR::Instr *instr, IR::Opnd *opnd)
240240
{
241241
IR::IntConstOpnd *intConstOpnd = opnd->AsIntConstOpnd();
242242

243-
if (!this->IsLargeConstant(intConstOpnd->AsInt32()))
243+
if (!this->IsLargeConstant(intConstOpnd->GetValue()))
244244
{
245245
return;
246246
}

lib/Backend/Security.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Security
2626

2727
// Large constants have more than 16 significant bits.
2828
// Constants except these are considered large: 0x0000????, 0xffff????, 0x????0000, 0x????ffff
29-
static bool IsLargeConstant(int32 value) { return static_cast<int16>(value) != 0 && static_cast<int16>(value) != -1 && (value >> 16) != 0 && (value >> 16) != -1; }
29+
static bool IsLargeConstant(IntConstType value) { return static_cast<int16>(value) != 0 && static_cast<int16>(value) != -1 && (value >> 16) != 0 && (value >> 16) != -1; }
3030

3131
void InsertNOPBefore(IR::Instr *instr);
3232
int GetNextNOPInsertPoint();

lib/Common/Common/MathUtil.h

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,8 @@ class Math
4444
}
4545

4646
static bool FitsInDWord(int32 value) { return true; }
47-
static bool FitsInDWord(int64 value) { return ((int64)(signed int)(value & 0xFFFFFFFF) == value); }
48-
static bool FitsInDWord(size_t value)
49-
{
50-
#if TARGET_32
51-
CompileAssert(sizeof(size_t) == 4);
52-
return FitsInDWord((int32) value);
53-
#elif TARGET_64
54-
CompileAssert(sizeof(size_t) == 8);
55-
return FitsInDWord((int64)value);
56-
#endif
57-
}
47+
static bool FitsInDWord(size_t value) { return ((size_t)(signed int)(value & 0xFFFFFFFF) == value); }
48+
static bool FitsInDWord(int64 value) { return FitsInDWord((size_t)value); }
5849

5950
static UINT_PTR Rand();
6051
static bool IsPow2(int32 val) { return (val > 0 && ((val-1) & val) == 0); }

0 commit comments

Comments
 (0)