summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/X86/MCTargetDesc
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-10-09 23:00:34 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-10-09 23:00:34 +0000
commitf42454b94b035cd4ad65c8470bb56e761f79b86e (patch)
treedc8386dc823263161a0fadf2cf1de1227927a2e7 /llvm/lib/Target/X86/MCTargetDesc
parent69125397170c6ee553725b8bfb562fe38d3ffefe (diff)
downloadbcm5719-llvm-f42454b94b035cd4ad65c8470bb56e761f79b86e.tar.gz
bcm5719-llvm-f42454b94b035cd4ad65c8470bb56e761f79b86e.zip
Move the global variables representing each Target behind accessor function
This avoids "static initialization order fiasco" Differential Revision: https://reviews.llvm.org/D25412 llvm-svn: 283702
Diffstat (limited to 'llvm/lib/Target/X86/MCTargetDesc')
-rw-r--r--llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp6
-rw-r--r--llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h3
2 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
index 311a8d677ee..22cb0fac33c 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp
@@ -234,7 +234,7 @@ static MCInstrAnalysis *createX86MCInstrAnalysis(const MCInstrInfo *Info) {
// Force static initialization.
extern "C" void LLVMInitializeX86TargetMC() {
- for (Target *T : {&TheX86_32Target, &TheX86_64Target}) {
+ for (Target *T : {&getTheX86_32Target(), &getTheX86_64Target()}) {
// Register the MC asm info.
RegisterMCAsmInfoFn X(*T, createX86MCAsmInfo);
@@ -268,9 +268,9 @@ extern "C" void LLVMInitializeX86TargetMC() {
}
// Register the asm backend.
- TargetRegistry::RegisterMCAsmBackend(TheX86_32Target,
+ TargetRegistry::RegisterMCAsmBackend(getTheX86_32Target(),
createX86_32AsmBackend);
- TargetRegistry::RegisterMCAsmBackend(TheX86_64Target,
+ TargetRegistry::RegisterMCAsmBackend(getTheX86_64Target(),
createX86_64AsmBackend);
}
diff --git a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
index 5f2db2e12b4..f73e734b9b0 100644
--- a/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
+++ b/llvm/lib/Target/X86/MCTargetDesc/X86MCTargetDesc.h
@@ -34,7 +34,8 @@ class StringRef;
class raw_ostream;
class raw_pwrite_stream;
-extern Target TheX86_32Target, TheX86_64Target;
+Target &getTheX86_32Target();
+Target &getTheX86_64Target();
/// Flavour of dwarf regnumbers
///
OpenPOWER on IntegriCloud