[llvm] 36477f7 - [XCOFF] Fix UB 'left shift of negative value' after #72532
    Vitaly Buka via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Thu Dec 14 11:29:00 PST 2023
    
    
  
Author: Vitaly Buka
Date: 2023-12-14T11:28:48-08:00
New Revision: 36477f7562c0f951bcfe3df5ae7a566e6e462dd1
URL: https://github.com/llvm/llvm-project/commit/36477f7562c0f951bcfe3df5ae7a566e6e462dd1
DIFF: https://github.com/llvm/llvm-project/commit/36477f7562c0f951bcfe3df5ae7a566e6e462dd1.diff
LOG: [XCOFF] Fix UB 'left shift of negative value' after #72532
Added: 
    
Modified: 
    llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
Removed: 
    
################################################################################
diff  --git a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
index 5e2106e9184f84..9a4291c90408d6 100644
--- a/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/MCTargetDesc/PPCInstPrinter.cpp
@@ -484,7 +484,7 @@ void PPCInstPrinter::printAbsBranchOperand(const MCInst *MI, unsigned OpNo,
   if (!MI->getOperand(OpNo).isImm())
     return printOperand(MI, OpNo, STI, O);
 
-  uint64_t Imm = MI->getOperand(OpNo).getImm() << 2;
+  uint64_t Imm = static_cast<uint64_t>(MI->getOperand(OpNo).getImm()) << 2;
   if (!TT.isPPC64())
     Imm = static_cast<uint32_t>(Imm);
   O << formatHex(Imm);
        
    
    
More information about the llvm-commits
mailing list