llvm::Constant *GcReadWeakFn;
/// GcAssignWeakFn -- LLVM objc_assign_weak function.
- llvm::Constant *GcAssignWeakFn;
+ llvm::Constant *getGcAssignWeakFn() {
+ // id objc_assign_weak (id, id *)
+ std::vector<const llvm::Type*> Args(1, ObjectPtrTy);
+ Args.push_back(ObjectPtrTy->getPointerTo());
+ llvm::FunctionType *FTy =
+ llvm::FunctionType::get(ObjectPtrTy, Args, false);
+ return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
+ }
/// GcAssignGlobalFn -- LLVM objc_assign_global function.
llvm::Constant *GcAssignGlobalFn;
}
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
- CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
+ CGF.Builder.CreateCall2(ObjCTypes.getGcAssignWeakFn(),
src, dst, "weakassign");
return;
}
FTy = Types.GetFunctionType(Types.getFunctionInfo(IdType, Params), false);
GcReadWeakFn = CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
- // id objc_assign_weak (id, id *)
+ // id objc_assign_global (id, id *)
Params.clear();
Params.push_back(IdType);
Params.push_back(Ctx.getPointerType(IdType));
FTy = Types.GetFunctionType(Types.getFunctionInfo(IdType, Params), false);
- GcAssignWeakFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
GcAssignGlobalFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
GcAssignIvarFn = CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
GcAssignStrongCastFn =
}
src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy);
dst = CGF.Builder.CreateBitCast(dst, ObjCTypes.PtrObjectPtrTy);
- CGF.Builder.CreateCall2(ObjCTypes.GcAssignWeakFn,
+ CGF.Builder.CreateCall2(ObjCTypes.getGcAssignWeakFn(),
src, dst, "weakassign");
return;
}