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" 227531a503SFrancis Visoiu Mistrih #include "llvm/IR/LLVMRemarkStreamer.h" 239fb823bbSChandler Carruth #include "llvm/IR/Metadata.h" 245354a8aaSEugene Zelenko #include "llvm/IR/Module.h" 257531a503SFrancis Visoiu Mistrih #include "llvm/Remarks/RemarkStreamer.h" 265354a8aaSEugene Zelenko #include "llvm/Support/Casting.h" 275354a8aaSEugene Zelenko #include "llvm/Support/ErrorHandling.h" 285354a8aaSEugene Zelenko #include "llvm/Support/raw_ostream.h" 295354a8aaSEugene Zelenko #include <cassert> 305354a8aaSEugene Zelenko #include <cstdlib> 315354a8aaSEugene Zelenko #include <string> 325354a8aaSEugene Zelenko #include <utility> 335354a8aaSEugene Zelenko 34ef860a24SChandler Carruth using namespace llvm; 35ef860a24SChandler Carruth 36ef860a24SChandler Carruth LLVMContext::LLVMContext() : pImpl(new LLVMContextImpl(*this)) { 37ef860a24SChandler Carruth // Create the fixed metadata kinds. This is done in the same order as the 38ef860a24SChandler Carruth // MD_* enum values so that they correspond. 396f0b4f2eSPeter Collingbourne std::pair<unsigned, StringRef> MDKinds[] = { 40d01ae675SVedant Kumar #define LLVM_FIXED_MD_KIND(EnumID, Name, Value) {EnumID, Name}, 41d01ae675SVedant Kumar #include "llvm/IR/FixedMetadataKinds.def" 42d01ae675SVedant Kumar #undef LLVM_FIXED_MD_KIND 436f0b4f2eSPeter Collingbourne }; 44ef860a24SChandler Carruth 456f0b4f2eSPeter Collingbourne for (auto &MDKind : MDKinds) { 466f0b4f2eSPeter Collingbourne unsigned ID = getMDKindID(MDKind.second); 476f0b4f2eSPeter Collingbourne assert(ID == MDKind.first && "metadata kind id drifted"); 486f0b4f2eSPeter Collingbourne (void)ID; 496f0b4f2eSPeter Collingbourne } 50302b69c9SDehao Chen 51cdafd849SSanjoy Das auto *DeoptEntry = pImpl->getOrInsertBundleTag("deopt"); 52cdafd849SSanjoy Das assert(DeoptEntry->second == LLVMContext::OB_deopt && 53cdafd849SSanjoy Das "deopt operand bundle id drifted!"); 54cdafd849SSanjoy Das (void)DeoptEntry; 553bb88c02SDavid Majnemer 563bb88c02SDavid Majnemer auto *FuncletEntry = pImpl->getOrInsertBundleTag("funclet"); 573bb88c02SDavid Majnemer assert(FuncletEntry->second == LLVMContext::OB_funclet && 583bb88c02SDavid Majnemer "funclet operand bundle id drifted!"); 593bb88c02SDavid Majnemer (void)FuncletEntry; 60a34ce95bSSanjoy Das 61a34ce95bSSanjoy Das auto *GCTransitionEntry = pImpl->getOrInsertBundleTag("gc-transition"); 62a34ce95bSSanjoy Das assert(GCTransitionEntry->second == LLVMContext::OB_gc_transition && 63a34ce95bSSanjoy Das "gc-transition operand bundle id drifted!"); 64a34ce95bSSanjoy Das (void)GCTransitionEntry; 65bb80d3e1SKonstantin Zhuravlyov 66d157a9bcSAndrew Paverd auto *CFGuardTargetEntry = pImpl->getOrInsertBundleTag("cfguardtarget"); 67d157a9bcSAndrew Paverd assert(CFGuardTargetEntry->second == LLVMContext::OB_cfguardtarget && 68d157a9bcSAndrew Paverd "cfguardtarget operand bundle id drifted!"); 69d157a9bcSAndrew Paverd (void)CFGuardTargetEntry; 70d157a9bcSAndrew Paverd 71bb80d3e1SKonstantin Zhuravlyov SyncScope::ID SingleThreadSSID = 72bb80d3e1SKonstantin Zhuravlyov pImpl->getOrInsertSyncScopeID("singlethread"); 73bb80d3e1SKonstantin Zhuravlyov assert(SingleThreadSSID == SyncScope::SingleThread && 74bb80d3e1SKonstantin Zhuravlyov "singlethread synchronization scope ID drifted!"); 75878fdee0SKonstantin Zhuravlyov (void)SingleThreadSSID; 76bb80d3e1SKonstantin Zhuravlyov 77bb80d3e1SKonstantin Zhuravlyov SyncScope::ID SystemSSID = 78bb80d3e1SKonstantin Zhuravlyov pImpl->getOrInsertSyncScopeID(""); 79bb80d3e1SKonstantin Zhuravlyov assert(SystemSSID == SyncScope::System && 80bb80d3e1SKonstantin Zhuravlyov "system synchronization scope ID drifted!"); 81878fdee0SKonstantin Zhuravlyov (void)SystemSSID; 82ef860a24SChandler Carruth } 835354a8aaSEugene Zelenko 84ef860a24SChandler Carruth LLVMContext::~LLVMContext() { delete pImpl; } 85ef860a24SChandler Carruth 86ef860a24SChandler Carruth void LLVMContext::addModule(Module *M) { 87ef860a24SChandler Carruth pImpl->OwnedModules.insert(M); 88ef860a24SChandler Carruth } 89ef860a24SChandler Carruth 90ef860a24SChandler Carruth void LLVMContext::removeModule(Module *M) { 91ef860a24SChandler Carruth pImpl->OwnedModules.erase(M); 92ef860a24SChandler Carruth } 93ef860a24SChandler Carruth 94ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 95ef860a24SChandler Carruth // Recoverable Backend Errors 96ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 97ef860a24SChandler Carruth 98a594fab4SBob Wilson void LLVMContext:: 99a594fab4SBob Wilson setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler, 100ef860a24SChandler Carruth void *DiagContext) { 101a594fab4SBob Wilson pImpl->InlineAsmDiagHandler = DiagHandler; 102a594fab4SBob Wilson pImpl->InlineAsmDiagContext = DiagContext; 103ef860a24SChandler Carruth } 104ef860a24SChandler Carruth 105a594fab4SBob Wilson /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by 106a594fab4SBob Wilson /// setInlineAsmDiagnosticHandler. 107a594fab4SBob Wilson LLVMContext::InlineAsmDiagHandlerTy 108a594fab4SBob Wilson LLVMContext::getInlineAsmDiagnosticHandler() const { 109a594fab4SBob Wilson return pImpl->InlineAsmDiagHandler; 110ef860a24SChandler Carruth } 111ef860a24SChandler Carruth 112a594fab4SBob Wilson /// getInlineAsmDiagnosticContext - Return the diagnostic context set by 113a594fab4SBob Wilson /// setInlineAsmDiagnosticHandler. 114a594fab4SBob Wilson void *LLVMContext::getInlineAsmDiagnosticContext() const { 115a594fab4SBob Wilson return pImpl->InlineAsmDiagContext; 116ef860a24SChandler Carruth } 117ef860a24SChandler Carruth 118b5ab895eSVivek Pandya void LLVMContext::setDiagnosticHandlerCallBack( 119b5ab895eSVivek Pandya DiagnosticHandler::DiagnosticHandlerTy DiagnosticHandler, 120b5ab895eSVivek Pandya void *DiagnosticContext, bool RespectFilters) { 121b5ab895eSVivek Pandya pImpl->DiagHandler->DiagHandlerCallback = DiagnosticHandler; 122b5ab895eSVivek Pandya pImpl->DiagHandler->DiagnosticContext = DiagnosticContext; 123b5ab895eSVivek Pandya pImpl->RespectDiagnosticFilters = RespectFilters; 124b5ab895eSVivek Pandya } 125b5ab895eSVivek Pandya 126b5ab895eSVivek Pandya void LLVMContext::setDiagnosticHandler(std::unique_ptr<DiagnosticHandler> &&DH, 12730c9242cSDuncan P. N. Exon Smith bool RespectFilters) { 128b5ab895eSVivek Pandya pImpl->DiagHandler = std::move(DH); 12930c9242cSDuncan P. N. Exon Smith pImpl->RespectDiagnosticFilters = RespectFilters; 130b4c44d23SQuentin Colombet } 131b4c44d23SQuentin Colombet 13244e5f6c4SBrian Gesiak void LLVMContext::setDiagnosticsHotnessRequested(bool Requested) { 13344e5f6c4SBrian Gesiak pImpl->DiagnosticsHotnessRequested = Requested; 13444e5f6c4SBrian Gesiak } 13544e5f6c4SBrian Gesiak bool LLVMContext::getDiagnosticsHotnessRequested() const { 13644e5f6c4SBrian Gesiak return pImpl->DiagnosticsHotnessRequested; 137aad81608SAdam Nemet } 138aad81608SAdam Nemet 1394ef3daafSBrian Gesiak void LLVMContext::setDiagnosticsHotnessThreshold(uint64_t Threshold) { 1404ef3daafSBrian Gesiak pImpl->DiagnosticsHotnessThreshold = Threshold; 1414ef3daafSBrian Gesiak } 1424ef3daafSBrian Gesiak uint64_t LLVMContext::getDiagnosticsHotnessThreshold() const { 1434ef3daafSBrian Gesiak return pImpl->DiagnosticsHotnessThreshold; 1444ef3daafSBrian Gesiak } 1454ef3daafSBrian Gesiak 1467531a503SFrancis Visoiu Mistrih remarks::RemarkStreamer *LLVMContext::getMainRemarkStreamer() { 1477531a503SFrancis Visoiu Mistrih return pImpl->MainRemarkStreamer.get(); 148a62b7e1aSAdam Nemet } 1497531a503SFrancis Visoiu Mistrih const remarks::RemarkStreamer *LLVMContext::getMainRemarkStreamer() const { 1507531a503SFrancis Visoiu Mistrih return const_cast<LLVMContext *>(this)->getMainRemarkStreamer(); 151b8a847c0SFrancis Visoiu Mistrih } 1527531a503SFrancis Visoiu Mistrih void LLVMContext::setMainRemarkStreamer( 1537531a503SFrancis Visoiu Mistrih std::unique_ptr<remarks::RemarkStreamer> RemarkStreamer) { 1547531a503SFrancis Visoiu Mistrih pImpl->MainRemarkStreamer = std::move(RemarkStreamer); 1557531a503SFrancis Visoiu Mistrih } 1567531a503SFrancis Visoiu Mistrih 1577531a503SFrancis Visoiu Mistrih LLVMRemarkStreamer *LLVMContext::getLLVMRemarkStreamer() { 158*31258878SFrancis Visoiu Mistrih return pImpl->LLVMRS.get(); 1597531a503SFrancis Visoiu Mistrih } 1607531a503SFrancis Visoiu Mistrih const LLVMRemarkStreamer *LLVMContext::getLLVMRemarkStreamer() const { 1617531a503SFrancis Visoiu Mistrih return const_cast<LLVMContext *>(this)->getLLVMRemarkStreamer(); 1627531a503SFrancis Visoiu Mistrih } 1637531a503SFrancis Visoiu Mistrih void LLVMContext::setLLVMRemarkStreamer( 1647531a503SFrancis Visoiu Mistrih std::unique_ptr<LLVMRemarkStreamer> RemarkStreamer) { 165*31258878SFrancis Visoiu Mistrih pImpl->LLVMRS = std::move(RemarkStreamer); 166a62b7e1aSAdam Nemet } 167a62b7e1aSAdam Nemet 168b5ab895eSVivek Pandya DiagnosticHandler::DiagnosticHandlerTy 169b5ab895eSVivek Pandya LLVMContext::getDiagnosticHandlerCallBack() const { 170b5ab895eSVivek Pandya return pImpl->DiagHandler->DiagHandlerCallback; 171b4c44d23SQuentin Colombet } 172b4c44d23SQuentin Colombet 173b4c44d23SQuentin Colombet void *LLVMContext::getDiagnosticContext() const { 174b5ab895eSVivek Pandya return pImpl->DiagHandler->DiagnosticContext; 175b4c44d23SQuentin Colombet } 176b4c44d23SQuentin Colombet 17734390c70SJuergen Ributzka void LLVMContext::setYieldCallback(YieldCallbackTy Callback, void *OpaqueHandle) 17834390c70SJuergen Ributzka { 17934390c70SJuergen Ributzka pImpl->YieldCallback = Callback; 18034390c70SJuergen Ributzka pImpl->YieldOpaqueHandle = OpaqueHandle; 18134390c70SJuergen Ributzka } 18234390c70SJuergen Ributzka 18334390c70SJuergen Ributzka void LLVMContext::yield() { 18434390c70SJuergen Ributzka if (pImpl->YieldCallback) 18534390c70SJuergen Ributzka pImpl->YieldCallback(this, pImpl->YieldOpaqueHandle); 18634390c70SJuergen Ributzka } 18734390c70SJuergen Ributzka 188ef860a24SChandler Carruth void LLVMContext::emitError(const Twine &ErrorStr) { 189dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(ErrorStr)); 190ef860a24SChandler Carruth } 191ef860a24SChandler Carruth 192bfb44ef9SBob Wilson void LLVMContext::emitError(const Instruction *I, const Twine &ErrorStr) { 193dec8d55bSQuentin Colombet assert (I && "Invalid instruction"); 194dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(*I, ErrorStr)); 195ef860a24SChandler Carruth } 196ef860a24SChandler Carruth 19730c9242cSDuncan P. N. Exon Smith static bool isDiagnosticEnabled(const DiagnosticInfo &DI) { 1987f8af8bfSDiego Novillo // Optimization remarks are selective. They need to check whether the regexp 1997f8af8bfSDiego Novillo // pattern, passed via one of the -pass-remarks* flags, matches the name of 2007f8af8bfSDiego Novillo // the pass that is emitting the diagnostic. If there is no match, ignore the 2017f8af8bfSDiego Novillo // diagnostic and return. 202f31b1f31SAdam Nemet // 203f31b1f31SAdam Nemet // Also noisy remarks are only enabled if we have hotness information to sort 204f31b1f31SAdam Nemet // them. 205e9148dd6SAkira Hatanaka if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) 206f31b1f31SAdam Nemet return Remark->isEnabled() && 207f31b1f31SAdam Nemet (!Remark->isVerbose() || Remark->getHotness()); 208e9148dd6SAkira Hatanaka 20930c9242cSDuncan P. N. Exon Smith return true; 21030c9242cSDuncan P. N. Exon Smith } 21130c9242cSDuncan P. N. Exon Smith 2124b9c0d4dSRenato Golin const char * 2134b9c0d4dSRenato Golin LLVMContext::getDiagnosticMessagePrefix(DiagnosticSeverity Severity) { 214735c47ecSAlex Lorenz switch (Severity) { 215735c47ecSAlex Lorenz case DS_Error: 216735c47ecSAlex Lorenz return "error"; 217735c47ecSAlex Lorenz case DS_Warning: 218735c47ecSAlex Lorenz return "warning"; 219735c47ecSAlex Lorenz case DS_Remark: 220735c47ecSAlex Lorenz return "remark"; 221735c47ecSAlex Lorenz case DS_Note: 222735c47ecSAlex Lorenz return "note"; 223735c47ecSAlex Lorenz } 2245220476aSAaron Ballman llvm_unreachable("Unknown DiagnosticSeverity"); 225735c47ecSAlex Lorenz } 226735c47ecSAlex Lorenz 22730c9242cSDuncan P. N. Exon Smith void LLVMContext::diagnose(const DiagnosticInfo &DI) { 228b8a847c0SFrancis Visoiu Mistrih if (auto *OptDiagBase = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) 2297531a503SFrancis Visoiu Mistrih if (LLVMRemarkStreamer *RS = getLLVMRemarkStreamer()) 230b8a847c0SFrancis Visoiu Mistrih RS->emit(*OptDiagBase); 231b8a847c0SFrancis Visoiu Mistrih 23230c9242cSDuncan P. N. Exon Smith // If there is a report handler, use it. 233b5ab895eSVivek Pandya if (pImpl->DiagHandler && 234b5ab895eSVivek Pandya (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) && 235b5ab895eSVivek Pandya pImpl->DiagHandler->handleDiagnostics(DI)) 23630c9242cSDuncan P. N. Exon Smith return; 23730c9242cSDuncan P. N. Exon Smith 23830c9242cSDuncan P. N. Exon Smith if (!isDiagnosticEnabled(DI)) 23930c9242cSDuncan P. N. Exon Smith return; 240df655013SDiego Novillo 241b4c44d23SQuentin Colombet // Otherwise, print the message with a prefix based on the severity. 242735c47ecSAlex Lorenz DiagnosticPrinterRawOStream DP(errs()); 243735c47ecSAlex Lorenz errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; 244b4c44d23SQuentin Colombet DI.print(DP); 245735c47ecSAlex Lorenz errs() << "\n"; 246735c47ecSAlex Lorenz if (DI.getSeverity() == DS_Error) 247b4c44d23SQuentin Colombet exit(1); 248b4c44d23SQuentin Colombet } 249b4c44d23SQuentin Colombet 250ef860a24SChandler Carruth void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) { 251dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(LocCookie, ErrorStr)); 252ef860a24SChandler Carruth } 253ef860a24SChandler Carruth 254ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 255ef860a24SChandler Carruth // Metadata Kind Uniquing 256ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 257ef860a24SChandler Carruth 2581ac0d2deSFilipe Cabecinhas /// Return a unique non-zero ID for the specified metadata kind. 259ef860a24SChandler Carruth unsigned LLVMContext::getMDKindID(StringRef Name) const { 260ef860a24SChandler Carruth // If this is new, assign it its ID. 2611ac0d2deSFilipe Cabecinhas return pImpl->CustomMDKindNames.insert( 2621ac0d2deSFilipe Cabecinhas std::make_pair( 2631ac0d2deSFilipe Cabecinhas Name, pImpl->CustomMDKindNames.size())) 2645106ce78SDavid Blaikie .first->second; 265ef860a24SChandler Carruth } 266ef860a24SChandler Carruth 2674104337dSSanjay Patel /// getHandlerNames - Populate client-supplied smallvector using custom 268ef860a24SChandler Carruth /// metadata name and ID. 269ef860a24SChandler Carruth void LLVMContext::getMDKindNames(SmallVectorImpl<StringRef> &Names) const { 270ef860a24SChandler Carruth Names.resize(pImpl->CustomMDKindNames.size()); 271ef860a24SChandler Carruth for (StringMap<unsigned>::const_iterator I = pImpl->CustomMDKindNames.begin(), 272ef860a24SChandler Carruth E = pImpl->CustomMDKindNames.end(); I != E; ++I) 273ef860a24SChandler Carruth Names[I->second] = I->first(); 274ef860a24SChandler Carruth } 2759303c246SSanjoy Das 2769303c246SSanjoy Das void LLVMContext::getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const { 2779303c246SSanjoy Das pImpl->getOperandBundleTags(Tags); 2789303c246SSanjoy Das } 2799303c246SSanjoy Das 2809303c246SSanjoy Das uint32_t LLVMContext::getOperandBundleTagID(StringRef Tag) const { 2819303c246SSanjoy Das return pImpl->getOperandBundleTagID(Tag); 2829303c246SSanjoy Das } 283599ebf27SMehdi Amini 284bb80d3e1SKonstantin Zhuravlyov SyncScope::ID LLVMContext::getOrInsertSyncScopeID(StringRef SSN) { 285bb80d3e1SKonstantin Zhuravlyov return pImpl->getOrInsertSyncScopeID(SSN); 286bb80d3e1SKonstantin Zhuravlyov } 287bb80d3e1SKonstantin Zhuravlyov 288bb80d3e1SKonstantin Zhuravlyov void LLVMContext::getSyncScopeNames(SmallVectorImpl<StringRef> &SSNs) const { 289bb80d3e1SKonstantin Zhuravlyov pImpl->getSyncScopeNames(SSNs); 290bb80d3e1SKonstantin Zhuravlyov } 291bb80d3e1SKonstantin Zhuravlyov 292599ebf27SMehdi Amini void LLVMContext::setGC(const Function &Fn, std::string GCName) { 293599ebf27SMehdi Amini auto It = pImpl->GCNames.find(&Fn); 294599ebf27SMehdi Amini 295599ebf27SMehdi Amini if (It == pImpl->GCNames.end()) { 296599ebf27SMehdi Amini pImpl->GCNames.insert(std::make_pair(&Fn, std::move(GCName))); 297599ebf27SMehdi Amini return; 298599ebf27SMehdi Amini } 299599ebf27SMehdi Amini It->second = std::move(GCName); 300599ebf27SMehdi Amini } 3015354a8aaSEugene Zelenko 302599ebf27SMehdi Amini const std::string &LLVMContext::getGC(const Function &Fn) { 303599ebf27SMehdi Amini return pImpl->GCNames[&Fn]; 304599ebf27SMehdi Amini } 3055354a8aaSEugene Zelenko 306599ebf27SMehdi Amini void LLVMContext::deleteGC(const Function &Fn) { 307599ebf27SMehdi Amini pImpl->GCNames.erase(&Fn); 308599ebf27SMehdi Amini } 30909b4a8daSMehdi Amini 310e7090155SMehdi Amini bool LLVMContext::shouldDiscardValueNames() const { 311e7090155SMehdi Amini return pImpl->DiscardValueNames; 312e7090155SMehdi Amini } 31309b4a8daSMehdi Amini 314ed8fdb2aSDuncan P. N. Exon Smith bool LLVMContext::isODRUniquingDebugTypes() const { return !!pImpl->DITypeMap; } 3155ab2be09SDuncan P. N. Exon Smith 316ed8fdb2aSDuncan P. N. Exon Smith void LLVMContext::enableDebugTypeODRUniquing() { 3175ab2be09SDuncan P. N. Exon Smith if (pImpl->DITypeMap) 3185ab2be09SDuncan P. N. Exon Smith return; 3195ab2be09SDuncan P. N. Exon Smith 320e8b555c6SDuncan P. N. Exon Smith pImpl->DITypeMap.emplace(); 3215ab2be09SDuncan P. N. Exon Smith } 3225ab2be09SDuncan P. N. Exon Smith 323ed8fdb2aSDuncan P. N. Exon Smith void LLVMContext::disableDebugTypeODRUniquing() { pImpl->DITypeMap.reset(); } 3245ab2be09SDuncan P. N. Exon Smith 32509b4a8daSMehdi Amini void LLVMContext::setDiscardValueNames(bool Discard) { 32609b4a8daSMehdi Amini pImpl->DiscardValueNames = Discard; 32709b4a8daSMehdi Amini } 328aa641a51SAndrew Kaylor 329d29884c7SFedor Sergeev OptPassGate &LLVMContext::getOptPassGate() const { 33098014e43SFedor Sergeev return pImpl->getOptPassGate(); 331aa641a51SAndrew Kaylor } 332b5ab895eSVivek Pandya 333d29884c7SFedor Sergeev void LLVMContext::setOptPassGate(OptPassGate& OPG) { 334d29884c7SFedor Sergeev pImpl->setOptPassGate(OPG); 335d29884c7SFedor Sergeev } 336d29884c7SFedor Sergeev 337b5ab895eSVivek Pandya const DiagnosticHandler *LLVMContext::getDiagHandlerPtr() const { 338b5ab895eSVivek Pandya return pImpl->DiagHandler.get(); 339b5ab895eSVivek Pandya } 340b5ab895eSVivek Pandya 341b5ab895eSVivek Pandya std::unique_ptr<DiagnosticHandler> LLVMContext::getDiagnosticHandler() { 342b5ab895eSVivek Pandya return std::move(pImpl->DiagHandler); 343b5ab895eSVivek Pandya } 344