Skip to content

Commit 9526384

Browse files
committed
[IRGen] NFC: Narrow the scope of some code
This code is only used on one side of a if/else branch, so let's just move it inside the `else` block.
1 parent 5013a02 commit 9526384

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/IRGen/GenClass.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -813,24 +813,24 @@ llvm::Value *irgen::emitClassAllocation(IRGenFunction &IGF, SILType selfType,
813813
auto &classLayout = classTI.getClassLayout(IGF.IGM, selfType,
814814
/*forBackwardDeployment=*/false);
815815

816-
llvm::Value *size, *alignMask;
817-
if (classLayout.isFixedSize()) {
818-
size = IGF.IGM.getSize(classLayout.getSize());
819-
alignMask = IGF.IGM.getSize(classLayout.getAlignMask());
820-
} else {
821-
std::tie(size, alignMask)
822-
= emitClassResilientInstanceSizeAndAlignMask(IGF,
823-
selfType.getClassOrBoundGenericClass(),
824-
metadata);
825-
}
826-
827816
llvm::Type *destType = classLayout.getType()->getPointerTo();
828817
llvm::Value *val = nullptr;
829818
if (llvm::Value *Promoted = stackPromote(IGF, classLayout, StackAllocSize,
830819
TailArrays)) {
831820
val = IGF.Builder.CreateBitCast(Promoted, IGF.IGM.RefCountedPtrTy);
832821
val = IGF.emitInitStackObjectCall(metadata, val, "reference.new");
833822
} else {
823+
llvm::Value *size, *alignMask;
824+
if (classLayout.isFixedSize()) {
825+
size = IGF.IGM.getSize(classLayout.getSize());
826+
alignMask = IGF.IGM.getSize(classLayout.getAlignMask());
827+
} else {
828+
std::tie(size, alignMask)
829+
= emitClassResilientInstanceSizeAndAlignMask(IGF,
830+
selfType.getClassOrBoundGenericClass(),
831+
metadata);
832+
}
833+
834834
// Allocate the object on the heap.
835835
std::tie(size, alignMask)
836836
= appendSizeForTailAllocatedArrays(IGF, size, alignMask, TailArrays);

0 commit comments

Comments
 (0)