diff options
author | Vitaly Buka <vitalybuka@google.com> | 2021-11-04 19:26:25 -0700 |
---|---|---|
committer | Vitaly Buka <vitalybuka@google.com> | 2021-11-04 19:29:06 -0700 |
commit | 1caabbef8e8e73b3dd0cf1f15cf7417d75b7621c (patch) | |
tree | 0488211c845ed7383c5adb7f88234ea47a197d9b /llvm/lib/IR/LLVMContextImpl.cpp | |
parent | 3f6c0fb2ff750c9246aee41eb8ad086518752edf (diff) | |
download | llvm-1caabbef8e8e73b3dd0cf1f15cf7417d75b7621c.zip llvm-1caabbef8e8e73b3dd0cf1f15cf7417d75b7621c.tar.gz llvm-1caabbef8e8e73b3dd0cf1f15cf7417d75b7621c.tar.bz2 |
[OpaquePtr] Fix initialization-order-fiasco
Asan detects it after D112732.
Diffstat (limited to 'llvm/lib/IR/LLVMContextImpl.cpp')
-rw-r--r-- | llvm/lib/IR/LLVMContextImpl.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/IR/LLVMContextImpl.cpp b/llvm/lib/IR/LLVMContextImpl.cpp index 068bc58..ebbf382a 100644 --- a/llvm/lib/IR/LLVMContextImpl.cpp +++ b/llvm/lib/IR/LLVMContextImpl.cpp @@ -35,8 +35,7 @@ LLVMContextImpl::LLVMContextImpl(LLVMContext &C) X86_FP80Ty(C, Type::X86_FP80TyID), FP128Ty(C, Type::FP128TyID), PPC_FP128Ty(C, Type::PPC_FP128TyID), X86_MMXTy(C, Type::X86_MMXTyID), X86_AMXTy(C, Type::X86_AMXTyID), Int1Ty(C, 1), Int8Ty(C, 8), - Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64), Int128Ty(C, 128), - OpaquePointers(OpaquePointersCL) {} + Int16Ty(C, 16), Int32Ty(C, 32), Int64Ty(C, 64), Int128Ty(C, 128) {} LLVMContextImpl::~LLVMContextImpl() { // NOTE: We need to delete the contents of OwnedModules, but Module's dtor @@ -233,3 +232,11 @@ OptPassGate &LLVMContextImpl::getOptPassGate() const { void LLVMContextImpl::setOptPassGate(OptPassGate& OPG) { this->OPG = &OPG; } + +bool LLVMContextImpl::getOpaquePointers() { + if (LLVM_UNLIKELY(!(OpaquePointers.hasValue()))) + OpaquePointers = OpaquePointersCL; + return *OpaquePointers; +} + +void LLVMContextImpl::setOpaquePointers(bool OP) { OpaquePointers = OP; } |