Skip to content

Commit c19478a

Browse files
committed
IRGen: Offset::offsetBy() should take an Offset and a Size
1 parent 0fa7440 commit c19478a

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

lib/IRGen/IRGen.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ class Offset {
484484
}
485485

486486
llvm::Value *getAsValue(IRGenFunction &IGF) const;
487-
Offset offsetBy(IRGenFunction &IGF, Offset other) const;
487+
Offset offsetBy(IRGenFunction &IGF, Size other) const;
488488
};
489489

490490
} // end namespace irgen

lib/IRGen/IRGenFunction.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,12 @@ llvm::Value *Offset::getAsValue(IRGenFunction &IGF) const {
394394
}
395395
}
396396

397-
Offset Offset::offsetBy(IRGenFunction &IGF, Offset other) const {
398-
if (isStatic() && other.isStatic()) {
399-
return Offset(getStatic() + other.getStatic());
397+
Offset Offset::offsetBy(IRGenFunction &IGF, Size other) const {
398+
if (isStatic()) {
399+
return Offset(getStatic() + other);
400400
}
401-
return Offset(IGF.Builder.CreateAdd(getDynamic(), other.getDynamic()));
401+
auto otherVal = llvm::ConstantInt::get(IGF.IGM.SizeTy, other.getValue());
402+
return Offset(IGF.Builder.CreateAdd(getDynamic(), otherVal));
402403
}
403404

404405
Address IRGenFunction::emitAddressAtOffset(llvm::Value *base, Offset offset,

lib/IRGen/MetadataLayout.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static llvm::Value *emitLoadOfGenericRequirement(IRGenFunction &IGF,
147147
llvm::Type *reqtTy) {
148148
auto offset =
149149
IGF.IGM.getMetadataLayout(decl).getGenericRequirementsOffset(IGF);
150-
offset = offset.offsetBy(IGF, Offset(reqtIndex * IGF.IGM.getPointerSize()));
150+
offset = offset.offsetBy(IGF, Size(reqtIndex * IGF.IGM.getPointerSize()));
151151

152152
auto slot = IGF.emitAddressAtOffset(metadata, offset, reqtTy,
153153
IGF.IGM.getPointerAlignment());

0 commit comments

Comments
 (0)