From 8de16131cb0eac5a9b716cadb6125377b271f862 Mon Sep 17 00:00:00 2001 From: Jie Fu Date: Thu, 27 Apr 2023 17:08:24 +0800 Subject: [PATCH] [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. --- llvm/lib/Target/X86/X86InstrInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp index 2ee9ab6..c499410 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"); -- 2.7.4