[SystemZ] Fix fallout from r288374
authorUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 1 Dec 2016 18:00:50 +0000 (18:00 +0000)
committerUlrich Weigand <ulrich.weigand@de.ibm.com>
Thu, 1 Dec 2016 18:00:50 +0000 (18:00 +0000)
Avoid undefined behavior due to too-large shift count.

llvm-svn: 288391

llvm/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp

index 1f3cdde..9192448 100644 (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);