[PATCH] D93747: Rename debug linkage name with -funique-internal-linkage-names
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 23 13:20:08 PST 2020
hoy updated this revision to Diff 313607.
hoy added a comment.
Undoing changes to the clang test.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93747/new/
https://reviews.llvm.org/D93747
Files:
llvm/include/llvm/IR/DebugInfoMetadata.h
llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll
Index: llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll
===================================================================
--- llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll
+++ llvm/test/Transforms/UniqueLinkageNames/unique-internal-linkage-names.ll
@@ -32,5 +32,6 @@
!17 = !{!13}
!18 = !DILocation(line: 6, column: 3, scope: !15)
-; CHECK: define internal i32 @foo.__uniq.{{[0-9a-f]+}}()
+; CHECK: define internal i32 @foo.__uniq.{{[0-9a-f]+}}() !dbg ![[#DBG:]]
; CHECK: ret {{.*}} @foo.__uniq.{{[0-9a-f]+}} {{.*}}
+; CHECK: ![[#DBG]] = distinct !DISubprogram(name: "foo", linkageName: "foo.__uniq.{{[0-9a-f]+}}"
Index: llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
===================================================================
--- llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
+++ llvm/lib/Transforms/Utils/UniqueInternalLinkageNames.cpp
@@ -13,6 +13,8 @@
#include "llvm/Transforms/Utils/UniqueInternalLinkageNames.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/IR/DebugInfoMetadata.h"
+#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/Module.h"
#include "llvm/InitializePasses.h"
#include "llvm/Support/MD5.h"
@@ -31,11 +33,16 @@
// this symbol is of internal linkage type.
std::string ModuleNameHash = (Twine(".__uniq.") + Twine(Str)).str();
bool Changed = false;
+ MDBuilder MDB(M.getContext());
// Append the module hash to all internal linkage functions.
for (auto &F : M) {
if (F.hasInternalLinkage()) {
F.setName(F.getName() + ModuleNameHash);
+ if (DISubprogram *SP = F.getSubprogram()) {
+ auto *Name = MDB.createString(F.getName());
+ SP->replaceRawLinkageName(Name);
+ }
Changed = true;
}
}
Index: llvm/include/llvm/IR/DebugInfoMetadata.h
===================================================================
--- llvm/include/llvm/IR/DebugInfoMetadata.h
+++ llvm/include/llvm/IR/DebugInfoMetadata.h
@@ -2053,6 +2053,10 @@
return getNumOperands() > 10 ? getOperandAs<Metadata>(10) : nullptr;
}
+ void replaceRawLinkageName(MDString *LinkageName) {
+ replaceOperandWith(3, LinkageName);
+ }
+
/// Check if this subprogram describes the given function.
///
/// FIXME: Should this be looking through bitcasts?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93747.313607.patch
Type: text/x-patch
Size: 2308 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201223/0abcc5c3/attachment.bin>
More information about the llvm-commits
mailing list