From: Dylan McKay Date: Thu, 12 Mar 2020 11:03:30 +0000 (+1300) Subject: [AVR] Fix read of uninitialized variable AVRSubtarget:::ELFArch X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=13be27482e5300ac8d7cafacd8a046a6611ad1c4;p=platform%2Fupstream%2Fllvm.git [AVR] Fix read of uninitialized variable AVRSubtarget:::ELFArch Found by the LLVM MemorySanitizer tests when switching AVR to a default backend. ELFArch must be initialized before the call to initializeSubtargetDependencies(). The uninitialized read would occur deep within TableGen'd code. --- diff --git a/llvm/lib/Target/AVR/AVRSubtarget.cpp b/llvm/lib/Target/AVR/AVRSubtarget.cpp index 6a41036..be5c4c0 100644 --- a/llvm/lib/Target/AVR/AVRSubtarget.cpp +++ b/llvm/lib/Target/AVR/AVRSubtarget.cpp @@ -29,7 +29,7 @@ namespace llvm { AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const AVRTargetMachine &TM) - : AVRGenSubtargetInfo(TT, CPU, FS), InstrInfo(), FrameLowering(), + : AVRGenSubtargetInfo(TT, CPU, FS), ELFArch(0), InstrInfo(), FrameLowering(), TLInfo(TM, initializeSubtargetDependencies(CPU, FS, TM)), TSInfo(), // Subtarget features @@ -38,7 +38,7 @@ AVRSubtarget::AVRSubtarget(const Triple &TT, const std::string &CPU, m_hasMOVW(false), m_hasLPM(false), m_hasLPMX(false), m_hasELPM(false), m_hasELPMX(false), m_hasSPM(false), m_hasSPMX(false), m_hasDES(false), m_supportsRMW(false), m_supportsMultiplication(false), m_hasBREAK(false), - m_hasTinyEncoding(false), ELFArch(false), m_FeatureSetDummy(false) { + m_hasTinyEncoding(false), m_FeatureSetDummy(false) { // Parse features string. ParseSubtargetFeatures(CPU, FS); } diff --git a/llvm/lib/Target/AVR/AVRSubtarget.h b/llvm/lib/Target/AVR/AVRSubtarget.h index da9289a..aa813a1 100644 --- a/llvm/lib/Target/AVR/AVRSubtarget.h +++ b/llvm/lib/Target/AVR/AVRSubtarget.h @@ -81,6 +81,10 @@ public: } private: + + /// The ELF e_flags architecture. + unsigned ELFArch; + AVRInstrInfo InstrInfo; AVRFrameLowering FrameLowering; AVRTargetLowering TLInfo; @@ -107,9 +111,6 @@ private: bool m_hasBREAK; bool m_hasTinyEncoding; - /// The ELF e_flags architecture. - unsigned ELFArch; - // Dummy member, used by FeatureSet's. We cannot have a SubtargetFeature with // no variable, so we instead bind pseudo features to this variable. bool m_FeatureSetDummy;