Skip to content

Commit 53a6d89

Browse files
committed
More fixes for pre-specializations
Since the bodies of pre-specializaitons are not serialized, do not use the `[serialized]` attribute for them.
1 parent 9134153 commit 53a6d89

File tree

5 files changed

+11
-10
lines changed

5 files changed

+11
-10
lines changed

lib/SILOptimizer/IPO/DeadFunctionElimination.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class FunctionLivenessComputation {
113113
// a pipeline, as it may break some optimizations.
114114
if (F->isKeepAsPublic()) {
115115
F->setLinkage(SILLinkage::Public);
116-
F->setSerialized(IsSerialized);
117116
DEBUG(llvm::dbgs() << "DFE: Preserve the specialization "
118117
<< F->getName() << '\n');
119118
return true;

lib/SILOptimizer/IPO/UsePrespecialized.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,10 @@ bool UsePrespecialized::replaceByPrespecialized(SILFunction &F) {
9999
if (SpecType->hasArchetype())
100100
continue;
101101

102-
// Create a name of the specialization.
102+
// Create a name of the specialization. All external pre-specializations
103+
// are serialized without bodies. Thus use IsNotSerialized here.
103104
Mangle::GenericSpecializationMangler NewGenericMangler(ReferencedF,
104-
Subs, ReferencedF->isSerialized(),
105+
Subs, IsNotSerialized,
105106
/*isReAbstracted*/ true);
106107
std::string ClonedName = NewGenericMangler.mangle();
107108

lib/SILOptimizer/Utils/Generics.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,11 +2274,12 @@ void swift::trySpecializeApplyOfGeneric(
22742274
if (F->isSerialized() && RefF->isSerialized())
22752275
Serialized = IsSerializable;
22762276

2277-
// If it is OnoneSupport consider all specializations as serialized.
2277+
// If it is OnoneSupport consider all specializations as non-serialized
2278+
// as we do not SIL serialize their bodies.
22782279
// It is important to set this flag here, because it affects the
22792280
// mangling of the specialization's name.
22802281
if (Apply.getModule().isOptimizedOnoneSupportModule())
2281-
Serialized = IsSerialized;
2282+
Serialized = IsNotSerialized;
22822283

22832284
ReabstractionInfo ReInfo(Apply, RefF, Apply.getSubstitutions());
22842285
if (!ReInfo.canBeSpecialized())

test/SILOptimizer/eager_specialize.sil

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ bb0(%0 : $*T):
581581

582582
// Check that a public specialization for Int64 was produced.
583583
// specialized exportSpecializations<A> (A) -> ()
584-
// CHECK-DEADFUNCELIM-LABEL: sil [serialized] @_T016eager_specialize21exportSpecializationsyxlFs5Int64V_Tg5 : $@convention(thin) (Int64) -> ()
584+
// CHECK-DEADFUNCELIM-LABEL: sil @_T016eager_specialize21exportSpecializationsyxlFs5Int64V_Tg5 : $@convention(thin) (Int64) -> ()
585585

586586
////////////////////////////////////////////////////////////////////
587587
// Check the ability to produce explicit partial specializations.

test/SILOptimizer/prespecialize.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@
1111
// CHECK-LABEL: sil [noinline] @_T013prespecialize4testySaySiGz_Si4sizetF
1212
//
1313
// function_ref specialized Collection<A where ...>.makeIterator() -> IndexingIterator<A>
14-
// CHECK: function_ref @_T0s10CollectionPssAARzs16IndexingIteratorVyxG0C0RtzlE04makeC0AEyFs14CountableRangeVySiG_Tgq5
14+
// CHECK: function_ref @_T0s10CollectionPssAARzs16IndexingIteratorVyxG0C0RtzlE04makeC0AEyFs14CountableRangeVySiG_Tg5
1515
//
1616
// function_ref specialized IndexingIterator.next() -> A.Element?
17-
// CHECK: function_ref @_T0s16IndexingIteratorV4next7ElementQzSgyFs14CountableRangeVySiG_Tgq5
17+
// CHECK: function_ref @_T0s16IndexingIteratorV4next7ElementQzSgyFs14CountableRangeVySiG_Tg5
1818
//
1919
// Look for generic specialization <Swift.Int> of Swift.Array.subscript.getter : (Swift.Int) -> A
20-
// CHECK: function_ref {{@_T0SaxSicigSi_Tgq5|@_TTSg5Si___TFSaap9subscriptFSix}}
20+
// CHECK: function_ref {{@_T0SaxSicigSi_Tg5|@_TTSg5Si___TFSaap9subscriptFSix}}
2121
// CHECK: return
2222
@inline(never)
2323
public func test(_ a: inout [Int], size: Int) {
@@ -30,7 +30,7 @@ public func test(_ a: inout [Int], size: Int) {
3030

3131
// CHECK-LABEL: sil [noinline] @_T013prespecialize3runyyF
3232
// Look for generic specialization <Swift.Int> of Swift.Array.init (repeating : A, count : Swift.Int) -> Swift.Array<A>
33-
// CHECK: function_ref @_T0S2ayxGx9repeating_Si5counttcfCSi_Tgq5
33+
// CHECK: function_ref @_T0S2ayxGx9repeating_Si5counttcfCSi_Tg5
3434
// CHECK: return
3535
@inline(never)
3636
public func run() {

0 commit comments

Comments
 (0)