diff options
| author | Mehdi Amini <mehdi.amini@apple.com> | 2016-10-09 23:00:34 +0000 |
|---|---|---|
| committer | Mehdi Amini <mehdi.amini@apple.com> | 2016-10-09 23:00:34 +0000 |
| commit | f42454b94b035cd4ad65c8470bb56e761f79b86e (patch) | |
| tree | dc8386dc823263161a0fadf2cf1de1227927a2e7 /llvm/lib/Target/BPF/TargetInfo | |
| parent | 69125397170c6ee553725b8bfb562fe38d3ffefe (diff) | |
| download | bcm5719-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/BPF/TargetInfo')
| -rw-r--r-- | llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp b/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp index a16dbae867b..265180b9987 100644 --- a/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp +++ b/llvm/lib/Target/BPF/TargetInfo/BPFTargetInfo.cpp @@ -12,17 +12,25 @@ using namespace llvm; namespace llvm { -Target TheBPFleTarget; -Target TheBPFbeTarget; -Target TheBPFTarget; +Target &getTheBPFleTarget() { + static Target TheBPFleTarget; + return TheBPFleTarget; } +Target &getTheBPFbeTarget() { + static Target TheBPFbeTarget; + return TheBPFbeTarget; +} +Target &getTheBPFTarget() { + static Target TheBPFTarget; + return TheBPFTarget; +} +} // namespace llvm extern "C" void LLVMInitializeBPFTargetInfo() { - TargetRegistry::RegisterTarget(TheBPFTarget, "bpf", - "BPF (host endian)", + TargetRegistry::RegisterTarget(getTheBPFTarget(), "bpf", "BPF (host endian)", [](Triple::ArchType) { return false; }, true); - RegisterTarget<Triple::bpfel, /*HasJIT=*/true> X( - TheBPFleTarget, "bpfel", "BPF (little endian)"); - RegisterTarget<Triple::bpfeb, /*HasJIT=*/true> Y( - TheBPFbeTarget, "bpfeb", "BPF (big endian)"); + RegisterTarget<Triple::bpfel, /*HasJIT=*/true> X(getTheBPFleTarget(), "bpfel", + "BPF (little endian)"); + RegisterTarget<Triple::bpfeb, /*HasJIT=*/true> Y(getTheBPFbeTarget(), "bpfeb", + "BPF (big endian)"); } |

