[llvm] r333270 - Fix ubsan errors introduced by r333263 re. left-shifting negative values.
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri May 25 04:41:04 PDT 2018
Author: s.desmalen
Date: Fri May 25 04:41:04 2018
New Revision: 333270
URL: http://llvm.org/viewvc/llvm-project?rev=333270&view=rev
Log:
Fix ubsan errors introduced by r333263 re. left-shifting negative values.
Modified:
llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Modified: llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp?rev=333270&r1=333269&r2=333270&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp Fri May 25 04:41:04 2018
@@ -648,7 +648,7 @@ public:
if (isImm())
if (auto *CE = dyn_cast<MCConstantExpr>(getImm())) {
int64_t Val = CE->getValue();
- if ((Val != 0) && ((Val >> Width) << Width) == Val)
+ if ((Val != 0) && (uint64_t(Val >> Width) << Width) == uint64_t(Val))
return std::make_pair(Val >> Width, Width);
else
return std::make_pair(Val, 0u);
@@ -736,7 +736,8 @@ public:
std::is_same<int8_t, typename std::make_signed<T>::type>::value;
if (auto ShiftedImm = getShiftedVal<8>())
if (!(IsByte && ShiftedImm->second) &&
- AArch64_AM::isSVECpyImm<T>(ShiftedImm->first << ShiftedImm->second))
+ AArch64_AM::isSVECpyImm<T>(uint64_t(ShiftedImm->first)
+ << ShiftedImm->second))
return DiagnosticPredicateTy::Match;
return DiagnosticPredicateTy::NearMatch;
More information about the llvm-commits
mailing list