From 55eac64914e5cf08662c39dae1bd179c747cc630 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Thu, 25 Feb 2021 16:51:31 +0100 Subject: [PATCH] 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 --- lib/Transforms/IPO/WholeProgramDevirt.cpp | 2 +- lib/Transforms/Utils/ModuleUtils.cpp | 2 +- .../AddressSanitizer/global_with_comdat.ll | 12 ++++++------ test/ThinLTO/X86/devirt.ll | 2 +- test/ThinLTO/X86/devirt2.ll | 8 ++++---- .../ThinLTOBitcodeWriter/split-internal-typeid.ll | 10 +++++----- .../ThinLTOBitcodeWriter/split-internal1.ll | 6 +++--- .../ThinLTOBitcodeWriter/split-internal2.ll | 6 +++--- .../ThinLTOBitcodeWriter/split-vfunc-internal.ll | 8 ++++---- .../WholeProgramDevirt/export-single-impl.ll | 12 ++++++------ tools/llvm-lto2/llvm-lto2.cpp | 6 +++--- 11 files changed, 37 insertions(+), 37 deletions(-) diff --git a/lib/Transforms/IPO/WholeProgramDevirt.cpp b/lib/Transforms/IPO/WholeProgramDevirt.cpp index 14214562f03..6fe3116f6fc 100644 --- a/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/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/lib/Transforms/Utils/ModuleUtils.cpp b/lib/Transforms/Utils/ModuleUtils.cpp index f7bd8f0d500..74d3239847f 100644 --- a/lib/Transforms/Utils/ModuleUtils.cpp +++ b/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/test/Instrumentation/AddressSanitizer/global_with_comdat.ll b/test/Instrumentation/AddressSanitizer/global_with_comdat.ll index e7df431ca24..4559f172b92 100644 --- a/test/Instrumentation/AddressSanitizer/global_with_comdat.ll +++ b/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/test/ThinLTO/X86/devirt.ll b/test/ThinLTO/X86/devirt.ll index 0a389f3ee63..66adec0bece 100644 --- a/test/ThinLTO/X86/devirt.ll +++ b/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/test/ThinLTO/X86/devirt2.ll b/test/ThinLTO/X86/devirt2.ll index 71b36552353..42c15f1c1df 100644 --- a/test/ThinLTO/X86/devirt2.ll +++ b/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/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll b/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll index 290df00fa9e..481910025e7 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/split-internal-typeid.ll +++ b/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/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll b/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll index 42a06bdf2bf..717c10e8c4c 100644 --- a/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll +++ b/test/Transforms/ThinLTOBitcodeWriter/split-internal1.ll @@ -12,14 +12,14 @@ ; BCA0: