[llvm] 13be274 - [AVR] Fix read of uninitialized variable AVRSubtarget:::ELFArch
Dylan McKay via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 12 04:10:13 PDT 2020
Author: Dylan McKay
Date: 2020-03-13T00:09:13+13:00
New Revision: 13be27482e5300ac8d7cafacd8a046a6611ad1c4
URL: https://github.com/llvm/llvm-project/commit/13be27482e5300ac8d7cafacd8a046a6611ad1c4
DIFF: https://github.com/llvm/llvm-project/commit/13be27482e5300ac8d7cafacd8a046a6611ad1c4.diff
LOG: [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.
Added:
Modified:
llvm/lib/Target/AVR/AVRSubtarget.cpp
llvm/lib/Target/AVR/AVRSubtarget.h
Removed:
################################################################################
diff --git a/llvm/lib/Target/AVR/AVRSubtarget.cpp b/llvm/lib/Target/AVR/AVRSubtarget.cpp
index 6a41036fdd6c..be5c4c06225b 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 da9289af7c8d..aa813a15dc0a 100644
--- a/llvm/lib/Target/AVR/AVRSubtarget.h
+++ b/llvm/lib/Target/AVR/AVRSubtarget.h
@@ -81,6 +81,10 @@ class AVRSubtarget : public AVRGenSubtargetInfo {
}
private:
+
+ /// The ELF e_flags architecture.
+ unsigned ELFArch;
+
AVRInstrInfo InstrInfo;
AVRFrameLowering FrameLowering;
AVRTargetLowering TLInfo;
@@ -107,9 +111,6 @@ class AVRSubtarget : public AVRGenSubtargetInfo {
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;
More information about the llvm-commits
mailing list