diff options
author | Vladislav Dzhidzhoev <vdzhidzhoev@accesssoftek.com> | 2024-01-11 17:08:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-11 17:08:12 +0100 |
commit | fc6faa1113e9069f41b5500db051210af0eea843 (patch) | |
tree | 105a76fe962bf21897f044fb563d7b5abd83a226 /llvm/lib/IR/DebugInfo.cpp | |
parent | 31ce0f1dda3caed829db09b9212eac54a8a28572 (diff) | |
download | llvm-fc6faa1113e9069f41b5500db051210af0eea843.zip llvm-fc6faa1113e9069f41b5500db051210af0eea843.tar.gz llvm-fc6faa1113e9069f41b5500db051210af0eea843.tar.bz2 |
[CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined functions (#75385)
- [DebugMetadata][DwarfDebug] Support function-local types in lexical
block scopes (4/7)
- [CloneFunction][DebugInfo] Avoid cloning DILocalVariables of inlined
functions
This is a follow-up for https://reviews.llvm.org/D144006, fixing a crash
reported
in Chromium (https://reviews.llvm.org/D144006#4651955).
The first commit is added for convenience, as it has already been
accepted.
If DISubpogram was not cloned (e.g. we are cloning a function that has
other
functions inlined into it, and subprograms of the inlined functions are
not supposed to be cloned), it doesn't make sense to clone its
DILocalVariables as well.
Otherwise get duplicated DILocalVariables not tracked in their
subprogram's retainedNodes, that crash LTO with Chromium.
This is meant to be committed along with
https://reviews.llvm.org/D144006.
Diffstat (limited to 'llvm/lib/IR/DebugInfo.cpp')
-rw-r--r-- | llvm/lib/IR/DebugInfo.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp index c6dc42e..316197a 100644 --- a/llvm/lib/IR/DebugInfo.cpp +++ b/llvm/lib/IR/DebugInfo.cpp @@ -193,7 +193,7 @@ void DebugInfoFinder::processCompileUnit(DICompileUnit *CU) { void DebugInfoFinder::processInstruction(const Module &M, const Instruction &I) { if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) - processVariable(M, DVI->getVariable()); + processVariable(DVI->getVariable()); if (auto DbgLoc = I.getDebugLoc()) processLocation(M, DbgLoc.get()); @@ -210,7 +210,7 @@ void DebugInfoFinder::processLocation(const Module &M, const DILocation *Loc) { } void DebugInfoFinder::processDPValue(const Module &M, const DPValue &DPV) { - processVariable(M, DPV.getVariable()); + processVariable(DPV.getVariable()); processLocation(M, DPV.getDebugLoc().get()); } @@ -285,12 +285,18 @@ void DebugInfoFinder::processSubprogram(DISubprogram *SP) { processType(TVal->getType()); } } + + for (auto *N : SP->getRetainedNodes()) { + if (auto *Var = dyn_cast_or_null<DILocalVariable>(N)) { + processVariable(Var); + } + } } -void DebugInfoFinder::processVariable(const Module &M, - const DILocalVariable *DV) { +void DebugInfoFinder::processVariable(DILocalVariable *DV) { if (!NodesSeen.insert(DV).second) return; + LVs.push_back(DV); processScope(DV->getScope()); processType(DV->getType()); } |