Skip to content

[IRGen] fix crashes emitting calls to get metadata from mangled name (16 bit architectures) #70957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion lib/IRGen/Linking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1017,7 +1017,11 @@ llvm::Type *LinkEntity::getDefaultDeclarationType(IRGenModule &IGM) const {
case Kind::NoncanonicalSpecializedGenericTypeMetadataCacheVariable:
return IGM.TypeMetadataPtrTy;
case Kind::TypeMetadataDemanglingCacheVariable:
return llvm::StructType::get(IGM.Int32Ty, IGM.Int32Ty);
if (IGM.getModule()->getDataLayout().isBigEndian()) {
return llvm::StructType::get(IGM.Int32Ty, IGM.RelativeAddressTy);
} else {
return llvm::StructType::get(IGM.RelativeAddressTy, IGM.Int32Ty);
}
case Kind::TypeMetadataSingletonInitializationCache:
// TODO: put a cache variable on IGM
return llvm::StructType::get(IGM.getLLVMContext(),
Expand Down
4 changes: 2 additions & 2 deletions lib/IRGen/MetadataRequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3209,8 +3209,8 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,

auto stringAddrOffset = subIGF.Builder.CreateTrunc(load,
IGM.Int32Ty);
stringAddrOffset = subIGF.Builder.CreateSExtOrBitCast(stringAddrOffset,
IGM.SizeTy);
stringAddrOffset = subIGF.Builder.CreateSExtOrTrunc(stringAddrOffset,
IGM.SizeTy);
auto stringAddrBase = subIGF.Builder.CreatePtrToInt(cache, IGM.SizeTy);
if (IGM.getModule()->getDataLayout().isBigEndian()) {
stringAddrBase = subIGF.Builder.CreateAdd(stringAddrBase,
Expand Down