[SystemZ] Fix fallout from r288374

Avoid undefined behavior due to too-large shift count.

llvm-svn: 288391
This commit is contained in:
Ulrich Weigand 2016-12-01 18:00:50 +00:00
parent cf26d56390
commit d36b31d03f
1 changed files with 2 additions and 1 deletions

View File

@ -101,7 +101,8 @@ void SystemZMCAsmBackend::applyFixup(const MCFixup &Fixup, char *Data,
// Big-endian insertion of Size bytes.
Value = extractBitsForFixup(Kind, Value);
Value &= ((uint64_t)1 << BitSize) - 1;
if (BitSize < 64)
Value &= ((uint64_t)1 << BitSize) - 1;
unsigned ShiftValue = (Size * 8) - 8;
for (unsigned I = 0; I != Size; ++I) {
Data[Offset + I] |= uint8_t(Value >> ShiftValue);