Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/SIL/Utils/GenericSpecializationMangler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,10 @@ std::string SpecializationMangler::finalize() {
StringRef FuncName = Function ? Function->getName() : StringRef(FunctionName);
NodePointer FuncTopLevel = nullptr;
if (FuncName.starts_with(MANGLING_PREFIX_STR)) {
// Demangling can fail, i.e. FuncTopLevel == nullptr, if the user provides
// a custom not-demangable `@_silgen_name` (but still containing the "$s"
// mangling prefix).
FuncTopLevel = D.demangleSymbol(FuncName);
assert(FuncTopLevel);
}
else if (FuncName.starts_with(MANGLING_PREFIX_EMBEDDED_STR)) {
FuncTopLevel = D.demangleSymbol(FuncName);
Expand Down
19 changes: 19 additions & 0 deletions test/SILOptimizer/specialize_ossa.sil
Original file line number Diff line number Diff line change
Expand Up @@ -1665,3 +1665,22 @@ bb0(%0 : $Int):
dealloc_stack %1
return %11
}


sil hidden [ossa] @$s_custom_not_demangable_name : $@convention(thin) <T> (@thick T.Type) -> () {
bb0(%0 : $@thick T.Type):
%8 = tuple ()
return %8 : $()
}

// CHECK-LABEL: sil [ossa] @call_custom_name :
// CHECK: function_ref @$s29$s_custom_not_demangable_nameSi_Ttg5 : $@convention(thin) () -> ()
// CHECK: } // end sil function 'call_custom_name'
sil [ossa] @call_custom_name : $@convention(thin) () -> () {
bb0:
%2 = function_ref @$s_custom_not_demangable_name : $@convention(thin) <τ_0_0> (@thick τ_0_0.Type) -> ()
%3 = metatype $@thick Int.Type
%4 = apply %2<Int>(%3) : $@convention(thin) <τ_0_0> (@thick τ_0_0.Type) -> ()
%5 = tuple ()
return %5 : $()
}