From a0c671e0382f67bcc55990fa57a15fd6949b78ee Mon Sep 17 00:00:00 2001 From: Ulrich Weigand Date: Thu, 1 Dec 2016 18:00:50 +0000 Subject: [PATCH] [SystemZ] Fix fallout from r288374 Avoid undefined behavior due to too-large shift count. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@288391 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp b/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp index 1f3cdde1d74..9192448afd0 100644 --- a/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp +++ b/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp @@ -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); -- 2.50.1