From: Jie Fu Date: Thu, 27 Apr 2023 09:08:24 +0000 (+0800) Subject: [X86] Fix -Wsometimes-uninitialized in X86InstrInfo.cpp (NFC) X-Git-Tag: upstream/17.0.6~10214 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8de16131cb0eac5a9b716cadb6125377b271f862;p=platform%2Fupstream%2Fllvm.git [X86] Fix -Wsometimes-uninitialized in X86InstrInfo.cpp (NFC) /data/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:9793:3: error: variable 'MaddOpc' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ /data/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:9854:25: note: uninitialized use occurs here Madd->setDesc(TII.get(MaddOpc)); ^~~~~~~ /data/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:9791:19: note: initialize the variable 'MaddOpc' to silence this warning unsigned MaddOpc; ^ = 0 /data/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:9793:3: error: variable 'AddOpc' is used uninitialized whenever switch default is taken [-Werror,-Wsometimes-uninitialized] default: ^~~~~~~ /data/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:9862:46: note: uninitialized use occurs here BuildMI(*MF, MIMetadata(Root), TII.get(AddOpc), DstReg) ^~~~~~ /data/llvm-project/llvm/lib/Target/X86/X86InstrInfo.cpp:9790:18: note: initialize the variable 'AddOpc' to silence this warning unsigned AddOpc; ^ = 0 2 errors generated. --- diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 2ee9ab6f95f3..c499410928cb 100644 --- a/llvm/lib/Target/X86/X86InstrInfo.cpp +++ b/llvm/lib/Target/X86/X86InstrInfo.cpp @@ -9787,8 +9787,8 @@ genAlternativeDpCodeSequence(MachineInstr &Root, const TargetInstrInfo &TII, MachineRegisterInfo &RegInfo = MF->getRegInfo(); unsigned Opc = Root.getOpcode(); - unsigned AddOpc; - unsigned MaddOpc; + unsigned AddOpc = 0; + unsigned MaddOpc = 0; switch (Opc) { default: assert("It should not reach here");