@@ -841,76 +841,6 @@ llvm::Value *irgen::emitClassAllocationDynamic(IRGenFunction &IGF,
841
841
return IGF.Builder .CreateBitCast (val, destType);
842
842
}
843
843
844
- // / Look for the instance method:
845
- // / func __getInstanceSizeAndAlignMask() -> (Int, Int)
846
- // / and use it to populate 'size' and 'alignMask' if it's present.
847
- static bool getInstanceSizeByMethod (IRGenFunction &IGF,
848
- CanType selfType,
849
- ClassDecl *selfClass,
850
- llvm::Value *selfValue,
851
- llvm::Value *&size,
852
- llvm::Value *&alignMask) {
853
- // Look for a single instance method with the magic name.
854
- FuncDecl *fn; {
855
- auto name = IGF.IGM .Context .getIdentifier (" __getInstanceSizeAndAlignMask" );
856
- SmallVector<ValueDecl*, 4 > results;
857
- selfClass->lookupQualified (selfClass, name,
858
- NL_KnownNonCascadingDependency, results);
859
- if (results.size () != 1 )
860
- return false ;
861
- fn = dyn_cast<FuncDecl>(results[0 ]);
862
- if (!fn)
863
- return false ;
864
- }
865
-
866
- // Check whether the SIL module defines it. (We need a type for it.)
867
- SILDeclRef fnRef (fn, SILDeclRef::Kind::Func);
868
- SILFunction *silFn = IGF.getSILModule ().lookUpFunction (fnRef);
869
- if (!silFn)
870
- return false ;
871
-
872
- // Check that it returns two size_t's and takes no other arguments.
873
- auto fnType = silFn->getLoweredFunctionType ();
874
- auto fnConv = silFn->getConventions ();
875
- if (fnType->getParameters ().size () != 1 )
876
- return false ;
877
- if (fnConv.getNumDirectSILResults () != 2
878
- || fnConv.getNumIndirectSILResults () != 0 )
879
- return false ;
880
- if ((fnConv.getDirectSILResults ().begin ()->getConvention ()
881
- != ResultConvention::Unowned)
882
- || (std::next (fnConv.getDirectSILResults ().begin ())->getConvention ()
883
- != ResultConvention::Unowned))
884
- return false ;
885
- llvm::Function *llvmFn =
886
- IGF.IGM .getAddrOfSILFunction (silFn, NotForDefinition);
887
- auto llvmFnTy = llvmFn->getFunctionType ();
888
- if (llvmFnTy->getNumParams () != 1 ) return false ;
889
- auto returnType = dyn_cast<llvm::StructType>(llvmFnTy->getReturnType ());
890
- if (!returnType ||
891
- returnType->getNumElements () != 2 ||
892
- returnType->getElementType (0 ) != IGF.IGM .SizeTy ||
893
- returnType->getElementType (1 ) != IGF.IGM .SizeTy )
894
- return false ;
895
-
896
- // Retain 'self' if necessary.
897
- if (fnType->getParameters ()[0 ].isConsumed ()) {
898
- IGF.emitNativeStrongRetain (selfValue, IGF.getDefaultAtomicity ());
899
- }
900
-
901
- // Adjust down to the defining subclass type if necessary.
902
- selfValue = IGF.Builder .CreateBitCast (selfValue, llvmFnTy->getParamType (0 ));
903
-
904
- // Emit a direct call.
905
- auto result = IGF.Builder .CreateCall (llvmFn, selfValue);
906
- result->setCallingConv (llvmFn->getCallingConv ());
907
-
908
- // Extract the size and alignment.
909
- size = IGF.Builder .CreateExtractValue (result, 0 , " size" );
910
- alignMask = IGF.Builder .CreateExtractValue (result, 1 , " alignMask" );
911
- return true ;
912
- }
913
-
914
844
// / Get the instance size and alignment mask for the given class
915
845
// / instance.
916
846
static void getInstanceSizeAndAlignMask (IRGenFunction &IGF,
@@ -919,12 +849,6 @@ static void getInstanceSizeAndAlignMask(IRGenFunction &IGF,
919
849
llvm::Value *selfValue,
920
850
llvm::Value *&size,
921
851
llvm::Value *&alignMask) {
922
- // Use the magic __getInstanceSizeAndAlignMask method if we can
923
- // see a declaration of it
924
- if (getInstanceSizeByMethod (IGF, selfType.getASTType (),
925
- selfClass, selfValue, size, alignMask))
926
- return ;
927
-
928
852
// Try to determine the size of the object we're deallocating.
929
853
auto &info = IGF.IGM .getTypeInfo (selfType).as <ClassTypeInfo>();
930
854
auto &layout = info.getLayout (IGF.IGM , selfType);
0 commit comments