Skip to content

Commit e48c0c0

Browse files
authored
Merge pull request swiftlang#12797 from anemet/opt-remark-demangle
2 parents 9a6d650 + 65b24eb commit e48c0c0

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

lib/SIL/OptimizationRemark.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "swift/SIL/OptimizationRemark.h"
2020
#include "swift/AST/DiagnosticEngine.h"
2121
#include "swift/AST/DiagnosticsSIL.h"
22+
#include "swift/Demangling/Demangler.h"
2223
#include "llvm/ADT/StringExtras.h"
2324
#include "llvm/Support/YAMLTraits.h"
2425
#include "llvm/Support/raw_ostream.h"
@@ -43,7 +44,13 @@ Argument::Argument(StringRef Key, unsigned long long N)
4344
: Key(Key), Val(llvm::utostr(N)) {}
4445

4546
Argument::Argument(StringRef Key, SILFunction *F)
46-
: Key(Key), Val(F->getName()) {
47+
: Key(Key),
48+
Val((Twine("\"") +
49+
Demangle::demangleSymbolAsString(
50+
F->getName(),
51+
Demangle::DemangleOptions::SimplifiedUIDemangleOptions()) +
52+
"\"")
53+
.str()) {
4754
if (F->hasLocation())
4855
Loc = F->getLocation().getSourceLoc();
4956
}
@@ -110,7 +117,9 @@ template <typename KindT> struct MappingTraits<Remark<KindT>> {
110117
if (!io.outputting() || Loc.isValid())
111118
io.mapOptional("DebugLoc", Loc);
112119

113-
StringRef FN = R.getFunction()->getName();
120+
std::string FN = Demangle::demangleSymbolAsString(
121+
R.getFunction()->getName(),
122+
Demangle::DemangleOptions::SimplifiedUIDemangleOptions());
114123
io.mapRequired("Function", FN);
115124
io.mapOptional("Args", R.getArgs());
116125
}

test/Driver/opt-record.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ public func bar() {
2020
// YAML-NEXT: File: {{.*}}opt-record.swift
2121
// YAML-NEXT: Line: 42
2222
// YAML-NEXT: Column: 3
23-
// YAML-NEXT: Function: _T012optrecordmod3baryyF
23+
// YAML-NEXT: Function: 'bar()'
2424
// YAML-NEXT: Args:
25-
// YAML-NEXT: - Callee: _T012optrecordmod3fooyyF
25+
// YAML-NEXT: - Callee: '"foo()"'
2626
// YAML-NEXT: DebugLoc:
2727
// YAML-NEXT: File: {{.*}}opt-record.swift
2828
// YAML-NEXT: Line: 11
2929
// YAML-NEXT: Column: 6
3030
// YAML-NEXT: - String: ' inlined into '
31-
// YAML-NEXT: - Caller: _T012optrecordmod3baryyF
31+
// YAML-NEXT: - Caller: '"bar()"'
3232
// YAML-NEXT: DebugLoc:
3333
// YAML-NEXT: File: {{.*}}opt-record.swift
3434
// YAML-NEXT: Line: 15

test/Driver/opt-remark.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func foo() {
4242
// REMARK_MISSED-NOT: remark: {{.*}} inlined
4343
big()
4444
// REMARK_PASSED-NOT: remark: Not profitable
45-
// REMARK_PASSED: opt-remark.swift:47:3: remark: _T04null5smallyyF inlined into _T04null3fooyyF (cost = {{.*}}, benefit = {{.*}})
45+
// REMARK_PASSED: opt-remark.swift:47:3: remark: "small()" inlined into "foo()" (cost = {{.*}}, benefit = {{.*}})
4646
// REMARK_PASSED-NOT: remark: Not profitable
4747
small()
4848
}

test/SILOptimizer/inliner_coldblocks.sil

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ bb0:
193193
%c30 = builtin "assert_configuration"() : $Builtin.Int32
194194

195195
%f = function_ref @update_global: $@convention(thin) () -> ()
196-
// REMARKS_PASSED: inliner_coldblocks.sil:223:3: remark: update_global inlined into regular_large_callee (cost = {{.*}}, benefit = {{.*}})
196+
// REMARKS_PASSED: inliner_coldblocks.sil:223:3: remark: "update_global" inlined into "regular_large_callee" (cost = {{.*}}, benefit = {{.*}})
197197
// YAML: --- !Passed
198198
// YAML-NEXT: Pass: sil-inliner
199199
// YAML-NEXT: Name: Inlined
@@ -203,13 +203,13 @@ bb0:
203203
// YAML-NEXT: Column: 3
204204
// YAML-NEXT: Function: regular_large_callee
205205
// YAML-NEXT: Args:
206-
// YAML-NEXT: - Callee: update_global
206+
// YAML-NEXT: - Callee: '"update_global"'
207207
// YAML-NEXT: DebugLoc:
208208
// YAML-NEXT: File: {{.*}}inliner_coldblocks.sil
209209
// YAML-NEXT: Line: 20
210210
// YAML-NEXT: Column: 6
211211
// YAML-NEXT: - String: ' inlined into '
212-
// YAML-NEXT: - Caller: regular_large_callee
212+
// YAML-NEXT: - Caller: '"regular_large_callee"'
213213
// YAML-NEXT: DebugLoc:
214214
// YAML-NEXT: File: {{.*}}inliner_coldblocks.sil
215215
// YAML-NEXT: Line: 162

0 commit comments

Comments
 (0)