Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer DiaSession's symbol init (it is unused by WinPix (or anyone?)) #6187

Merged
merged 2 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions lib/DxilDia/DxilDiaSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,18 @@ void dxil_dia::Session::Init(std::shared_ptr<llvm::LLVMContext> context,
DXASSERT(m_rvaMap[It->second] == It->first,
"instruction mapped to wrong rva");
}
}

// Initialize symbols
try {
m_symsMgr.Init(this);
} catch (const hlsl::Exception &) {
m_symsMgr = dxil_dia::SymbolManager();
const dxil_dia::SymbolManager &dxil_dia::Session::SymMgr() {
if (!m_symsMgr) {
try {
m_symsMgr.reset(new dxil_dia::SymbolManager());
m_symsMgr->Init(this);
} catch (const hlsl::Exception &) {
m_symsMgr.reset(new dxil_dia::SymbolManager());
}
}
return *m_symsMgr;
}

HRESULT dxil_dia::Session::getSourceFileIdByName(llvm::StringRef fileName,
Expand Down Expand Up @@ -138,7 +143,7 @@ STDMETHODIMP dxil_dia::Session::get_globalScope(
*pRetVal = nullptr;

Symbol *ret;
IFR(m_symsMgr.GetGlobalScope(&ret));
IFR(SymMgr().GetGlobalScope(&ret));
*pRetVal = ret;
return S_OK;
}
Expand Down Expand Up @@ -378,7 +383,7 @@ STDMETHODIMP dxil_dia::Session::findInlineFramesByAddr(

HRESULT hr;
SymbolChildrenEnumerator *ChildrenEnum;
IFR(hr = m_symsMgr.DbgScopeOf(It->second, &ChildrenEnum));
IFR(hr = SymMgr().DbgScopeOf(It->second, &ChildrenEnum));

*ppResult = ChildrenEnum;
return hr;
Expand Down
4 changes: 2 additions & 2 deletions lib/DxilDia/DxilDiaSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Session : public IDiaSession, public IDxcPixDxilDebugInfoFactory {
hlsl::DxilModule &DxilModuleRef() { return *m_dxilModule.get(); }
llvm::Module &ModuleRef() { return *m_module.get(); }
llvm::DebugInfoFinder &InfoRef() { return *m_finder.get(); }
const SymbolManager &SymMgr() const { return m_symsMgr; }
const SymbolManager &SymMgr();
const RVAMap &InstructionsRef() const { return m_instructions; }
const std::vector<const llvm::Instruction *> &InstructionLinesRef() const {
return m_instructionLines;
Expand Down Expand Up @@ -499,7 +499,7 @@ class Session : public IDiaSession, public IDxcPixDxilDebugInfoFactory {
std::unordered_map<const llvm::Instruction *, RVA>
m_rvaMap; // Map instruction to its RVA.
LineToInfoMap m_lineToInfoMap;
SymbolManager m_symsMgr;
std::unique_ptr<SymbolManager> m_symsMgr;

private:
CComPtr<IDiaEnumTables> m_pEnumTables;
Expand Down
Loading