[llvm] r325347 - [PowerPC] Fix transform in table gen file causing UB
Nemanja Ivanovic via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 16 06:49:01 PST 2018
Author: nemanjai
Date: Fri Feb 16 06:49:01 2018
New Revision: 325347
URL: http://llvm.org/viewvc/llvm-project?rev=325347&view=rev
Log:
[PowerPC] Fix transform in table gen file causing UB
Running a bootstrap build with UBSan produces a number of instances where
we have signed integer overflow due to this transform. Change the type to
long to prevent this UB on 64-bit build machines.
Modified:
llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
Modified: llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td?rev=325347&r1=325346&r2=325347&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCInstrInfo.td Fri Feb 16 06:49:01 2018
@@ -308,7 +308,7 @@ def HI16 : SDNodeXForm<imm, [{
def HA16 : SDNodeXForm<imm, [{
// Transformation function: shift the immediate value down into the low bits.
- int Val = N->getZExtValue();
+ long Val = N->getZExtValue();
return getI32Imm((Val - (signed short)Val) >> 16, SDLoc(N));
}]>;
def MB : SDNodeXForm<imm, [{
More information about the llvm-commits
mailing list