[llvm] ca1a5b3 - [Coroutine][DebugInfo] Update the linkage name of the declaration of coro-split functions in the debug info.
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 7 17:26:40 PDT 2023
Author: DianQK
Date: 2023-08-08T08:22:46+08:00
New Revision: ca1a5b37c7236dd29a3169859153dfdcce066b51
URL: https://github.com/llvm/llvm-project/commit/ca1a5b37c7236dd29a3169859153dfdcce066b51
DIFF: https://github.com/llvm/llvm-project/commit/ca1a5b37c7236dd29a3169859153dfdcce066b51.diff
LOG: [Coroutine][DebugInfo] Update the linkage name of the declaration of coro-split functions in the debug info.
This patch adds the linkage name update to DISubprogram's declaration after 6ce76ff7eb7640e53b65f0473848ce7d08165c98.
Reviewed By: ChuanqiXu
Differential Revision: https://reviews.llvm.org/D157184
Added:
Modified:
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-async-declaration.ll
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/DebugInfoMetadata.h b/llvm/include/llvm/IR/DebugInfoMetadata.h
index 65612240520971..b9f6d39a749156 100644
--- a/llvm/include/llvm/IR/DebugInfoMetadata.h
+++ b/llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1818,6 +1818,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());
}
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 185cea984c586f..71bcbbbbbcabd7 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -937,9 +937,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);
diff --git a/llvm/test/Transforms/Coroutines/coro-async-declaration.ll b/llvm/test/Transforms/Coroutines/coro-async-declaration.ll
index 37b77b4f16ca90..fb0973576d7852 100644
--- a/llvm/test/Transforms/Coroutines/coro-async-declaration.ll
+++ b/llvm/test/Transforms/Coroutines/coro-async-declaration.ll
@@ -305,9 +305,11 @@ attributes #13 = { nounwind memory(none) }
!43 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "$s4main5entryOXMtD", file: !44, size: 8, flags: DIFlagArtificial, runtimeLang: DW_LANG_Swift, identifier: "$s4main5entryOXMtD")
!44 = !DIFile(filename: "<compiler-generated>", directory: "")
; CHECK-DAG: ![[DECL:[0-9]+]] = !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZ"
+; CHECK-DAG: ![[DECL_Q0:[0-9]+]] = !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZTQ0_"
+; CHECK-DAG: ![[DECL_Y1:[0-9]+]] = !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZTY1_"
; CHECK-DAG: distinct !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZ"{{.*}}, declaration: ![[DECL]]
-; CHECK-DAG: distinct !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZ"{{.*}}, declaration: ![[DECL]]
-; CHECK-DAG: distinct !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZ"{{.*}}, declaration: ![[DECL]]
+; CHECK-DAG: distinct !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZTQ0_"{{.*}}, declaration: ![[DECL_Q0]]
+; CHECK-DAG: distinct !DISubprogram({{.*}}, linkageName: "$s4main5entryOAAyyYaFZTY1_"{{.*}}, declaration: ![[DECL_Y1]]
!45 = !DISubprogram(name: "main", linkageName: "$s4main5entryOAAyyYaFZ", scope: !39, file: !1, line: 2, type: !40, scopeLine: 2, spFlags: 0)
!46 = !{!47, !49}
!47 = !DILocalVariable(name: "self", arg: 1, scope: !38, file: !1, line: 2, type: !48, flags: DIFlagArtificial)
More information about the llvm-commits
mailing list