Merge pull request #42553 from aschwaighofer/irgen_metadata_instantiation_readonly_willreturn

IRGen: Set `readonly` and `willreturn` on meta data instantiation functions
This commit is contained in:
Arnold Schwaighofer
2022-04-22 07:54:09 -07:00
committed by GitHub
4 changed files with 12 additions and 9 deletions

View File

@@ -2276,7 +2276,8 @@ MetadataResponse irgen::emitGenericTypeMetadataAccessFunction(
// materialize the nominal type descriptor and call this thunk.
auto generateThunkFn = [&IGM,
checkPrespecialized](IRGenFunction &subIGF) {
subIGF.CurFn->setDoesNotAccessMemory();
subIGF.CurFn->setOnlyReadsMemory();
subIGF.CurFn->setWillReturn();
subIGF.CurFn->setCallingConv(IGM.SwiftCC);
IGM.setHasNoFramePointer(subIGF.CurFn);
@@ -2857,7 +2858,8 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,
? "__swift_instantiateConcreteTypeFromMangledNameAbstract"
: "__swift_instantiateConcreteTypeFromMangledName";
auto generateInstantiationFn = [&IGM, request](IRGenFunction &subIGF) {
subIGF.CurFn->setDoesNotAccessMemory();
subIGF.CurFn->setOnlyReadsMemory();
subIGF.CurFn->setWillReturn();
IGM.setHasNoFramePointer(subIGF.CurFn);
auto params = subIGF.collectParameters();
@@ -2960,7 +2962,7 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,
llvm::ConstantPointerNull::get(IGM.Int8PtrPtrTy)});
}
call->setDoesNotThrow();
call->setDoesNotAccessMemory();
call->setOnlyReadsMemory();
call->setCallingConv(IGM.SwiftCC);
// Store the result back to the cache. Metadata instantiation should
@@ -2995,7 +2997,7 @@ emitMetadataAccessByMangledName(IRGenFunction &IGF, CanType type,
auto call = IGF.Builder.CreateCall(instantiationFn, cache);
call->setDoesNotThrow();
call->setDoesNotAccessMemory();
call->setOnlyReadsMemory();
auto response = MetadataResponse::forComplete(call);