Skip to content

Commit

Permalink
[PowerPC] Fix transform in table gen file causing UB
Browse files Browse the repository at this point in the history
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.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325347 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
nemanjai committed Feb 16, 2018
1 parent 63623d9 commit 148bc17
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/Target/PowerPC/PPCInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -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, [{
Expand Down

0 comments on commit 148bc17

Please sign in to comment.