[PATCH] D157184: [Coroutine][DebugInfo] Update the linkage name of the declaration of coro-split functions in the debug info.
DianQK via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Aug 5 01:08:58 PDT 2023
DianQK created this revision.
Herald added subscribers: ChuanqiXu, hiraditya.
Herald added a project: All.
DianQK requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
This patch adds the linkage name update to DISubprogram's declaration
after 6ce76ff7eb7640e53b65f0473848ce7d08165c98 <https://reviews.llvm.org/rG6ce76ff7eb7640e53b65f0473848ce7d08165c98>.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D157184
Files:
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-async-declaration.ll
Index: llvm/test/Transforms/Coroutines/coro-async-declaration.ll
===================================================================
--- llvm/test/Transforms/Coroutines/coro-async-declaration.ll
+++ llvm/test/Transforms/Coroutines/coro-async-declaration.ll
@@ -305,9 +305,11 @@
!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)
Index: llvm/lib/Transforms/Coroutines/CoroSplit.cpp
===================================================================
--- llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -937,9 +937,22 @@
// 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);
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===================================================================
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -1818,6 +1818,7 @@
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());
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D157184.547462.patch
Type: text/x-patch
Size: 3618 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230805/d3c0d610/attachment.bin>
More information about the llvm-commits
mailing list