Skip to content

Commit bac5a64

Browse files
Merge pull request #28831 from aschwaighofer/irgen_remove_asSizeConstant
IRGen: Replace local utility function by existing function on IRGenModule
2 parents 54d67d9 + 729609b commit bac5a64

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/IRGen/GenType.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -198,23 +198,19 @@ void LoadableTypeInfo::addScalarToAggLowering(IRGenModule &IGM,
198198
offset.asCharUnits() + storageSize.asCharUnits());
199199
}
200200

201-
static llvm::Constant *asSizeConstant(IRGenModule &IGM, Size size) {
202-
return llvm::ConstantInt::get(IGM.SizeTy, size.getValue());
203-
}
204-
205201
llvm::Value *FixedTypeInfo::getSize(IRGenFunction &IGF, SILType T) const {
206202
return FixedTypeInfo::getStaticSize(IGF.IGM);
207203
}
208204
llvm::Constant *FixedTypeInfo::getStaticSize(IRGenModule &IGM) const {
209-
return asSizeConstant(IGM, getFixedSize());
205+
return IGM.getSize(getFixedSize());
210206
}
211207

212208
llvm::Value *FixedTypeInfo::getAlignmentMask(IRGenFunction &IGF,
213209
SILType T) const {
214210
return FixedTypeInfo::getStaticAlignmentMask(IGF.IGM);
215211
}
216212
llvm::Constant *FixedTypeInfo::getStaticAlignmentMask(IRGenModule &IGM) const {
217-
return asSizeConstant(IGM, Size(getFixedAlignment().getValue() - 1));
213+
return IGM.getSize(Size(getFixedAlignment().getValue() - 1));
218214
}
219215

220216
llvm::Value *FixedTypeInfo::getStride(IRGenFunction &IGF, SILType T) const {
@@ -229,7 +225,7 @@ llvm::Value *FixedTypeInfo::getIsBitwiseTakable(IRGenFunction &IGF, SILType T) c
229225
isBitwiseTakable(ResilienceExpansion::Maximal) == IsBitwiseTakable);
230226
}
231227
llvm::Constant *FixedTypeInfo::getStaticStride(IRGenModule &IGM) const {
232-
return asSizeConstant(IGM, getFixedStride());
228+
return IGM.getSize(getFixedStride());
233229
}
234230

235231
llvm::Value *FixedTypeInfo::isDynamicallyPackedInline(IRGenFunction &IGF,
@@ -399,7 +395,7 @@ static llvm::Value *computeExtraTagBytes(IRGenFunction &IGF, IRBuilder &Builder,
399395
}
400396

401397
auto *entryBB = Builder.GetInsertBlock();
402-
llvm::Value *size = asSizeConstant(IGM, fixedSize);
398+
llvm::Value *size = IGM.getSize(fixedSize);
403399
auto *returnBB = llvm::BasicBlock::Create(Ctx);
404400
size = Builder.CreateZExtOrTrunc(size, int32Ty); // We know size < 4.
405401

0 commit comments

Comments
 (0)