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

[Coroutine][DebugInfo] Update the linkage name of the declaration of coro-split functions in the debug info. #7168

Merged
merged 3 commits into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions llvm/include/llvm/IR/DebugInfoMetadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -2085,6 +2085,7 @@ class DISubprogram : public DILocalScope {
DISubprogram *getDeclaration() const {
return cast_or_null<DISubprogram>(getRawDeclaration());
}
void replaceDeclaration(DISubprogram *Decl) { replaceOperandWith(6, Decl); }
DINodeArray getRetainedNodes() const {
return cast_or_null<MDTuple>(getRawRetainedNodes());
}
Expand Down
17 changes: 15 additions & 2 deletions llvm/lib/Transforms/Coroutines/CoroSplit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,22 @@ void CoroCloner::create() {
// abstract specification, since the DWARF backend expects the
// abstract specification to contain the linkage name and asserts
// that they are identical.
if (!SP->getDeclaration() && SP->getUnit() &&
SP->getUnit()->getSourceLanguage() == dwarf::DW_LANG_Swift)
if (SP->getUnit() &&
SP->getUnit()->getSourceLanguage() == dwarf::DW_LANG_Swift) {
SP->replaceLinkageName(MDString::get(Context, NewF->getName()));
if (auto *Decl = SP->getDeclaration()) {
auto *NewDecl = DISubprogram::get(
Decl->getContext(), Decl->getScope(), Decl->getName(),
NewF->getName(), Decl->getFile(), Decl->getLine(), Decl->getType(),
Decl->getScopeLine(), Decl->getContainingType(),
Decl->getVirtualIndex(), Decl->getThisAdjustment(),
Decl->getFlags(), Decl->getSPFlags(), Decl->getUnit(),
Decl->getTemplateParams(), nullptr, Decl->getRetainedNodes(),
Decl->getThrownTypes(), Decl->getAnnotations(),
Decl->getTargetFuncName());
SP->replaceDeclaration(NewDecl);
}
}
}

NewF->setLinkage(savedLinkage);
Expand Down
Loading