diff options
| author | Sean Fertile <sfertile@ca.ibm.com> | 2019-02-12 20:03:04 +0000 |
|---|---|---|
| committer | Sean Fertile <sfertile@ca.ibm.com> | 2019-02-12 20:03:04 +0000 |
| commit | 9850a4827510d86046e8034511f442f267760c3b (patch) | |
| tree | 654808b8938c651495aecf9485ff0300e8c2581d | |
| parent | 706a965295618cadbc1a27098f1a015590e7a392 (diff) | |
| download | bcm5719-llvm-9850a4827510d86046e8034511f442f267760c3b.tar.gz bcm5719-llvm-9850a4827510d86046e8034511f442f267760c3b.zip | |
Fix undefined behaviour in PPCInstPrinter::printBranchOperand.
Fix the undefined behaviour introduced by my previous patch r353865 (left
shifting a potentially negative value), which was caught by the bots that run
UBSan.
llvm-svn: 353874
| -rw-r--r-- | llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp b/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp index 49e73891bc3..77206494990 100644 --- a/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp +++ b/llvm/lib/Target/PowerPC/InstPrinter/PPCInstPrinter.cpp @@ -382,7 +382,7 @@ void PPCInstPrinter::printBranchOperand(const MCInst *MI, unsigned OpNo, // Branches can take an immediate operand. This is used by the branch // selection pass to print .+8, an eight byte displacement from the PC. O << "."; - int32_t Imm = MI->getOperand(OpNo).getImm() << 2; + int32_t Imm = SignExtend32<32>((unsigned)MI->getOperand(OpNo).getImm() << 2); if (Imm >= 0) O << "+"; O << Imm; |

