[llvm] r288391 - [SystemZ] Fix fallout from r288374

Ulrich Weigand via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 1 10:00:50 PST 2016


Author: uweigand
Date: Thu Dec  1 12:00:50 2016
New Revision: 288391

URL: http://llvm.org/viewvc/llvm-project?rev=288391&view=rev
Log:
[SystemZ] Fix fallout from r288374

Avoid undefined behavior due to too-large shift count.


Modified:
    llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp

Modified: llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp?rev=288391&r1=288390&r2=288391&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/MCTargetDesc/SystemZMCAsmBackend.cpp Thu Dec  1 12:00:50 2016
@@ -101,7 +101,8 @@ void SystemZMCAsmBackend::applyFixup(con
 
   // 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);




More information about the llvm-commits mailing list