[llvm] c6e5c46 - Don't use $ as suffix for symbol names in ThinLTOBitcodeWriter and other places
Hans Wennborg via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 29 04:16:52 PDT 2021
Author: Hans Wennborg
Date: 2021-03-29T13:03:52+02:00
New Revision: c6e5c4654bd5045fe22a1a52779e48e2038a404c
URL: https://github.com/llvm/llvm-project/commit/c6e5c4654bd5045fe22a1a52779e48e2038a404c
DIFF: https://github.com/llvm/llvm-project/commit/c6e5c4654bd5045fe22a1a52779e48e2038a404c.diff
LOG: Don't use $ as suffix for symbol names in ThinLTOBitcodeWriter and other places
Using $ breaks demangling of the symbols. For example,
$ c++filt _Z3foov\$123
_Z3foov$123
This causes problems for developers who would like to see nice stack traces
etc., but also for automatic crash tracking systems which try to organize
crashes based on the stack traces.
Instead, use the period as suffix separator, since Itanium demanglers normally
ignore such suffixes:
$ c++filt _Z3foov.123
foo() [clone .123]
This is already done in some places; try to do it everywhere.
Differential revision: https://reviews.llvm.org/D97484
Added:
Modified:
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/Utils/ModuleUtils.cpp
llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
llvm/test/ThinLTO/X86/devirt.ll
llvm/test/ThinLTO/X86/devirt2.ll
llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll
llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
llvm/tools/llvm-lto2/llvm-lto2.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
index 14214562f032..6fe3116f6fc6 100644
--- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -1153,7 +1153,7 @@ bool DevirtModule::trySingleImplDevirt(
// to make it visible to thin LTO objects. We can only get here during the
// ThinLTO export phase.
if (TheFn->hasLocalLinkage()) {
- std::string NewName = (TheFn->getName() + "$merged").str();
+ std::string NewName = (TheFn->getName() + ".llvm.merged").str();
// Since we are renaming the function, any comdats with the same name must
// also be renamed. This is required when targeting COFF, as the comdat name
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index f7bd8f0d500f..74d3239847f7 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -289,7 +289,7 @@ std::string llvm::getUniqueModuleId(Module *M) {
SmallString<32> Str;
MD5::stringifyResult(R, Str);
- return ("$" + Str).str();
+ return ("." + Str).str();
}
void VFABI::setVectorVariantNames(
diff --git a/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll b/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
index e7df431ca24a..4559f172b927 100644
--- a/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
+++ b/llvm/test/Instrumentation/AddressSanitizer/global_with_comdat.ll
@@ -25,18 +25,18 @@ target triple = "x86_64-unknown-linux-gnu"
; COMDAT: $global = comdat any
; COMDAT: $dyn_init_global = comdat any
-; COMDAT: $"_ZZ4funcvE10static_var${{[01-9a-f]+}}" = comdat any
-; COMDAT: $".str${{[01-9a-f]+}}" = comdat any
+; COMDAT: $_ZZ4funcvE10static_var.{{[01-9a-f]+}} = comdat any
+; COMDAT: $.str.{{[01-9a-f]+}} = comdat any
; NOCOMDAT-NOT: $global = comdat any
; NOCOMDAT-NOT: $dyn_init_global = comdat any
-; NOCOMDAT-NOT: $"_ZZ4funcvE10static_var${{[01-9a-f]+}}" = comdat any
-; NOCOMDAT-NOT: $".str${{[01-9a-f]+}}" = comdat any
+; NOCOMDAT-NOT: $_ZZ4funcvE10static_var.{{[01-9a-f]+}} = comdat any
+; NOCOMDAT-NOT: $.str.{{[01-9a-f]+}} = comdat any
; COMDAT: @global = global { i32, [60 x i8] } zeroinitializer, comdat, align 32
; COMDAT: @dyn_init_global = global { i32, [60 x i8] } zeroinitializer, comdat, align 32
-; COMDAT: @_ZZ4funcvE10static_var = internal global { i32, [60 x i8] } zeroinitializer, comdat($"_ZZ4funcvE10static_var${{[01-9a-f]+}}"), align 32
-; COMDAT: @.str = internal constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }, comdat($".str${{[01-9a-f]+}}"), align 32
+; COMDAT: @_ZZ4funcvE10static_var = internal global { i32, [60 x i8] } zeroinitializer, comdat($_ZZ4funcvE10static_var.{{[01-9a-f]+}}), align 32
+; COMDAT: @.str = internal constant { [14 x i8], [50 x i8] } { [14 x i8] c"Hello, world!\00", [50 x i8] zeroinitializer }, comdat($.str.{{[01-9a-f]+}}), align 32
; NOCOMDAT: @global = global { i32, [60 x i8] } zeroinitializer, align 32
; NOCOMDAT: @dyn_init_global = global { i32, [60 x i8] } zeroinitializer, align 32
diff --git a/llvm/test/ThinLTO/X86/devirt.ll b/llvm/test/ThinLTO/X86/devirt.ll
index 0a389f3ee638..66adec0becef 100644
--- a/llvm/test/ThinLTO/X86/devirt.ll
+++ b/llvm/test/ThinLTO/X86/devirt.ll
@@ -31,7 +31,7 @@
; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "_ZTS1B", summary: ((offset: 16, [[B]])))
; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "_ZTS1C", summary: ((offset: 16, [[C]])))
; Type Id on _ZTV1D should have been promoted
-; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "1${{.*}}", summary: ((offset: 16, [[D]])))
+; NOENABLESPLITFLAG-DAG: typeidCompatibleVTable: (name: "1.{{.*}}", summary: ((offset: 16, [[D]])))
; Legacy PM, Index based WPD
; RUN: llvm-lto2 run %t2.o -save-temps -pass-remarks=. \
diff --git a/llvm/test/ThinLTO/X86/devirt2.ll b/llvm/test/ThinLTO/X86/devirt2.ll
index 71b36552353f..42c15f1c1df5 100644
--- a/llvm/test/ThinLTO/X86/devirt2.ll
+++ b/llvm/test/ThinLTO/X86/devirt2.ll
@@ -190,12 +190,12 @@
; RUN: llvm-nm %t5.1 | FileCheck %s --check-prefix=NM-HYBRID1
; RUN: llvm-nm %t5.2 | FileCheck %s --check-prefix=NM-HYBRID2
-; NM-HYBRID1-DAG: U _ZN1A1nEi$
-; NM-HYBRID1-DAG: U _ZN1E1mEi$
+; NM-HYBRID1-DAG: U _ZN1A1nEi.{{[0-9a-f]*}}
+; NM-HYBRID1-DAG: U _ZN1E1mEi.{{[0-9a-f]*}}
; NM-HYBRID1-DAG: U _ZN1D1mEi
-; NM-HYBRID2-DAG: T _ZN1A1nEi$
-; NM-HYBRID2-DAG: T _ZN1E1mEi$
+; NM-HYBRID2-DAG: T _ZN1A1nEi.{{[0-9a-f]*}}
+; NM-HYBRID2-DAG: T _ZN1E1mEi.{{[0-9a-f]*}}
; NM-HYBRID2-DAG: W _ZN1D1mEi
; NM-HYBRID2-DAG: T _ZN1B1fEi
; NM-HYBRID2-DAG: T _ZN1C1fEi
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
index 290df00fa9eb..481910025e73 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll
@@ -19,9 +19,9 @@
; M0: define void @f()
; M1-NOT: @f()
define void @f() {
- ; M0: llvm.type.test{{.*}}metadata !"1$f50b51a12bb012bebbeff978335e34cf"
+ ; M0: llvm.type.test{{.*}}metadata !"1.f50b51a12bb012bebbeff978335e34cf"
%p = call i1 @llvm.type.test(i8* null, metadata !0)
- ; M0: llvm.type.checked.load{{.*}}metadata !"2$f50b51a12bb012bebbeff978335e34cf"
+ ; M0: llvm.type.checked.load{{.*}}metadata !"2.f50b51a12bb012bebbeff978335e34cf"
%q = call {i8*, i1} @llvm.type.checked.load(i8* null, i32 0, metadata !3)
ret void
}
@@ -30,11 +30,11 @@ declare i1 @llvm.type.test(i8*, metadata)
declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata)
!0 = distinct !{}
-; M1: !0 = !{i32 0, !"1$f50b51a12bb012bebbeff978335e34cf"}
+; M1: !0 = !{i32 0, !"1.f50b51a12bb012bebbeff978335e34cf"}
!1 = !{i32 0, !0}
-; M1: !1 = !{i32 1, !"1$f50b51a12bb012bebbeff978335e34cf"}
+; M1: !1 = !{i32 1, !"1.f50b51a12bb012bebbeff978335e34cf"}
!2 = !{i32 1, !0}
!3 = distinct !{}
-; M1: !2 = !{i32 0, !"2$f50b51a12bb012bebbeff978335e34cf"}
+; M1: !2 = !{i32 0, !"2.f50b51a12bb012bebbeff978335e34cf"}
!4 = !{i32 0, !3}
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll
index 42a06bdf2bf8..717c10e8c4cf 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll
@@ -12,14 +12,14 @@
; BCA0: <GLOBALVAL_SUMMARY_BLOCK
; BCA1-NOT: <GLOBALVAL_SUMMARY_BLOCK
-; M0: @"g$581d7631532fa146ba4061179da39272" = external hidden global i8{{$}}
-; M1: @"g$581d7631532fa146ba4061179da39272" = hidden global i8 42, !type !0
+; M0: @g.581d7631532fa146ba4061179da39272 = external hidden global i8{{$}}
+; M1: @g.581d7631532fa146ba4061179da39272 = hidden global i8 42, !type !0
@g = internal global i8 42, !type !0
; M0: define i8* @f()
; M1-NOT: @f()
define i8* @f() {
- ; M0: ret i8* @"g$581d7631532fa146ba4061179da39272"
+ ; M0: ret i8* @g.581d7631532fa146ba4061179da39272
ret i8* @g
}
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
index 02fc3d188509..98cc80e557f9 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-internal2.ll
@@ -13,11 +13,11 @@
; BCA1-NOT: <GLOBALVAL_SUMMARY_BLOCK
; M0: @g = external global void ()*{{$}}
-; M1: @g = global void ()* @"f$13757e0fb71915e385efa4dc9d1e08fd", !type !0
+; M1: @g = global void ()* @f.13757e0fb71915e385efa4dc9d1e08fd, !type !0
@g = global void ()* @f, !type !0
-; M0: define hidden void @"f$13757e0fb71915e385efa4dc9d1e08fd"()
-; M1: declare hidden void @"f$13757e0fb71915e385efa4dc9d1e08fd"()
+; M0: define hidden void @f.13757e0fb71915e385efa4dc9d1e08fd()
+; M1: declare hidden void @f.13757e0fb71915e385efa4dc9d1e08fd()
define internal void @f() {
call void @f2()
ret void
diff --git a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
index 7ebb30ae1aab..d17cbefb0fb1 100644
--- a/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
+++ b/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc-internal.ll
@@ -6,14 +6,14 @@ define [1 x i8*]* @source() {
ret [1 x i8*]* @g
}
-; M0: @"g$84f59439b469192440047efc8de357fb" = external hidden constant [1 x i8*]{{$}}
-; M1: @"g$84f59439b469192440047efc8de357fb" = hidden constant [1 x i8*] [i8* bitcast (i64 (i8*)* @"ok$84f59439b469192440047efc8de357fb" to i8*)]
+; M0: @g.84f59439b469192440047efc8de357fb = external hidden constant [1 x i8*]{{$}}
+; M1: @g.84f59439b469192440047efc8de357fb = hidden constant [1 x i8*] [i8* bitcast (i64 (i8*)* @ok.84f59439b469192440047efc8de357fb to i8*)]
@g = internal constant [1 x i8*] [
i8* bitcast (i64 (i8*)* @ok to i8*)
], !type !0
-; M0: define hidden i64 @"ok$84f59439b469192440047efc8de357fb"
-; M1: define available_externally hidden i64 @"ok$84f59439b469192440047efc8de357fb"
+; M0: define hidden i64 @ok.84f59439b469192440047efc8de357fb
+; M1: define available_externally hidden i64 @ok.84f59439b469192440047efc8de357fb
define internal i64 @ok(i8* %this) {
ret i64 42
}
diff --git a/llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll b/llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
index 861f5f658489..d1671ea785d1 100644
--- a/llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
+++ b/llvm/test/Transforms/WholeProgramDevirt/export-single-impl.ll
@@ -13,7 +13,7 @@
; SUMMARY-NEXT: WPDRes:
; SUMMARY-NEXT: 0:
; SUMMARY-NEXT: Kind: SingleImpl
-; SUMMARY-NEXT: SingleImplName: 'vf3$merged'
+; SUMMARY-NEXT: SingleImplName: vf3.llvm.merged
; SUMMARY-NEXT: ResByArg:
; SUMMARY-NEXT: typeid1:
; SUMMARY-NEXT: TTRes:
@@ -52,12 +52,12 @@
; SUMMARY-NEXT: WPDRes:
; SUMMARY-NEXT: 0:
; SUMMARY-NEXT: Kind: SingleImpl
-; SUMMARY-NEXT: SingleImplName: 'vf4$merged'
+; SUMMARY-NEXT: SingleImplName: vf4.llvm.merged
; SUMMARY-NEXT: ResByArg:
; SUMMARY-NEXT: WithGlobalValueDeadStripping: false
; SUMMARY-NEXT: ...
-; CHECK: $"vf4$merged" = comdat largest
+; CHECK: $vf4.llvm.merged = comdat largest
$vf4 = comdat largest
; CHECK: @vt1 = constant void (i8*)* @vf1
@@ -68,7 +68,7 @@ $vf4 = comdat largest
@vt3 = constant void (i8*)* @vf3, !type !2
-; CHECK: @vt4 = constant void (i8*)* @"vf4$merged", comdat($"vf4$merged")
+; CHECK: @vt4 = constant void (i8*)* @vf4.llvm.merged, comdat($vf4.llvm.merged)
@vt4 = constant void (i8*)* @vf4, comdat($vf4), !type !3
@vt5 = constant void (i8*)* @vf5, !type !4
@@ -81,12 +81,12 @@ define void @vf2(i8*) {
ret void
}
-; CHECK: define hidden void @"vf3$merged"(i8* %0) {
+; CHECK: define hidden void @vf3.llvm.merged(i8* %0) {
define internal void @vf3(i8*) {
ret void
}
-; CHECK: define hidden void @"vf4$merged"(i8* %0) comdat {
+; CHECK: define hidden void @vf4.llvm.merged(i8* %0) comdat {
define internal void @vf4(i8*) comdat {
ret void
}
diff --git a/llvm/tools/llvm-lto2/llvm-lto2.cpp b/llvm/tools/llvm-lto2/llvm-lto2.cpp
index ca4278fafb89..cedfd6f1194e 100644
--- a/llvm/tools/llvm-lto2/llvm-lto2.cpp
+++ b/llvm/tools/llvm-lto2/llvm-lto2.cpp
@@ -325,12 +325,12 @@ static int run(int argc, char **argv) {
std::vector<SymbolResolution> Res;
for (const InputFile::Symbol &Sym : Input->symbols()) {
auto I = CommandLineResolutions.find({F, std::string(Sym.getName())});
- // If it isn't found, look for "$", which would have been added
+ // If it isn't found, look for ".", which would have been added
// (followed by a hash) when the symbol was promoted during module
// splitting if it was defined in one part and used in the other.
- // Try looking up the symbol name before the "$".
+ // Try looking up the symbol name before the suffix.
if (I == CommandLineResolutions.end()) {
- auto SplitName = Sym.getName().rsplit("$");
+ auto SplitName = Sym.getName().rsplit(".");
I = CommandLineResolutions.find({F, std::string(SplitName.first)});
}
if (I == CommandLineResolutions.end()) {
More information about the llvm-commits
mailing list