Skip to content

Commit 1226315

Browse files
committed
IRGen: Remove some duplicate code
1 parent 2f86ad5 commit 1226315

File tree

2 files changed

+7
-76
lines changed

2 files changed

+7
-76
lines changed

lib/IRGen/GenEnum.cpp

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -279,62 +279,6 @@ EnumImplStrategy::emitResilientTagIndices(IRGenModule &IGM) const {
279279
}
280280
}
281281

282-
void EnumImplStrategy::callOutlinedCopy(IRGenFunction &IGF,
283-
Address dest, Address src, SILType T,
284-
IsInitialization_t isInit,
285-
IsTake_t isTake) const {
286-
if (!IGF.IGM.getOptions().UseTypeLayoutValueHandling) {
287-
OutliningMetadataCollector collector(IGF);
288-
if (T.hasArchetype()) {
289-
collectMetadataForOutlining(collector, T);
290-
}
291-
collector.emitCallToOutlinedCopy(dest, src, T, *TI, isInit, isTake);
292-
return;
293-
}
294-
295-
if (!T.hasArchetype()) {
296-
// Call the outlined copy function (the implementation will call vwt in this
297-
// case).
298-
OutliningMetadataCollector collector(IGF);
299-
collector.emitCallToOutlinedCopy(dest, src, T, *TI, isInit, isTake);
300-
return;
301-
}
302-
303-
if (isInit == IsInitialization && isTake == IsTake) {
304-
return emitInitializeWithTakeCall(IGF, T, dest, src);
305-
} else if (isInit == IsInitialization && isTake == IsNotTake) {
306-
return emitInitializeWithCopyCall(IGF, T, dest, src);
307-
} else if (isInit == IsNotInitialization && isTake == IsTake) {
308-
return emitAssignWithTakeCall(IGF, T, dest, src);
309-
} else if (isInit == IsNotInitialization && isTake == IsNotTake) {
310-
return emitAssignWithCopyCall(IGF, T, dest, src);
311-
}
312-
llvm_unreachable("unknown case");
313-
}
314-
315-
void EnumImplStrategy::callOutlinedDestroy(IRGenFunction &IGF,
316-
Address addr, SILType T) const {
317-
if (!IGF.IGM.getOptions().UseTypeLayoutValueHandling) {
318-
OutliningMetadataCollector collector(IGF);
319-
if (T.hasArchetype()) {
320-
collectMetadataForOutlining(collector, T);
321-
}
322-
collector.emitCallToOutlinedDestroy(addr, T, *TI);
323-
return;
324-
}
325-
326-
if (!T.hasArchetype()) {
327-
// Call the outlined copy function (the implementation will call vwt in this
328-
// case).
329-
OutliningMetadataCollector collector(IGF);
330-
collector.emitCallToOutlinedDestroy(addr, T, *TI);
331-
return;
332-
}
333-
334-
emitDestroyCall(IGF, T, addr);
335-
return;
336-
}
337-
338282
namespace {
339283
/// Implementation strategy for singleton enums, with zero or one cases.
340284
class SingletonEnumImplStrategy final : public EnumImplStrategy {
@@ -2854,24 +2798,7 @@ namespace {
28542798
}
28552799
}
28562800
} else {
2857-
if (!IGF.IGM.getOptions().UseTypeLayoutValueHandling) {
2858-
OutliningMetadataCollector collector(IGF);
2859-
if (T.hasArchetype()) {
2860-
collectMetadataForOutlining(collector, T);
2861-
}
2862-
collector.emitCallToOutlinedDestroy(addr, T, *TI);
2863-
return;
2864-
}
2865-
2866-
if (!T.hasArchetype()) {
2867-
// Call the outlined copy function (the implementation will call vwt
2868-
// in this case).
2869-
OutliningMetadataCollector collector(IGF);
2870-
collector.emitCallToOutlinedDestroy(addr, T, *TI);
2871-
return;
2872-
}
2873-
2874-
emitDestroyCall(IGF, T, addr);
2801+
callOutlinedDestroy(IGF, addr, T);
28752802
return;
28762803
}
28772804
}

lib/IRGen/GenEnum.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -449,9 +449,13 @@ class EnumImplStrategy {
449449

450450
void callOutlinedCopy(IRGenFunction &IGF, Address dest, Address src,
451451
SILType T, IsInitialization_t isInit,
452-
IsTake_t isTake) const;
452+
IsTake_t isTake) const {
453+
TI->callOutlinedCopy(IGF, dest, src, T, isInit, isTake);
454+
}
453455

454-
void callOutlinedDestroy(IRGenFunction &IGF, Address addr, SILType T) const;
456+
void callOutlinedDestroy(IRGenFunction &IGF, Address addr, SILType T) const {
457+
TI->callOutlinedDestroy(IGF, addr, T);
458+
}
455459

456460
virtual void collectMetadataForOutlining(OutliningMetadataCollector &collector,
457461
SILType T) const = 0;

0 commit comments

Comments
 (0)