[PATCH] D98799: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and debug linkage name.
Hongtao Yu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 18 22:12:03 PDT 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfc1812a0ad75: [UniqueLinkageName] Use consistent checks when mangling symbo linkage name and… (authored by hoy).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D98799/new/
https://reviews.llvm.org/D98799
Files:
clang/lib/AST/ItaniumMangle.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
Index: clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
===================================================================
--- clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
+++ clang/test/CodeGen/unique-internal-linkage-names-dwarf.c
@@ -8,21 +8,48 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited -dwarf-version=5 -funique-internal-linkage-names -emit-llvm -o - %s | FileCheck %s --check-prefix=UNIQUE
static int glob;
+// foo should be given a uniquefied name under -funique-internal-linkage-names.
static int foo(void) {
return glob;
}
+// bar should not be given a uniquefied name under -funique-internal-linkage-names,
+// since it doesn't come with valid prototype.
+static int bar(a) int a;
+{
+ return glob + a;
+}
+
+// go should be given a uniquefied name under -funique-internal-linkage-names, even
+// if its definition doesn't come with a valid prototype, but the declaration here
+// has a prototype.
+static int go(int);
+
void baz() {
foo();
+ bar(1);
+ go(2);
}
+static int go(a) int a;
+{
+ return glob + a;
+}
+
+
// PLAIN: @glob = internal global i32
// PLAIN: define internal i32 @foo()
+// PLAIN: define internal i32 @bar(i32 %a)
// PLAIN: distinct !DIGlobalVariable(name: "glob"{{.*}})
// PLAIN: distinct !DISubprogram(name: "foo"{{.*}})
+// PLAIN: distinct !DISubprogram(name: "bar"{{.*}})
+// PLAIN: distinct !DISubprogram(name: "go"{{.*}})
// PLAIN-NOT: linkageName:
//
// UNIQUE: @glob = internal global i32
// UNIQUE: define internal i32 @_ZL3foov.[[MODHASH:__uniq.[0-9]+]]()
+// UNIQUE: define internal i32 @bar(i32 %a)
+// UNIQUE: define internal i32 @_ZL2goi.[[MODHASH]](i32 %a)
// UNIQUE: distinct !DIGlobalVariable(name: "glob"{{.*}})
// UNIQUE: distinct !DISubprogram(name: "foo", linkageName: "_ZL3foov.[[MODHASH]]"{{.*}})
+// UNIQUE: distinct !DISubprogram(name: "go", linkageName: "_ZL2goi.[[MODHASH]]"{{.*}})
Index: clang/lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- clang/lib/CodeGen/CGDebugInfo.cpp
+++ clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3522,7 +3522,7 @@
llvm::DIScope *&FDContext,
llvm::DINodeArray &TParamsArray,
llvm::DINode::DIFlags &Flags) {
- const auto *FD = cast<FunctionDecl>(GD.getDecl());
+ const auto *FD = cast<FunctionDecl>(GD.getCanonicalDecl().getDecl());
Name = getFunctionName(FD);
// Use mangled name as linkage name for C/C++ functions.
if (FD->hasPrototype()) {
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -640,7 +640,7 @@
// For C functions without prototypes, return false as their
// names should not be mangled.
- if (!FD->getType()->getAs<FunctionProtoType>())
+ if (!FD->hasPrototype())
return false;
if (isInternalLinkageDecl(ND))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98799.331762.patch
Type: text/x-patch
Size: 3041 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210319/2ac120ce/attachment.bin>
More information about the cfe-commits
mailing list