1ef860a24SChandler Carruth //===-- LLVMContext.cpp - Implement LLVMContext ---------------------------===// 2ef860a24SChandler Carruth // 3ef860a24SChandler Carruth // The LLVM Compiler Infrastructure 4ef860a24SChandler Carruth // 5ef860a24SChandler Carruth // This file is distributed under the University of Illinois Open Source 6ef860a24SChandler Carruth // License. See LICENSE.TXT for details. 7ef860a24SChandler Carruth // 8ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 9ef860a24SChandler Carruth // 10ef860a24SChandler Carruth // This file implements LLVMContext, as a wrapper around the opaque 11ef860a24SChandler Carruth // class LLVMContextImpl. 12ef860a24SChandler Carruth // 13ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 14ef860a24SChandler Carruth 159fb823bbSChandler Carruth #include "llvm/IR/LLVMContext.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" 20ef860a24SChandler Carruth #include "LLVMContextImpl.h" 21b4c44d23SQuentin Colombet #include "llvm/IR/DiagnosticInfo.h" 22b4c44d23SQuentin Colombet #include "llvm/IR/DiagnosticPrinter.h" 239fb823bbSChandler Carruth #include "llvm/IR/Metadata.h" 245354a8aaSEugene Zelenko #include "llvm/IR/Module.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. 38ef860a24SChandler Carruth 39ef860a24SChandler Carruth // Create the 'dbg' metadata kind. 40ef860a24SChandler Carruth unsigned DbgID = getMDKindID("dbg"); 41ef860a24SChandler Carruth assert(DbgID == MD_dbg && "dbg kind id drifted"); (void)DbgID; 42ef860a24SChandler Carruth 43ef860a24SChandler Carruth // Create the 'tbaa' metadata kind. 44ef860a24SChandler Carruth unsigned TBAAID = getMDKindID("tbaa"); 45ef860a24SChandler Carruth assert(TBAAID == MD_tbaa && "tbaa kind id drifted"); (void)TBAAID; 46ef860a24SChandler Carruth 47ef860a24SChandler Carruth // Create the 'prof' metadata kind. 48ef860a24SChandler Carruth unsigned ProfID = getMDKindID("prof"); 49ef860a24SChandler Carruth assert(ProfID == MD_prof && "prof kind id drifted"); (void)ProfID; 50ef860a24SChandler Carruth 51ef860a24SChandler Carruth // Create the 'fpmath' metadata kind. 52ef860a24SChandler Carruth unsigned FPAccuracyID = getMDKindID("fpmath"); 53ef860a24SChandler Carruth assert(FPAccuracyID == MD_fpmath && "fpmath kind id drifted"); 54ef860a24SChandler Carruth (void)FPAccuracyID; 55ef860a24SChandler Carruth 56ef860a24SChandler Carruth // Create the 'range' metadata kind. 57ef860a24SChandler Carruth unsigned RangeID = getMDKindID("range"); 58ef860a24SChandler Carruth assert(RangeID == MD_range && "range kind id drifted"); 59ef860a24SChandler Carruth (void)RangeID; 60ef860a24SChandler Carruth 61ef860a24SChandler Carruth // Create the 'tbaa.struct' metadata kind. 62ef860a24SChandler Carruth unsigned TBAAStructID = getMDKindID("tbaa.struct"); 63ef860a24SChandler Carruth assert(TBAAStructID == MD_tbaa_struct && "tbaa.struct kind id drifted"); 64ef860a24SChandler Carruth (void)TBAAStructID; 65408bdad5SShuxin Yang 66408bdad5SShuxin Yang // Create the 'invariant.load' metadata kind. 67408bdad5SShuxin Yang unsigned InvariantLdId = getMDKindID("invariant.load"); 68408bdad5SShuxin Yang assert(InvariantLdId == MD_invariant_load && "invariant.load kind id drifted"); 69408bdad5SShuxin Yang (void)InvariantLdId; 709414665aSHal Finkel 719414665aSHal Finkel // Create the 'alias.scope' metadata kind. 729414665aSHal Finkel unsigned AliasScopeID = getMDKindID("alias.scope"); 739414665aSHal Finkel assert(AliasScopeID == MD_alias_scope && "alias.scope kind id drifted"); 749414665aSHal Finkel (void)AliasScopeID; 759414665aSHal Finkel 769414665aSHal Finkel // Create the 'noalias' metadata kind. 779414665aSHal Finkel unsigned NoAliasID = getMDKindID("noalias"); 789414665aSHal Finkel assert(NoAliasID == MD_noalias && "noalias kind id drifted"); 799414665aSHal Finkel (void)NoAliasID; 805a3f5f75SPhilip Reames 815a3f5f75SPhilip Reames // Create the 'nontemporal' metadata kind. 825a3f5f75SPhilip Reames unsigned NonTemporalID = getMDKindID("nontemporal"); 835a3f5f75SPhilip Reames assert(NonTemporalID == MD_nontemporal && "nontemporal kind id drifted"); 845a3f5f75SPhilip Reames (void)NonTemporalID; 855a3f5f75SPhilip Reames 865a3f5f75SPhilip Reames // Create the 'llvm.mem.parallel_loop_access' metadata kind. 875a3f5f75SPhilip Reames unsigned MemParallelLoopAccessID = getMDKindID("llvm.mem.parallel_loop_access"); 885a3f5f75SPhilip Reames assert(MemParallelLoopAccessID == MD_mem_parallel_loop_access && 895a3f5f75SPhilip Reames "mem_parallel_loop_access kind id drifted"); 905a3f5f75SPhilip Reames (void)MemParallelLoopAccessID; 915a3f5f75SPhilip Reames 925a3f5f75SPhilip Reames // Create the 'nonnull' metadata kind. 935a3f5f75SPhilip Reames unsigned NonNullID = getMDKindID("nonnull"); 945a3f5f75SPhilip Reames assert(NonNullID == MD_nonnull && "nonnull kind id drifted"); 955a3f5f75SPhilip Reames (void)NonNullID; 96f999547dSSanjoy Das 97f999547dSSanjoy Das // Create the 'dereferenceable' metadata kind. 98f999547dSSanjoy Das unsigned DereferenceableID = getMDKindID("dereferenceable"); 99f999547dSSanjoy Das assert(DereferenceableID == MD_dereferenceable && 100f999547dSSanjoy Das "dereferenceable kind id drifted"); 101f999547dSSanjoy Das (void)DereferenceableID; 102f999547dSSanjoy Das 103f999547dSSanjoy Das // Create the 'dereferenceable_or_null' metadata kind. 104f999547dSSanjoy Das unsigned DereferenceableOrNullID = getMDKindID("dereferenceable_or_null"); 105f999547dSSanjoy Das assert(DereferenceableOrNullID == MD_dereferenceable_or_null && 106f999547dSSanjoy Das "dereferenceable_or_null kind id drifted"); 107f999547dSSanjoy Das (void)DereferenceableOrNullID; 10800038784SChen Li 10900038784SChen Li // Create the 'make.implicit' metadata kind. 11000038784SChen Li unsigned MakeImplicitID = getMDKindID("make.implicit"); 11100038784SChen Li assert(MakeImplicitID == MD_make_implicit && 11200038784SChen Li "make.implicit kind id drifted"); 11300038784SChen Li (void)MakeImplicitID; 114a99ab1f5SSanjay Patel 115a99ab1f5SSanjay Patel // Create the 'unpredictable' metadata kind. 116a99ab1f5SSanjay Patel unsigned UnpredictableID = getMDKindID("unpredictable"); 117a99ab1f5SSanjay Patel assert(UnpredictableID == MD_unpredictable && 118a99ab1f5SSanjay Patel "unpredictable kind id drifted"); 119a99ab1f5SSanjay Patel (void)UnpredictableID; 120ea09288eSPiotr Padlewski 121ea09288eSPiotr Padlewski // Create the 'invariant.group' metadata kind. 122ea09288eSPiotr Padlewski unsigned InvariantGroupId = getMDKindID("invariant.group"); 123ea09288eSPiotr Padlewski assert(InvariantGroupId == MD_invariant_group && 124ea09288eSPiotr Padlewski "invariant.group kind id drifted"); 125ea09288eSPiotr Padlewski (void)InvariantGroupId; 126ea09288eSPiotr Padlewski 127b4d00904SArtur Pilipenko // Create the 'align' metadata kind. 128b4d00904SArtur Pilipenko unsigned AlignID = getMDKindID("align"); 129b4d00904SArtur Pilipenko assert(AlignID == MD_align && "align kind id drifted"); 130b4d00904SArtur Pilipenko (void)AlignID; 131cdafd849SSanjoy Das 1321d15a9f0SDuncan P. N. Exon Smith // Create the 'llvm.loop' metadata kind. 1331d15a9f0SDuncan P. N. Exon Smith unsigned LoopID = getMDKindID("llvm.loop"); 1341d15a9f0SDuncan P. N. Exon Smith assert(LoopID == MD_loop && "llvm.loop kind id drifted"); 1351d15a9f0SDuncan P. N. Exon Smith (void)LoopID; 1361d15a9f0SDuncan P. N. Exon Smith 1377efd7506SPeter Collingbourne unsigned TypeID = getMDKindID("type"); 1387efd7506SPeter Collingbourne assert(TypeID == MD_type && "type kind id drifted"); 1397efd7506SPeter Collingbourne (void)TypeID; 1407efd7506SPeter Collingbourne 141302b69c9SDehao Chen unsigned SectionPrefixID = getMDKindID("section_prefix"); 142302b69c9SDehao Chen assert(SectionPrefixID == MD_section_prefix && 143302b69c9SDehao Chen "section_prefix kind id drifted"); 144302b69c9SDehao Chen (void)SectionPrefixID; 145302b69c9SDehao Chen 146cdafd849SSanjoy Das auto *DeoptEntry = pImpl->getOrInsertBundleTag("deopt"); 147cdafd849SSanjoy Das assert(DeoptEntry->second == LLVMContext::OB_deopt && 148cdafd849SSanjoy Das "deopt operand bundle id drifted!"); 149cdafd849SSanjoy Das (void)DeoptEntry; 1503bb88c02SDavid Majnemer 1513bb88c02SDavid Majnemer auto *FuncletEntry = pImpl->getOrInsertBundleTag("funclet"); 1523bb88c02SDavid Majnemer assert(FuncletEntry->second == LLVMContext::OB_funclet && 1533bb88c02SDavid Majnemer "funclet operand bundle id drifted!"); 1543bb88c02SDavid Majnemer (void)FuncletEntry; 155a34ce95bSSanjoy Das 156a34ce95bSSanjoy Das auto *GCTransitionEntry = pImpl->getOrInsertBundleTag("gc-transition"); 157a34ce95bSSanjoy Das assert(GCTransitionEntry->second == LLVMContext::OB_gc_transition && 158a34ce95bSSanjoy Das "gc-transition operand bundle id drifted!"); 159a34ce95bSSanjoy Das (void)GCTransitionEntry; 160ef860a24SChandler Carruth } 1615354a8aaSEugene Zelenko 162ef860a24SChandler Carruth LLVMContext::~LLVMContext() { delete pImpl; } 163ef860a24SChandler Carruth 164ef860a24SChandler Carruth void LLVMContext::addModule(Module *M) { 165ef860a24SChandler Carruth pImpl->OwnedModules.insert(M); 166ef860a24SChandler Carruth } 167ef860a24SChandler Carruth 168ef860a24SChandler Carruth void LLVMContext::removeModule(Module *M) { 169ef860a24SChandler Carruth pImpl->OwnedModules.erase(M); 170ef860a24SChandler Carruth } 171ef860a24SChandler Carruth 172ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 173ef860a24SChandler Carruth // Recoverable Backend Errors 174ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 175ef860a24SChandler Carruth 176a594fab4SBob Wilson void LLVMContext:: 177a594fab4SBob Wilson setInlineAsmDiagnosticHandler(InlineAsmDiagHandlerTy DiagHandler, 178ef860a24SChandler Carruth void *DiagContext) { 179a594fab4SBob Wilson pImpl->InlineAsmDiagHandler = DiagHandler; 180a594fab4SBob Wilson pImpl->InlineAsmDiagContext = DiagContext; 181ef860a24SChandler Carruth } 182ef860a24SChandler Carruth 183a594fab4SBob Wilson /// getInlineAsmDiagnosticHandler - Return the diagnostic handler set by 184a594fab4SBob Wilson /// setInlineAsmDiagnosticHandler. 185a594fab4SBob Wilson LLVMContext::InlineAsmDiagHandlerTy 186a594fab4SBob Wilson LLVMContext::getInlineAsmDiagnosticHandler() const { 187a594fab4SBob Wilson return pImpl->InlineAsmDiagHandler; 188ef860a24SChandler Carruth } 189ef860a24SChandler Carruth 190a594fab4SBob Wilson /// getInlineAsmDiagnosticContext - Return the diagnostic context set by 191a594fab4SBob Wilson /// setInlineAsmDiagnosticHandler. 192a594fab4SBob Wilson void *LLVMContext::getInlineAsmDiagnosticContext() const { 193a594fab4SBob Wilson return pImpl->InlineAsmDiagContext; 194ef860a24SChandler Carruth } 195ef860a24SChandler Carruth 196b4c44d23SQuentin Colombet void LLVMContext::setDiagnosticHandler(DiagnosticHandlerTy DiagnosticHandler, 19730c9242cSDuncan P. N. Exon Smith void *DiagnosticContext, 19830c9242cSDuncan P. N. Exon Smith bool RespectFilters) { 199b4c44d23SQuentin Colombet pImpl->DiagnosticHandler = DiagnosticHandler; 200b4c44d23SQuentin Colombet pImpl->DiagnosticContext = DiagnosticContext; 20130c9242cSDuncan P. N. Exon Smith pImpl->RespectDiagnosticFilters = RespectFilters; 202b4c44d23SQuentin Colombet } 203b4c44d23SQuentin Colombet 204aad81608SAdam Nemet void LLVMContext::setDiagnosticHotnessRequested(bool Requested) { 205aad81608SAdam Nemet pImpl->DiagnosticHotnessRequested = Requested; 206aad81608SAdam Nemet } 207aad81608SAdam Nemet bool LLVMContext::getDiagnosticHotnessRequested() const { 208aad81608SAdam Nemet return pImpl->DiagnosticHotnessRequested; 209aad81608SAdam Nemet } 210aad81608SAdam Nemet 211a62b7e1aSAdam Nemet yaml::Output *LLVMContext::getDiagnosticsOutputFile() { 212a62b7e1aSAdam Nemet return pImpl->DiagnosticsOutputFile.get(); 213a62b7e1aSAdam Nemet } 214a62b7e1aSAdam Nemet 215*6f408368SMehdi Amini void LLVMContext::setDiagnosticsOutputFile(std::unique_ptr<yaml::Output> F) { 216*6f408368SMehdi Amini pImpl->DiagnosticsOutputFile = std::move(F); 217a62b7e1aSAdam Nemet } 218a62b7e1aSAdam Nemet 219b4c44d23SQuentin Colombet LLVMContext::DiagnosticHandlerTy LLVMContext::getDiagnosticHandler() const { 220b4c44d23SQuentin Colombet return pImpl->DiagnosticHandler; 221b4c44d23SQuentin Colombet } 222b4c44d23SQuentin Colombet 223b4c44d23SQuentin Colombet void *LLVMContext::getDiagnosticContext() const { 224b4c44d23SQuentin Colombet return pImpl->DiagnosticContext; 225b4c44d23SQuentin Colombet } 226b4c44d23SQuentin Colombet 22734390c70SJuergen Ributzka void LLVMContext::setYieldCallback(YieldCallbackTy Callback, void *OpaqueHandle) 22834390c70SJuergen Ributzka { 22934390c70SJuergen Ributzka pImpl->YieldCallback = Callback; 23034390c70SJuergen Ributzka pImpl->YieldOpaqueHandle = OpaqueHandle; 23134390c70SJuergen Ributzka } 23234390c70SJuergen Ributzka 23334390c70SJuergen Ributzka void LLVMContext::yield() { 23434390c70SJuergen Ributzka if (pImpl->YieldCallback) 23534390c70SJuergen Ributzka pImpl->YieldCallback(this, pImpl->YieldOpaqueHandle); 23634390c70SJuergen Ributzka } 23734390c70SJuergen Ributzka 238ef860a24SChandler Carruth void LLVMContext::emitError(const Twine &ErrorStr) { 239dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(ErrorStr)); 240ef860a24SChandler Carruth } 241ef860a24SChandler Carruth 242bfb44ef9SBob Wilson void LLVMContext::emitError(const Instruction *I, const Twine &ErrorStr) { 243dec8d55bSQuentin Colombet assert (I && "Invalid instruction"); 244dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(*I, ErrorStr)); 245ef860a24SChandler Carruth } 246ef860a24SChandler Carruth 24730c9242cSDuncan P. N. Exon Smith static bool isDiagnosticEnabled(const DiagnosticInfo &DI) { 2487f8af8bfSDiego Novillo // Optimization remarks are selective. They need to check whether the regexp 2497f8af8bfSDiego Novillo // pattern, passed via one of the -pass-remarks* flags, matches the name of 2507f8af8bfSDiego Novillo // the pass that is emitting the diagnostic. If there is no match, ignore the 2517f8af8bfSDiego Novillo // diagnostic and return. 252e9148dd6SAkira Hatanaka if (auto *Remark = dyn_cast<DiagnosticInfoOptimizationBase>(&DI)) 253e9148dd6SAkira Hatanaka return Remark->isEnabled(); 254e9148dd6SAkira Hatanaka 25530c9242cSDuncan P. N. Exon Smith return true; 25630c9242cSDuncan P. N. Exon Smith } 25730c9242cSDuncan P. N. Exon Smith 2584b9c0d4dSRenato Golin const char * 2594b9c0d4dSRenato Golin LLVMContext::getDiagnosticMessagePrefix(DiagnosticSeverity Severity) { 260735c47ecSAlex Lorenz switch (Severity) { 261735c47ecSAlex Lorenz case DS_Error: 262735c47ecSAlex Lorenz return "error"; 263735c47ecSAlex Lorenz case DS_Warning: 264735c47ecSAlex Lorenz return "warning"; 265735c47ecSAlex Lorenz case DS_Remark: 266735c47ecSAlex Lorenz return "remark"; 267735c47ecSAlex Lorenz case DS_Note: 268735c47ecSAlex Lorenz return "note"; 269735c47ecSAlex Lorenz } 2705220476aSAaron Ballman llvm_unreachable("Unknown DiagnosticSeverity"); 271735c47ecSAlex Lorenz } 272735c47ecSAlex Lorenz 27330c9242cSDuncan P. N. Exon Smith void LLVMContext::diagnose(const DiagnosticInfo &DI) { 27430c9242cSDuncan P. N. Exon Smith // If there is a report handler, use it. 27530c9242cSDuncan P. N. Exon Smith if (pImpl->DiagnosticHandler) { 27630c9242cSDuncan P. N. Exon Smith if (!pImpl->RespectDiagnosticFilters || isDiagnosticEnabled(DI)) 27730c9242cSDuncan P. N. Exon Smith pImpl->DiagnosticHandler(DI, pImpl->DiagnosticContext); 27830c9242cSDuncan P. N. Exon Smith return; 27930c9242cSDuncan P. N. Exon Smith } 28030c9242cSDuncan P. N. Exon Smith 28130c9242cSDuncan P. N. Exon Smith if (!isDiagnosticEnabled(DI)) 28230c9242cSDuncan P. N. Exon Smith return; 283df655013SDiego Novillo 284b4c44d23SQuentin Colombet // Otherwise, print the message with a prefix based on the severity. 285735c47ecSAlex Lorenz DiagnosticPrinterRawOStream DP(errs()); 286735c47ecSAlex Lorenz errs() << getDiagnosticMessagePrefix(DI.getSeverity()) << ": "; 287b4c44d23SQuentin Colombet DI.print(DP); 288735c47ecSAlex Lorenz errs() << "\n"; 289735c47ecSAlex Lorenz if (DI.getSeverity() == DS_Error) 290b4c44d23SQuentin Colombet exit(1); 291b4c44d23SQuentin Colombet } 292b4c44d23SQuentin Colombet 293ef860a24SChandler Carruth void LLVMContext::emitError(unsigned LocCookie, const Twine &ErrorStr) { 294dec8d55bSQuentin Colombet diagnose(DiagnosticInfoInlineAsm(LocCookie, ErrorStr)); 295ef860a24SChandler Carruth } 296ef860a24SChandler Carruth 297ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 298ef860a24SChandler Carruth // Metadata Kind Uniquing 299ef860a24SChandler Carruth //===----------------------------------------------------------------------===// 300ef860a24SChandler Carruth 3011ac0d2deSFilipe Cabecinhas /// Return a unique non-zero ID for the specified metadata kind. 302ef860a24SChandler Carruth unsigned LLVMContext::getMDKindID(StringRef Name) const { 303ef860a24SChandler Carruth // If this is new, assign it its ID. 3041ac0d2deSFilipe Cabecinhas return pImpl->CustomMDKindNames.insert( 3051ac0d2deSFilipe Cabecinhas std::make_pair( 3061ac0d2deSFilipe Cabecinhas Name, pImpl->CustomMDKindNames.size())) 3075106ce78SDavid Blaikie .first->second; 308ef860a24SChandler Carruth } 309ef860a24SChandler Carruth 3104104337dSSanjay Patel /// getHandlerNames - Populate client-supplied smallvector using custom 311ef860a24SChandler Carruth /// metadata name and ID. 312ef860a24SChandler Carruth void LLVMContext::getMDKindNames(SmallVectorImpl<StringRef> &Names) const { 313ef860a24SChandler Carruth Names.resize(pImpl->CustomMDKindNames.size()); 314ef860a24SChandler Carruth for (StringMap<unsigned>::const_iterator I = pImpl->CustomMDKindNames.begin(), 315ef860a24SChandler Carruth E = pImpl->CustomMDKindNames.end(); I != E; ++I) 316ef860a24SChandler Carruth Names[I->second] = I->first(); 317ef860a24SChandler Carruth } 3189303c246SSanjoy Das 3199303c246SSanjoy Das void LLVMContext::getOperandBundleTags(SmallVectorImpl<StringRef> &Tags) const { 3209303c246SSanjoy Das pImpl->getOperandBundleTags(Tags); 3219303c246SSanjoy Das } 3229303c246SSanjoy Das 3239303c246SSanjoy Das uint32_t LLVMContext::getOperandBundleTagID(StringRef Tag) const { 3249303c246SSanjoy Das return pImpl->getOperandBundleTagID(Tag); 3259303c246SSanjoy Das } 326599ebf27SMehdi Amini 327599ebf27SMehdi Amini void LLVMContext::setGC(const Function &Fn, std::string GCName) { 328599ebf27SMehdi Amini auto It = pImpl->GCNames.find(&Fn); 329599ebf27SMehdi Amini 330599ebf27SMehdi Amini if (It == pImpl->GCNames.end()) { 331599ebf27SMehdi Amini pImpl->GCNames.insert(std::make_pair(&Fn, std::move(GCName))); 332599ebf27SMehdi Amini return; 333599ebf27SMehdi Amini } 334599ebf27SMehdi Amini It->second = std::move(GCName); 335599ebf27SMehdi Amini } 3365354a8aaSEugene Zelenko 337599ebf27SMehdi Amini const std::string &LLVMContext::getGC(const Function &Fn) { 338599ebf27SMehdi Amini return pImpl->GCNames[&Fn]; 339599ebf27SMehdi Amini } 3405354a8aaSEugene Zelenko 341599ebf27SMehdi Amini void LLVMContext::deleteGC(const Function &Fn) { 342599ebf27SMehdi Amini pImpl->GCNames.erase(&Fn); 343599ebf27SMehdi Amini } 34409b4a8daSMehdi Amini 345e7090155SMehdi Amini bool LLVMContext::shouldDiscardValueNames() const { 346e7090155SMehdi Amini return pImpl->DiscardValueNames; 347e7090155SMehdi Amini } 34809b4a8daSMehdi Amini 349ed8fdb2aSDuncan P. N. Exon Smith bool LLVMContext::isODRUniquingDebugTypes() const { return !!pImpl->DITypeMap; } 3505ab2be09SDuncan P. N. Exon Smith 351ed8fdb2aSDuncan P. N. Exon Smith void LLVMContext::enableDebugTypeODRUniquing() { 3525ab2be09SDuncan P. N. Exon Smith if (pImpl->DITypeMap) 3535ab2be09SDuncan P. N. Exon Smith return; 3545ab2be09SDuncan P. N. Exon Smith 355e8b555c6SDuncan P. N. Exon Smith pImpl->DITypeMap.emplace(); 3565ab2be09SDuncan P. N. Exon Smith } 3575ab2be09SDuncan P. N. Exon Smith 358ed8fdb2aSDuncan P. N. Exon Smith void LLVMContext::disableDebugTypeODRUniquing() { pImpl->DITypeMap.reset(); } 3595ab2be09SDuncan P. N. Exon Smith 36009b4a8daSMehdi Amini void LLVMContext::setDiscardValueNames(bool Discard) { 36109b4a8daSMehdi Amini pImpl->DiscardValueNames = Discard; 36209b4a8daSMehdi Amini } 363aa641a51SAndrew Kaylor 364aa641a51SAndrew Kaylor OptBisect &LLVMContext::getOptBisect() { 365aa641a51SAndrew Kaylor return pImpl->getOptBisect(); 366aa641a51SAndrew Kaylor } 367