1ef860a24SChandler Carruth //===-- LLVMContext.cpp - Implement LLVMContext ---------------------------===// 2ef860a24SChandler Carruth // 32946cd70SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 42946cd70SChandler Carruth // See https://llvm.org/LICENSE.txt for license information. 52946cd70SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6ef860a24SChandler Carruth // 7ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 8ef860a24SChandler Carruth // 9ef860a24SChandler Carruth // This file implements LLVMContext, as a wrapper around the opaque 10ef860a24SChandler Carruth // class LLVMContextImpl. 11ef860a24SChandler Carruth // 12ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 13ef860a24SChandler Carruth 149fb823bbSChandler Carruth #include "llvm/IR/LLVMContext.h" 156bda14b3SChandler Carruth #include "LLVMContextImpl.h" 165354a8aaSEugene Zelenko #include "llvm/ADT/SmallVector.h" 175354a8aaSEugene Zelenko #include "llvm/ADT/StringMap.h" 185354a8aaSEugene Zelenko #include "llvm/ADT/StringRef.h" 195354a8aaSEugene Zelenko #include "llvm/ADT/Twine.h" 20b4c44d23SQuentin Colombet #include "llvm/IR/DiagnosticInfo.h" 21b4c44d23SQuentin Colombet #include "llvm/IR/DiagnosticPrinter.h" 229fb823bbSChandler Carruth #include "llvm/IR/Metadata.h" 235354a8aaSEugene Zelenko #include "llvm/IR/Module.h" 24*b8a847c0SFrancis Visoiu Mistrih #include "llvm/IR/RemarkStreamer.h" 255354a8aaSEugene Zelenko #include "llvm/Support/Casting.h" 265354a8aaSEugene Zelenko #include "llvm/Support/ErrorHandling.h" 275354a8aaSEugene Zelenko #include "llvm/Support/raw_ostream.h" 285354a8aaSEugene Zelenko #include <cassert> 295354a8aaSEugene Zelenko #include <cstdlib> 305354a8aaSEugene Zelenko #include <string> 315354a8aaSEugene Zelenko #include <utility> 325354a8aaSEugene Zelenko 33ef860a24SChandler Carruth using namespace llvm; 34ef860a24SChandler Carruth 35ef860a24SChandler Carruth LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { 36ef860a24SChandler Carruth // Create the fixed metadata kinds. This is done in the same order as the 37ef860a24SChandler Carruth // MD_* enum values so that they correspond. 386f0b4f2eSPeter Collingbourne std::pair<unsigned, StringRef> MDKinds[] = { 396f0b4f2eSPeter Collingbourne {MD_dbg, "dbg"}, 406f0b4f2eSPeter Collingbourne {MD_tbaa, "tbaa"}, 416f0b4f2eSPeter Collingbourne {MD_prof, "prof"}, 426f0b4f2eSPeter Collingbourne {MD_fpmath, "fpmath"}, 436f0b4f2eSPeter Collingbourne {MD_range, "range"}, 446f0b4f2eSPeter Collingbourne {MD_tbaa_struct, "tbaa.struct"}, 456f0b4f2eSPeter Collingbourne {MD_invariant_load, "invariant.load"}, 466f0b4f2eSPeter Collingbourne {MD_alias_scope, "alias.scope"}, 476f0b4f2eSPeter Collingbourne {MD_noalias, "noalias"}, 486f0b4f2eSPeter Collingbourne {MD_nontemporal, "nontemporal"}, 496f0b4f2eSPeter Collingbourne {MD_mem_parallel_loop_access, "llvm.mem.parallel_loop_access"}, 506f0b4f2eSPeter Collingbourne {MD_nonnull, "nonnull"}, 516f0b4f2eSPeter Collingbourne {MD_dereferenceable, "dereferenceable"}, 526f0b4f2eSPeter Collingbourne {MD_dereferenceable_or_null, "dereferenceable_or_null"}, 536f0b4f2eSPeter Collingbourne {MD_make_implicit, "make.implicit"}, 546f0b4f2eSPeter Collingbourne {MD_unpredictable, "unpredictable"}, 556f0b4f2eSPeter Collingbourne {MD_invariant_group, "invariant.group"}, 566f0b4f2eSPeter Collingbourne {MD_align, "align"}, 576f0b4f2eSPeter Collingbourne {MD_loop, "llvm.loop"}, 586f0b4f2eSPeter Collingbourne {MD_type, "type"}, 596f0b4f2eSPeter Collingbourne {MD_section_prefix, "section_prefix"}, 60235c275bSPeter Collingbourne {MD_absolute_symbol, "absolute_symbol"}, 6151c962f7SEvgeniy Stepanov {MD_associated, "associated"}, 6236bbc8ceSMatthew Simpson {MD_callees, "callees"}, 63dce9def3SHiroshi Yamauchi {MD_irr_loop, "irr_loop"}, 64978ba615SMichael Kruse {MD_access_group, "llvm.access.group"}, 6518251842SJohannes Doerfert {MD_callback, "callback"}, 666f0b4f2eSPeter Collingbourne }; 67ef860a24SChandler Carruth 686f0b4f2eSPeter Collingbourne for (auto &MDKind : MDKinds) { 696f0b4f2eSPeter Collingbourne unsigned ID = getMDKindID(MDKind.second); 706f0b4f2eSPeter Collingbourne assert(ID == MDKind.first && "metadata kind id drifted"); 716f0b4f2eSPeter Collingbourne (void)ID; 726f0b4f2eSPeter Collingbourne } 73302b69c9SDehao Chen 74cdafd849SSanjoy Das auto *DeoptEntry = pImpl->getOrInsertBundleTag("deopt"); 75cdafd849SSanjoy Das assert(DeoptEntry->second == LLVMContext::OB_deopt && 76cdafd849SSanjoy Das "deopt operand bundle id drifted!"); 77cdafd849SSanjoy Das (void)DeoptEntry; 783bb88c02SDavid Majnemer 793bb88c02SDavid Majnemer auto *FuncletEntry = pImpl->getOrInsertBundleTag("funclet"); 803bb88c02SDavid Majnemer assert(FuncletEntry->second == LLVMContext::OB_funclet && 813bb88c02SDavid Majnemer "funclet operand bundle id drifted!"); 823bb88c02SDavid Majnemer (void)FuncletEntry; 83a34ce95bSSanjoy Das 84a34ce95bSSanjoy Das auto *GCTransitionEntry = pImpl->getOrInsertBundleTag("gc-transition"); 85a34ce95bSSanjoy Das assert(GCTransitionEntry->second == LLVMContext::OB_gc_transition && 86a34ce95bSSanjoy Das "gc-transition operand bundle id drifted!"); 87a34ce95bSSanjoy Das (void)GCTransitionEntry; 88bb80d3e1SKonstantin Zhuravlyov 89bb80d3e1SKonstantin Zhuravlyov SyncScope::ID SingleThreadSSID = 90bb80d3e1SKonstantin Zhuravlyov pImpl->getOrInsertSyncScopeID("singlethread"); 91bb80d3e1SKonstantin Zhuravlyov assert(SingleThreadSSID == SyncScope::SingleThread && 92bb80d3e1SKonstantin Zhuravlyov "singlethread synchronization scope ID drifted!"); 93878fdee0SKonstantin Zhuravlyov (void)SingleThreadSSID; 94bb80d3e1SKonstantin Zhuravlyov 95bb80d3e1SKonstantin Zhuravlyov SyncScope::ID SystemSSID = 96bb80d3e1SKonstantin Zhuravlyov pImpl->getOrInsertSyncScopeID(""); 97bb80d3e1SKonstantin Zhuravlyov assert(SystemSSID == SyncScope::System && 98bb80d3e1SKonstantin Zhuravlyov "system synchronization scope ID drifted!"); 99878fdee0SKonstantin Zhuravlyov (void)SystemSSID; 100ef860a24SChandler Carruth } 1015354a8aaSEugene Zelenko 102ef860a24SChandler Carruth LLVMContext::~LLVMContext() { delete pImpl; } 103ef860a24SChandler Carruth 104ef860a24SChandler Carruth void LLVMContext::addModule(Module *M) { 105ef860a24SChandler Carruth pImpl->OwnedModules.insert(M); 106ef860a24SChandler Carruth } 107ef860a24SChandler Carruth 108ef860a24SChandler Carruth void LLVMContext::removeModule(Module *M) { 109ef860a24SChandler Carruth pImpl->OwnedModules.erase(M); 110ef860a24SChandler Carruth } 111ef860a24SChandler Carruth 112ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 113ef860a24SChandler Carruth // Recoverable Backend Errors 114ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 115ef860a24SChandler Carruth 116a594fab4SBob Wilson void LLVMContext:: 117a594fab4SBob Wilson setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler, 118ef860a24SChandler Carruth void *DiagContext) { 119a594fab4SBob Wilson pImpl->InlineAsmDiagHandler = DiagHandler; 120a594fab4SBob Wilson pImpl->InlineAsmDiagContext = DiagContext; 121ef860a24SChandler Carruth } 122ef860a24SChandler Carruth 123a594fab4SBob Wilson /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by 124a594fab4SBob Wilson /// setInlineAsmDiagnosticHandler. 125a594fab4SBob Wilson LLVMContext::InlineAsmDiagHandlerTy 126a594fab4SBob Wilson LLVMContext::getInlineAsmDiagnosticHandler() const { 127a594fab4SBob Wilson return pImpl->InlineAsmDiagHandler; 128ef860a24SChandler Carruth } 129ef860a24SChandler Carruth 130a594fab4SBob Wilson /// getInlineAsmDiagnosticContext - Return the diagnostic context set by 131a594fab4SBob Wilson /// setInlineAsmDiagnosticHandler. 132a594fab4SBob Wilson void *LLVMContext::getInlineAsmDiagnosticContext() const { 133a594fab4SBob Wilson return pImpl->InlineAsmDiagContext; 134ef860a24SChandler Carruth } 135ef860a24SChandler Carruth 136b5ab895eSVivek Pandya void LLVMContext::setDiagnosticHandlerCallBack( 137b5ab895eSVivek Pandya DiagnosticHandler::DiagnosticHandlerTy DiagnosticHandler, 138b5ab895eSVivek Pandya void *DiagnosticContext, bool RespectFilters) { 139b5ab895eSVivek Pandya pImpl->DiagHandler->DiagHandlerCallback = DiagnosticHandler; 140b5ab895eSVivek Pandya pImpl->DiagHandler->DiagnosticContext = DiagnosticContext; 141b5ab895eSVivek Pandya pImpl->RespectDiagnosticFilters = RespectFilters; 142b5ab895eSVivek Pandya } 143b5ab895eSVivek Pandya 144b5ab895eSVivek Pandya void LLVMContext::setDiagnosticHandler(std::unique_ptr<DiagnosticHandler> &&DH, 14530c9242cSDuncan P. N. Exon Smith bool RespectFilters) { 146b5ab895eSVivek Pandya pImpl->DiagHandler = std::move(DH); 14730c9242cSDuncan P. N. Exon Smith pImpl->RespectDiagnosticFilters = RespectFilters; 148b4c44d23SQuentin Colombet } 149b4c44d23SQuentin Colombet 15044e5f6c4SBrian Gesiak void LLVMContext::setDiagnosticsHotnessRequested(bool Requested) { 15144e5f6c4SBrian Gesiak pImpl->DiagnosticsHotnessRequested = Requested; 15244e5f6c4SBrian Gesiak } 15344e5f6c4SBrian Gesiak bool LLVMContext::getDiagnosticsHotnessRequested() const { 15444e5f6c4SBrian Gesiak return pImpl->DiagnosticsHotnessRequested; 155aad81608SAdam Nemet } 156aad81608SAdam Nemet 1574ef3daafSBrian Gesiak void LLVMContext::setDiagnosticsHotnessThreshold(uint64_t Threshold) { 1584ef3daafSBrian Gesiak pImpl->DiagnosticsHotnessThreshold = Threshold; 1594ef3daafSBrian Gesiak } 1604ef3daafSBrian Gesiak uint64_t LLVMContext::getDiagnosticsHotnessThreshold() const { 1614ef3daafSBrian Gesiak return pImpl->DiagnosticsHotnessThreshold; 1624ef3daafSBrian Gesiak } 1634ef3daafSBrian Gesiak 164*b8a847c0SFrancis Visoiu Mistrih RemarkStreamer *LLVMContext::getRemarkStreamer() { 165*b8a847c0SFrancis Visoiu Mistrih return pImpl->RemarkDiagStreamer.get(); 166a62b7e1aSAdam Nemet } 167*b8a847c0SFrancis Visoiu Mistrih const RemarkStreamer *LLVMContext::getRemarkStreamer() const { 168*b8a847c0SFrancis Visoiu Mistrih return const_cast<LLVMContext *>(this)->getRemarkStreamer(); 169*b8a847c0SFrancis Visoiu Mistrih } 170*b8a847c0SFrancis Visoiu Mistrih void LLVMContext::setRemarkStreamer( 171*b8a847c0SFrancis Visoiu Mistrih std::unique_ptr<RemarkStreamer> RemarkStreamer) { 172*b8a847c0SFrancis Visoiu Mistrih pImpl->RemarkDiagStreamer = std::move(RemarkStreamer); 173a62b7e1aSAdam Nemet } 174a62b7e1aSAdam Nemet 175b5ab895eSVivek Pandya DiagnosticHandler::DiagnosticHandlerTy 176b5ab895eSVivek Pandya LLVMContext::getDiagnosticHandlerCallBack() const { 177b5ab895eSVivek Pandya return pImpl->DiagHandler->DiagHandlerCallback; 178b4c44d23SQuentin Colombet } 179b4c44d23SQuentin Colombet 180b4c44d23SQuentin Colombet void *LLVMContext::getDiagnosticContext() const { 181b5ab895eSVivek Pandya return pImpl->DiagHandler->DiagnosticContext; 182b4c44d23SQuentin Colombet } 183b4c44d23SQuentin Colombet 18434390c70SJuergen Ributzka void LLVMContext::setYieldCallback(YieldCallbackTy Callback, void *OpaqueHandle) 18534390c70SJuergen Ributzka { 18634390c70SJuergen Ributzka pImpl->YieldCallback = Callback; 18734390c70SJuergen Ributzka pImpl->YieldOpaqueHandle = OpaqueHandle; 18834390c70SJuergen Ributzka } 18934390c70SJuergen Ributzka 19034390c70SJuergen Ributzka void LLVMContext::yield() { 19134390c70SJuergen Ributzka if (pImpl->YieldCallback) 19234390c70SJuergen Ributzka pImpl->YieldCallback(this, pImpl->YieldOpaqueHandle); 19334390c70SJuergen Ributzka } 19434390c70SJuergen Ributzka 195ef860a24SChandler Carruth void LLVMContext::emitError(const Twine &ErrorStr) { 196dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(ErrorStr)); 197ef860a24SChandler Carruth } 198ef860a24SChandler Carruth 199bfb44ef9SBob Wilson void LLVMContext::emitError(const Instruction *I, const Twine &ErrorStr) { 200dec8d55bSQuentin Colombet assert (I && "Invalid instruction"); 201dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(*I, ErrorStr)); 202ef860a24SChandler Carruth } 203ef860a24SChandler Carruth 20430c9242cSDuncan P. N. Exon Smith static bool isDiagnosticEnabled(const DiagnosticInfo &DI) { 2057f8af8bfSDiego Novillo // Optimization remarks are selective. They need to check whether the regexp 2067f8af8bfSDiego Novillo // pattern, passed via one of the -pass-remarks* flags, matches the name of 2077f8af8bfSDiego Novillo // the pass that is emitting the diagnostic. If there is no match, ignore the 2087f8af8bfSDiego Novillo // diagnostic and return. 209f31b1f31SAdam Nemet // 210f31b1f31SAdam Nemet // Also noisy remarks are only enabled if we have hotness information to sort 211f31b1f31SAdam Nemet // them. 212e9148dd6SAkira Hatanaka if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) 213f31b1f31SAdam Nemet return Remark->isEnabled() && 214f31b1f31SAdam Nemet (!Remark->isVerbose() || Remark->getHotness()); 215e9148dd6SAkira Hatanaka 21630c9242cSDuncan P. N. Exon Smith return true; 21730c9242cSDuncan P. N. Exon Smith } 21830c9242cSDuncan P. N. Exon Smith 2194b9c0d4dSRenato Golin const char * 2204b9c0d4dSRenato Golin LLVMContext::getDiagnosticMessagePrefix(DiagnosticSeverity Severity) { 221735c47ecSAlex Lorenz switch (Severity) { 222735c47ecSAlex Lorenz case DS_Error: 223735c47ecSAlex Lorenz return "error"; 224735c47ecSAlex Lorenz case DS_Warning: 225735c47ecSAlex Lorenz return "warning"; 226735c47ecSAlex Lorenz case DS_Remark: 227735c47ecSAlex Lorenz return "remark"; 228735c47ecSAlex Lorenz case DS_Note: 229735c47ecSAlex Lorenz return "note"; 230735c47ecSAlex Lorenz } 2315220476aSAaron Ballman llvm_unreachable("Unknown DiagnosticSeverity"); 232735c47ecSAlex Lorenz } 233735c47ecSAlex Lorenz 23430c9242cSDuncan P. N. Exon Smith void LLVMContext::diagnose(const DiagnosticInfo &DI) { 235*b8a847c0SFrancis Visoiu Mistrih if (auto *OptDiagBase = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) 236*b8a847c0SFrancis Visoiu Mistrih if (RemarkStreamer *RS = getRemarkStreamer()) 237*b8a847c0SFrancis Visoiu Mistrih RS->emit(*OptDiagBase); 238*b8a847c0SFrancis Visoiu Mistrih 23930c9242cSDuncan P. N. Exon Smith // If there is a report handler, use it. 240b5ab895eSVivek Pandya if (pImpl->DiagHandler && 241b5ab895eSVivek Pandya (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && 242b5ab895eSVivek Pandya pImpl->DiagHandler->handleDiagnostics(DI)) 24330c9242cSDuncan P. N. Exon Smith return; 24430c9242cSDuncan P. N. Exon Smith 24530c9242cSDuncan P. N. Exon Smith if (!isDiagnosticEnabled(DI)) 24630c9242cSDuncan P. N. Exon Smith return; 247df655013SDiego Novillo 248b4c44d23SQuentin Colombet // Otherwise, print the message with a prefix based on the severity. 249735c47ecSAlex Lorenz DiagnosticPrinterRawOStream DP(errs()); 250735c47ecSAlex Lorenz errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; 251b4c44d23SQuentin Colombet DI.print(DP); 252735c47ecSAlex Lorenz errs() << "\n"; 253735c47ecSAlex Lorenz if (DI.getSeverity() == DS_Error) 254b4c44d23SQuentin Colombet exit(1); 255b4c44d23SQuentin Colombet } 256b4c44d23SQuentin Colombet 257ef860a24SChandler Carruth void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) { 258dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(LocCookie, ErrorStr)); 259ef860a24SChandler Carruth } 260ef860a24SChandler Carruth 261ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 262ef860a24SChandler Carruth // Metadata Kind Uniquing 263ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 264ef860a24SChandler Carruth 2651ac0d2deSFilipe Cabecinhas /// Return a unique non-zero ID for the specified metadata kind. 266ef860a24SChandler Carruth unsigned LLVMContext::getMDKindID(StringRef Name) const { 267ef860a24SChandler Carruth // If this is new, assign it its ID. 2681ac0d2deSFilipe Cabecinhas return pImpl->CustomMDKindNames.insert( 2691ac0d2deSFilipe Cabecinhas std::make_pair( 2701ac0d2deSFilipe Cabecinhas Name, pImpl->CustomMDKindNames.size())) 2715106ce78SDavid Blaikie .first->second; 272ef860a24SChandler Carruth } 273ef860a24SChandler Carruth 2744104337dSSanjay Patel /// getHandlerNames - Populate client-supplied smallvector using custom 275ef860a24SChandler Carruth /// metadata name and ID. 276ef860a24SChandler Carruth void LLVMContext::getMDKindNames(SmallVectorImpl<StringRef> &Names) const { 277ef860a24SChandler Carruth Names.resize(pImpl->CustomMDKindNames.size()); 278ef860a24SChandler Carruth for (StringMap<unsigned>::const_iterator I = pImpl->CustomMDKindNames.begin(), 279ef860a24SChandler Carruth E = pImpl->CustomMDKindNames.end(); I != E; ++I) 280ef860a24SChandler Carruth Names[I->second] = I->first(); 281ef860a24SChandler Carruth } 2829303c246SSanjoy Das 2839303c246SSanjoy Das void LLVMContext::getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const { 2849303c246SSanjoy Das pImpl->getOperandBundleTags(Tags); 2859303c246SSanjoy Das } 2869303c246SSanjoy Das 2879303c246SSanjoy Das uint32_t LLVMContext::getOperandBundleTagID(StringRef Tag) const { 2889303c246SSanjoy Das return pImpl->getOperandBundleTagID(Tag); 2899303c246SSanjoy Das } 290599ebf27SMehdi Amini 291bb80d3e1SKonstantin Zhuravlyov SyncScope::ID LLVMContext::getOrInsertSyncScopeID(StringRef SSN) { 292bb80d3e1SKonstantin Zhuravlyov return pImpl->getOrInsertSyncScopeID(SSN); 293bb80d3e1SKonstantin Zhuravlyov } 294bb80d3e1SKonstantin Zhuravlyov 295bb80d3e1SKonstantin Zhuravlyov void LLVMContext::getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const { 296bb80d3e1SKonstantin Zhuravlyov pImpl->getSyncScopeNames(SSNs); 297bb80d3e1SKonstantin Zhuravlyov } 298bb80d3e1SKonstantin Zhuravlyov 299599ebf27SMehdi Amini void LLVMContext::setGC(const Function &Fn, std::string GCName) { 300599ebf27SMehdi Amini auto It = pImpl->GCNames.find(&Fn); 301599ebf27SMehdi Amini 302599ebf27SMehdi Amini if (It == pImpl->GCNames.end()) { 303599ebf27SMehdi Amini pImpl->GCNames.insert(std::make_pair(&Fn, std::move(GCName))); 304599ebf27SMehdi Amini return; 305599ebf27SMehdi Amini } 306599ebf27SMehdi Amini It->second = std::move(GCName); 307599ebf27SMehdi Amini } 3085354a8aaSEugene Zelenko 309599ebf27SMehdi Amini const std::string &LLVMContext::getGC(const Function &Fn) { 310599ebf27SMehdi Amini return pImpl->GCNames[&Fn]; 311599ebf27SMehdi Amini } 3125354a8aaSEugene Zelenko 313599ebf27SMehdi Amini void LLVMContext::deleteGC(const Function &Fn) { 314599ebf27SMehdi Amini pImpl->GCNames.erase(&Fn); 315599ebf27SMehdi Amini } 31609b4a8daSMehdi Amini 317e7090155SMehdi Amini bool LLVMContext::shouldDiscardValueNames() const { 318e7090155SMehdi Amini return pImpl->DiscardValueNames; 319e7090155SMehdi Amini } 32009b4a8daSMehdi Amini 321ed8fdb2aSDuncan P. N. Exon Smith bool LLVMContext::isODRUniquingDebugTypes() const { return !!pImpl->DITypeMap; } 3225ab2be09SDuncan P. N. Exon Smith 323ed8fdb2aSDuncan P. N. Exon Smith void LLVMContext::enableDebugTypeODRUniquing() { 3245ab2be09SDuncan P. N. Exon Smith if (pImpl->DITypeMap) 3255ab2be09SDuncan P. N. Exon Smith return; 3265ab2be09SDuncan P. N. Exon Smith 327e8b555c6SDuncan P. N. Exon Smith pImpl->DITypeMap.emplace(); 3285ab2be09SDuncan P. N. Exon Smith } 3295ab2be09SDuncan P. N. Exon Smith 330ed8fdb2aSDuncan P. N. Exon Smith void LLVMContext::disableDebugTypeODRUniquing() { pImpl->DITypeMap.reset(); } 3315ab2be09SDuncan P. N. Exon Smith 33209b4a8daSMehdi Amini void LLVMContext::setDiscardValueNames(bool Discard) { 33309b4a8daSMehdi Amini pImpl->DiscardValueNames = Discard; 33409b4a8daSMehdi Amini } 335aa641a51SAndrew Kaylor 336d29884c7SFedor Sergeev OptPassGate &LLVMContext::getOptPassGate() const { 33798014e43SFedor Sergeev return pImpl->getOptPassGate(); 338aa641a51SAndrew Kaylor } 339b5ab895eSVivek Pandya 340d29884c7SFedor Sergeev void LLVMContext::setOptPassGate(OptPassGate& OPG) { 341d29884c7SFedor Sergeev pImpl->setOptPassGate(OPG); 342d29884c7SFedor Sergeev } 343d29884c7SFedor Sergeev 344b5ab895eSVivek Pandya const DiagnosticHandler *LLVMContext::getDiagHandlerPtr() const { 345b5ab895eSVivek Pandya return pImpl->DiagHandler.get(); 346b5ab895eSVivek Pandya } 347b5ab895eSVivek Pandya 348b5ab895eSVivek Pandya std::unique_ptr<DiagnosticHandler> LLVMContext::getDiagnosticHandler() { 349b5ab895eSVivek Pandya return std::move(pImpl->DiagHandler); 350b5ab895eSVivek Pandya } 351