@@ -63,7 +63,7 @@ private: |
| llvm::FunctionCallee getMessageSendFn() const { | | llvm::FunctionCallee getMessageSendFn() const { |
---|
| // Add the non-lazy-bind attribute, since objc_msgSend is likely to | | // Add the non-lazy-bind attribute, since objc_msgSend is likely to |
---|
| // be called a lot. | | // be called a lot. |
---|
| - llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy}; |
---|
| return CGM.CreateRuntimeFunction( | | return CGM.CreateRuntimeFunction( |
---|
| llvm::FunctionType::get(ObjectPtrTy, params, true), "objc_msgSend", | | llvm::FunctionType::get(ObjectPtrTy, params, true), "objc_msgSend", |
---|
| llvm::AttributeList::get(CGM.getLLVMContext(), | | llvm::AttributeList::get(CGM.getLLVMContext(), |
---|
@@ -77,10 +77,10 @@ private: |
| /// by indirect reference in the first argument, and therefore the | | /// by indirect reference in the first argument, and therefore the |
---|
| /// self and selector parameters are shifted over by one. | | /// self and selector parameters are shifted over by one. |
---|
| llvm::FunctionCallee getMessageSendStretFn() const { | | llvm::FunctionCallee getMessageSendStretFn() const { |
---|
| - llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.VoidTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(CGM.VoidTy, params, true), |
---|
| - "objc_msgSend_stret"); | | + "objc_msgSend_stret"); |
---|
| } | | } |
---|
| | | |
---|
| /// [double | long double] objc_msgSend_fpret(id self, SEL op, ...) | | /// [double | long double] objc_msgSend_fpret(id self, SEL op, ...) |
---|
@@ -89,10 +89,10 @@ private: |
| /// floating-point stack; without a special entrypoint, the nil case | | /// floating-point stack; without a special entrypoint, the nil case |
---|
| /// would be unbalanced. | | /// would be unbalanced. |
---|
| llvm::FunctionCallee getMessageSendFpretFn() const { | | llvm::FunctionCallee getMessageSendFpretFn() const { |
---|
| - llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(CGM.DoubleTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(CGM.DoubleTy, params, true), |
---|
| - "objc_msgSend_fpret"); | | + "objc_msgSend_fpret"); |
---|
| } | | } |
---|
| | | |
---|
| /// _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...) | | /// _Complex long double objc_msgSend_fp2ret(id self, SEL op, ...) |
---|
@@ -101,14 +101,14 @@ private: |
| /// x87 floating point stack; without a special entrypoint, the nil case | | /// x87 floating point stack; without a special entrypoint, the nil case |
---|
| /// would be unbalanced. Only used on 64-bit X86. | | /// would be unbalanced. Only used on 64-bit X86. |
---|
| llvm::FunctionCallee getMessageSendFp2retFn() const { | | llvm::FunctionCallee getMessageSendFp2retFn() const { |
---|
| - llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, SelectorPtrTy}; |
---|
| llvm::Type *longDoubleType = llvm::Type::getX86_FP80Ty(VMContext); | | llvm::Type *longDoubleType = llvm::Type::getX86_FP80Ty(VMContext); |
---|
| llvm::Type *resultType = | | llvm::Type *resultType = |
---|
| llvm::StructType::get(longDoubleType, longDoubleType); | | llvm::StructType::get(longDoubleType, longDoubleType); |
---|
| | | |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(resultType, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(resultType, params, true), |
---|
| - "objc_msgSend_fp2ret"); | | + "objc_msgSend_fp2ret"); |
---|
| } | | } |
---|
| | | |
---|
| /// id objc_msgSendSuper(struct objc_super *super, SEL op, ...) | | /// id objc_msgSendSuper(struct objc_super *super, SEL op, ...) |
---|
@@ -117,10 +117,10 @@ private: |
| /// semantics. The class passed is the superclass of the current | | /// semantics. The class passed is the superclass of the current |
---|
| /// class. | | /// class. |
---|
| llvm::FunctionCallee getMessageSendSuperFn() const { | | llvm::FunctionCallee getMessageSendSuperFn() const { |
---|
| - llvm::Type *params[] = { SuperPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {SuperPtrTy, SelectorPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSendSuper"); | | + "objc_msgSendSuper"); |
---|
| } | | } |
---|
| | | |
---|
| /// id objc_msgSendSuper2(struct objc_super *super, SEL op, ...) | | /// id objc_msgSendSuper2(struct objc_super *super, SEL op, ...) |
---|
@@ -128,10 +128,10 @@ private: |
| /// A slightly different messenger used for super calls. The class | | /// A slightly different messenger used for super calls. The class |
---|
| /// passed is the current class. | | /// passed is the current class. |
---|
| llvm::FunctionCallee getMessageSendSuperFn2() const { | | llvm::FunctionCallee getMessageSendSuperFn2() const { |
---|
| - llvm::Type *params[] = { SuperPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {SuperPtrTy, SelectorPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSendSuper2"); | | + "objc_msgSendSuper2"); |
---|
| } | | } |
---|
| | | |
---|
| /// void objc_msgSendSuper_stret(void *stretAddr, struct objc_super *super, | | /// void objc_msgSendSuper_stret(void *stretAddr, struct objc_super *super, |
---|
@@ -139,10 +139,10 @@ private: |
| /// | | /// |
---|
| /// The messenger used for super calls which return an aggregate indirectly. | | /// The messenger used for super calls which return an aggregate indirectly. |
---|
| llvm::FunctionCallee getMessageSendSuperStretFn() const { | | llvm::FunctionCallee getMessageSendSuperStretFn() const { |
---|
| - llvm::Type *params[] = { Int8PtrTy, SuperPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {Int8PtrTy, SuperPtrTy, SelectorPtrTy}; |
---|
| return CGM.CreateRuntimeFunction( | | return CGM.CreateRuntimeFunction( |
---|
| - llvm::FunctionType::get(CGM.VoidTy, params, true), | | + llvm::FunctionType::get(CGM.VoidTy, params, true), |
---|
| - "objc_msgSendSuper_stret"); | | + "objc_msgSendSuper_stret"); |
---|
| } | | } |
---|
| | | |
---|
| /// void objc_msgSendSuper2_stret(void * stretAddr, struct objc_super *super, | | /// void objc_msgSendSuper2_stret(void * stretAddr, struct objc_super *super, |
---|
@@ -150,10 +150,10 @@ private: |
| /// | | /// |
---|
| /// objc_msgSendSuper_stret with the super2 semantics. | | /// objc_msgSendSuper_stret with the super2 semantics. |
---|
| llvm::FunctionCallee getMessageSendSuperStretFn2() const { | | llvm::FunctionCallee getMessageSendSuperStretFn2() const { |
---|
| - llvm::Type *params[] = { Int8PtrTy, SuperPtrTy, SelectorPtrTy }; | | + llvm::Type *params[] = {Int8PtrTy, SuperPtrTy, SelectorPtrTy}; |
---|
| return CGM.CreateRuntimeFunction( | | return CGM.CreateRuntimeFunction( |
---|
| - llvm::FunctionType::get(CGM.VoidTy, params, true), | | + llvm::FunctionType::get(CGM.VoidTy, params, true), |
---|
| - "objc_msgSendSuper2_stret"); | | + "objc_msgSendSuper2_stret"); |
---|
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getMessageSendSuperFpretFn() const { | | llvm::FunctionCallee getMessageSendSuperFpretFn() const { |
---|
@@ -240,9 +240,8 @@ public: |
| CanQualType Params[] = { | | CanQualType Params[] = { |
---|
| IdType, SelType, | | IdType, SelType, |
---|
| Ctx.getPointerDiffType()->getCanonicalTypeUnqualified(), Ctx.BoolTy}; | | Ctx.getPointerDiffType()->getCanonicalTypeUnqualified(), Ctx.BoolTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = Types.GetFunctionType( |
---|
| - Types.GetFunctionType( | | + Types.arrangeBuiltinFunctionDeclaration(IdType, Params)); |
---|
| - Types.arrangeBuiltinFunctionDeclaration(IdType, Params)); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_getProperty"); | | return CGM.CreateRuntimeFunction(FTy, "objc_getProperty"); |
---|
| } | | } |
---|
| | | |
---|
@@ -259,9 +258,8 @@ public: |
| IdType, | | IdType, |
---|
| Ctx.BoolTy, | | Ctx.BoolTy, |
---|
| Ctx.BoolTy}; | | Ctx.BoolTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = Types.GetFunctionType( |
---|
| - Types.GetFunctionType( | | + Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); |
---|
| - Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_setProperty"); | | return CGM.CreateRuntimeFunction(FTy, "objc_setProperty"); |
---|
| } | | } |
---|
| | | |
---|
@@ -277,16 +275,15 @@ public: |
| // void objc_setProperty_nonatomic_copy(id self, SEL _cmd, | | // void objc_setProperty_nonatomic_copy(id self, SEL _cmd, |
---|
| // id newValue, ptrdiff_t offset); | | // id newValue, ptrdiff_t offset); |
---|
| | | |
---|
| - SmallVector<CanQualType,4> Params; | | + SmallVector<CanQualType, 4> Params; |
---|
| CanQualType IdType = Ctx.getCanonicalParamType(Ctx.getObjCIdType()); | | CanQualType IdType = Ctx.getCanonicalParamType(Ctx.getObjCIdType()); |
---|
| CanQualType SelType = Ctx.getCanonicalParamType(Ctx.getObjCSelType()); | | CanQualType SelType = Ctx.getCanonicalParamType(Ctx.getObjCSelType()); |
---|
| Params.push_back(IdType); | | Params.push_back(IdType); |
---|
| Params.push_back(SelType); | | Params.push_back(SelType); |
---|
| Params.push_back(IdType); | | Params.push_back(IdType); |
---|
| Params.push_back(Ctx.getPointerDiffType()->getCanonicalTypeUnqualified()); | | Params.push_back(Ctx.getPointerDiffType()->getCanonicalTypeUnqualified()); |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = Types.GetFunctionType( |
---|
| - Types.GetFunctionType( | | + Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); |
---|
| - Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); | | |
---|
| const char *name; | | const char *name; |
---|
| if (atomic && copy) | | if (atomic && copy) |
---|
| name = "objc_setProperty_atomic_copy"; | | name = "objc_setProperty_atomic_copy"; |
---|
@@ -304,15 +301,14 @@ public: |
| CodeGen::CodeGenTypes &Types = CGM.getTypes(); | | CodeGen::CodeGenTypes &Types = CGM.getTypes(); |
---|
| ASTContext &Ctx = CGM.getContext(); | | ASTContext &Ctx = CGM.getContext(); |
---|
| // void objc_copyStruct (void *, const void *, size_t, bool, bool) | | // void objc_copyStruct (void *, const void *, size_t, bool, bool) |
---|
| - SmallVector<CanQualType,5> Params; | | + SmallVector<CanQualType, 5> Params; |
---|
| Params.push_back(Ctx.VoidPtrTy); | | Params.push_back(Ctx.VoidPtrTy); |
---|
| Params.push_back(Ctx.VoidPtrTy); | | Params.push_back(Ctx.VoidPtrTy); |
---|
| Params.push_back(Ctx.getSizeType()); | | Params.push_back(Ctx.getSizeType()); |
---|
| Params.push_back(Ctx.BoolTy); | | Params.push_back(Ctx.BoolTy); |
---|
| Params.push_back(Ctx.BoolTy); | | Params.push_back(Ctx.BoolTy); |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = Types.GetFunctionType( |
---|
| - Types.GetFunctionType( | | + Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); |
---|
| - Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_copyStruct"); | | return CGM.CreateRuntimeFunction(FTy, "objc_copyStruct"); |
---|
| } | | } |
---|
| | | |
---|
@@ -323,14 +319,14 @@ public: |
| llvm::FunctionCallee getCppAtomicObjectFunction() { | | llvm::FunctionCallee getCppAtomicObjectFunction() { |
---|
| CodeGen::CodeGenTypes &Types = CGM.getTypes(); | | CodeGen::CodeGenTypes &Types = CGM.getTypes(); |
---|
| ASTContext &Ctx = CGM.getContext(); | | ASTContext &Ctx = CGM.getContext(); |
---|
| - /// void objc_copyCppObjectAtomic(void *dest, const void *src, void *helper); | | + /// void objc_copyCppObjectAtomic(void *dest, const void *src, void |
---|
| - SmallVector<CanQualType,3> Params; | | + /// *helper); |
---|
| | | + SmallVector<CanQualType, 3> Params; |
---|
| Params.push_back(Ctx.VoidPtrTy); | | Params.push_back(Ctx.VoidPtrTy); |
---|
| Params.push_back(Ctx.VoidPtrTy); | | Params.push_back(Ctx.VoidPtrTy); |
---|
| Params.push_back(Ctx.VoidPtrTy); | | Params.push_back(Ctx.VoidPtrTy); |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = Types.GetFunctionType( |
---|
| - Types.GetFunctionType( | | + Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); |
---|
| - Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_copyCppObjectAtomic"); | | return CGM.CreateRuntimeFunction(FTy, "objc_copyCppObjectAtomic"); |
---|
| } | | } |
---|
| | | |
---|
@@ -338,11 +334,10 @@ public: |
| CodeGen::CodeGenTypes &Types = CGM.getTypes(); | | CodeGen::CodeGenTypes &Types = CGM.getTypes(); |
---|
| ASTContext &Ctx = CGM.getContext(); | | ASTContext &Ctx = CGM.getContext(); |
---|
| // void objc_enumerationMutation (id) | | // void objc_enumerationMutation (id) |
---|
| - SmallVector<CanQualType,1> Params; | | + SmallVector<CanQualType, 1> Params; |
---|
| Params.push_back(Ctx.getCanonicalParamType(Ctx.getObjCIdType())); | | Params.push_back(Ctx.getCanonicalParamType(Ctx.getObjCIdType())); |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = Types.GetFunctionType( |
---|
| - Types.GetFunctionType( | | + Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); |
---|
| - Types.arrangeBuiltinFunctionDeclaration(Ctx.VoidTy, Params)); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_enumerationMutation"); | | return CGM.CreateRuntimeFunction(FTy, "objc_enumerationMutation"); |
---|
| } | | } |
---|
| | | |
---|
@@ -350,13 +345,12 @@ public: |
| CodeGen::CodeGenTypes &Types = CGM.getTypes(); | | CodeGen::CodeGenTypes &Types = CGM.getTypes(); |
---|
| ASTContext &Ctx = CGM.getContext(); | | ASTContext &Ctx = CGM.getContext(); |
---|
| // Class objc_lookUpClass (const char *) | | // Class objc_lookUpClass (const char *) |
---|
| - SmallVector<CanQualType,1> Params; | | + SmallVector<CanQualType, 1> Params; |
---|
| Params.push_back( | | Params.push_back( |
---|
| - Ctx.getCanonicalType(Ctx.getPointerType(Ctx.CharTy.withConst()))); | | + Ctx.getCanonicalType(Ctx.getPointerType(Ctx.CharTy.withConst()))); |
---|
| llvm::FunctionType *FTy = | | llvm::FunctionType *FTy = |
---|
| Types.GetFunctionType(Types.arrangeBuiltinFunctionDeclaration( | | Types.GetFunctionType(Types.arrangeBuiltinFunctionDeclaration( |
---|
| - Ctx.getCanonicalType(Ctx.getObjCClassType()), | | + Ctx.getCanonicalType(Ctx.getObjCClassType()), Params)); |
---|
| - Params)); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_lookUpClass"); | | return CGM.CreateRuntimeFunction(FTy, "objc_lookUpClass"); |
---|
| } | | } |
---|
| | | |
---|
@@ -364,8 +358,7 @@ public: |
| llvm::FunctionCallee getGcReadWeakFn() { | | llvm::FunctionCallee getGcReadWeakFn() { |
---|
| // id objc_read_weak (id *) | | // id objc_read_weak (id *) |
---|
| llvm::Type *args[] = {CGM.UnqualPtrTy}; | | llvm::Type *args[] = {CGM.UnqualPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); |
---|
| - llvm::FunctionType::get(ObjectPtrTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_read_weak"); | | return CGM.CreateRuntimeFunction(FTy, "objc_read_weak"); |
---|
| } | | } |
---|
| | | |
---|
@@ -373,8 +366,7 @@ public: |
| llvm::FunctionCallee getGcAssignWeakFn() { | | llvm::FunctionCallee getGcAssignWeakFn() { |
---|
| // id objc_assign_weak (id, id *) | | // id objc_assign_weak (id, id *) |
---|
| llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; | | llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); |
---|
| - llvm::FunctionType::get(ObjectPtrTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak"); | | return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak"); |
---|
| } | | } |
---|
| | | |
---|
@@ -382,8 +374,7 @@ public: |
| llvm::FunctionCallee getGcAssignGlobalFn() { | | llvm::FunctionCallee getGcAssignGlobalFn() { |
---|
| // id objc_assign_global(id, id *) | | // id objc_assign_global(id, id *) |
---|
| llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; | | llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); |
---|
| - llvm::FunctionType::get(ObjectPtrTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_assign_global"); | | return CGM.CreateRuntimeFunction(FTy, "objc_assign_global"); |
---|
| } | | } |
---|
| | | |
---|
@@ -391,8 +382,7 @@ public: |
| llvm::FunctionCallee getGcAssignThreadLocalFn() { | | llvm::FunctionCallee getGcAssignThreadLocalFn() { |
---|
| // id objc_assign_threadlocal(id src, id * dest) | | // id objc_assign_threadlocal(id src, id * dest) |
---|
| llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; | | llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); |
---|
| - llvm::FunctionType::get(ObjectPtrTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal"); | | return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal"); |
---|
| } | | } |
---|
| | | |
---|
@@ -400,15 +390,14 @@ public: |
| llvm::FunctionCallee getGcAssignIvarFn() { | | llvm::FunctionCallee getGcAssignIvarFn() { |
---|
| // id objc_assign_ivar(id, id *, ptrdiff_t) | | // id objc_assign_ivar(id, id *, ptrdiff_t) |
---|
| llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy}; | | llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); |
---|
| - llvm::FunctionType::get(ObjectPtrTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar"); | | return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar"); |
---|
| } | | } |
---|
| | | |
---|
| /// GcMemmoveCollectableFn -- LLVM objc_memmove_collectable function. | | /// GcMemmoveCollectableFn -- LLVM objc_memmove_collectable function. |
---|
| llvm::FunctionCallee GcMemmoveCollectableFn() { | | llvm::FunctionCallee GcMemmoveCollectableFn() { |
---|
| // void *objc_memmove_collectable(void *dst, const void *src, size_t size) | | // void *objc_memmove_collectable(void *dst, const void *src, size_t size) |
---|
| - llvm::Type *args[] = { Int8PtrTy, Int8PtrTy, LongTy }; | | + llvm::Type *args[] = {Int8PtrTy, Int8PtrTy, LongTy}; |
---|
| llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, args, false); | | llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, args, false); |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_memmove_collectable"); | | return CGM.CreateRuntimeFunction(FTy, "objc_memmove_collectable"); |
---|
| } | | } |
---|
@@ -417,17 +406,15 @@ public: |
| llvm::FunctionCallee getGcAssignStrongCastFn() { | | llvm::FunctionCallee getGcAssignStrongCastFn() { |
---|
| // id objc_assign_strongCast(id, id *) | | // id objc_assign_strongCast(id, id *) |
---|
| llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; | | llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(ObjectPtrTy, args, false); |
---|
| - llvm::FunctionType::get(ObjectPtrTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast"); | | return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast"); |
---|
| } | | } |
---|
| | | |
---|
| /// ExceptionThrowFn - LLVM objc_exception_throw function. | | /// ExceptionThrowFn - LLVM objc_exception_throw function. |
---|
| llvm::FunctionCallee getExceptionThrowFn() { | | llvm::FunctionCallee getExceptionThrowFn() { |
---|
| // void objc_exception_throw(id) | | // void objc_exception_throw(id) |
---|
| - llvm::Type *args[] = { ObjectPtrTy }; | | + llvm::Type *args[] = {ObjectPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.VoidTy, args, false); |
---|
| - llvm::FunctionType::get(CGM.VoidTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_exception_throw"); | | return CGM.CreateRuntimeFunction(FTy, "objc_exception_throw"); |
---|
| } | | } |
---|
| | | |
---|
@@ -441,18 +428,16 @@ public: |
| /// SyncEnterFn - LLVM object_sync_enter function. | | /// SyncEnterFn - LLVM object_sync_enter function. |
---|
| llvm::FunctionCallee getSyncEnterFn() { | | llvm::FunctionCallee getSyncEnterFn() { |
---|
| // int objc_sync_enter (id) | | // int objc_sync_enter (id) |
---|
| - llvm::Type *args[] = { ObjectPtrTy }; | | + llvm::Type *args[] = {ObjectPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.IntTy, args, false); |
---|
| - llvm::FunctionType::get(CGM.IntTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_sync_enter"); | | return CGM.CreateRuntimeFunction(FTy, "objc_sync_enter"); |
---|
| } | | } |
---|
| | | |
---|
| /// SyncExitFn - LLVM object_sync_exit function. | | /// SyncExitFn - LLVM object_sync_exit function. |
---|
| llvm::FunctionCallee getSyncExitFn() { | | llvm::FunctionCallee getSyncExitFn() { |
---|
| // int objc_sync_exit (id) | | // int objc_sync_exit (id) |
---|
| - llvm::Type *args[] = { ObjectPtrTy }; | | + llvm::Type *args[] = {ObjectPtrTy}; |
---|
| - llvm::FunctionType *FTy = | | + llvm::FunctionType *FTy = llvm::FunctionType::get(CGM.IntTy, args, false); |
---|
| - llvm::FunctionType::get(CGM.IntTy, args, false); | | |
---|
| return CGM.CreateRuntimeFunction(FTy, "objc_sync_exit"); | | return CGM.CreateRuntimeFunction(FTy, "objc_sync_exit"); |
---|
| } | | } |
---|
| | | |
---|
@@ -553,32 +538,32 @@ public: |
| llvm::FunctionCallee getExceptionTryEnterFn() { | | llvm::FunctionCallee getExceptionTryEnterFn() { |
---|
| llvm::Type *params[] = {CGM.UnqualPtrTy}; | | llvm::Type *params[] = {CGM.UnqualPtrTy}; |
---|
| return CGM.CreateRuntimeFunction( | | return CGM.CreateRuntimeFunction( |
---|
| - llvm::FunctionType::get(CGM.VoidTy, params, false), | | + llvm::FunctionType::get(CGM.VoidTy, params, false), |
---|
| - "objc_exception_try_enter"); | | + "objc_exception_try_enter"); |
---|
| } | | } |
---|
| | | |
---|
| /// ExceptionTryExitFn - LLVM objc_exception_try_exit function. | | /// ExceptionTryExitFn - LLVM objc_exception_try_exit function. |
---|
| llvm::FunctionCallee getExceptionTryExitFn() { | | llvm::FunctionCallee getExceptionTryExitFn() { |
---|
| llvm::Type *params[] = {CGM.UnqualPtrTy}; | | llvm::Type *params[] = {CGM.UnqualPtrTy}; |
---|
| return CGM.CreateRuntimeFunction( | | return CGM.CreateRuntimeFunction( |
---|
| - llvm::FunctionType::get(CGM.VoidTy, params, false), | | + llvm::FunctionType::get(CGM.VoidTy, params, false), |
---|
| - "objc_exception_try_exit"); | | + "objc_exception_try_exit"); |
---|
| } | | } |
---|
| | | |
---|
| /// ExceptionExtractFn - LLVM objc_exception_extract function. | | /// ExceptionExtractFn - LLVM objc_exception_extract function. |
---|
| llvm::FunctionCallee getExceptionExtractFn() { | | llvm::FunctionCallee getExceptionExtractFn() { |
---|
| llvm::Type *params[] = {CGM.UnqualPtrTy}; | | llvm::Type *params[] = {CGM.UnqualPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, false), | | + llvm::FunctionType::get(ObjectPtrTy, params, false), |
---|
| - "objc_exception_extract"); | | + "objc_exception_extract"); |
---|
| } | | } |
---|
| | | |
---|
| /// ExceptionMatchFn - LLVM objc_exception_match function. | | /// ExceptionMatchFn - LLVM objc_exception_match function. |
---|
| llvm::FunctionCallee getExceptionMatchFn() { | | llvm::FunctionCallee getExceptionMatchFn() { |
---|
| - llvm::Type *params[] = { ClassPtrTy, ObjectPtrTy }; | | + llvm::Type *params[] = {ClassPtrTy, ObjectPtrTy}; |
---|
| return CGM.CreateRuntimeFunction( | | return CGM.CreateRuntimeFunction( |
---|
| - llvm::FunctionType::get(CGM.Int32Ty, params, false), | | + llvm::FunctionType::get(CGM.Int32Ty, params, false), |
---|
| - "objc_exception_match"); | | + "objc_exception_match"); |
---|
| } | | } |
---|
| | | |
---|
| /// SetJmpFn - LLVM _setjmp function. | | /// SetJmpFn - LLVM _setjmp function. |
---|
@@ -670,44 +655,44 @@ public: |
| | | |
---|
| llvm::FunctionCallee getMessageSendFixupFn() { | | llvm::FunctionCallee getMessageSendFixupFn() { |
---|
| // id objc_msgSend_fixup(id, struct message_ref_t*, ...) | | // id objc_msgSend_fixup(id, struct message_ref_t*, ...) |
---|
| - llvm::Type *params[] = { ObjectPtrTy, MessageRefPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, MessageRefPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSend_fixup"); | | + "objc_msgSend_fixup"); |
---|
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getMessageSendFpretFixupFn() { | | llvm::FunctionCallee getMessageSendFpretFixupFn() { |
---|
| // id objc_msgSend_fpret_fixup(id, struct message_ref_t*, ...) | | // id objc_msgSend_fpret_fixup(id, struct message_ref_t*, ...) |
---|
| - llvm::Type *params[] = { ObjectPtrTy, MessageRefPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, MessageRefPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSend_fpret_fixup"); | | + "objc_msgSend_fpret_fixup"); |
---|
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getMessageSendStretFixupFn() { | | llvm::FunctionCallee getMessageSendStretFixupFn() { |
---|
| // id objc_msgSend_stret_fixup(id, struct message_ref_t*, ...) | | // id objc_msgSend_stret_fixup(id, struct message_ref_t*, ...) |
---|
| - llvm::Type *params[] = { ObjectPtrTy, MessageRefPtrTy }; | | + llvm::Type *params[] = {ObjectPtrTy, MessageRefPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSend_stret_fixup"); | | + "objc_msgSend_stret_fixup"); |
---|
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getMessageSendSuper2FixupFn() { | | llvm::FunctionCallee getMessageSendSuper2FixupFn() { |
---|
| // id objc_msgSendSuper2_fixup (struct objc_super *, | | // id objc_msgSendSuper2_fixup (struct objc_super *, |
---|
| // struct _super_message_ref_t*, ...) | | // struct _super_message_ref_t*, ...) |
---|
| - llvm::Type *params[] = { SuperPtrTy, SuperMessageRefPtrTy }; | | + llvm::Type *params[] = {SuperPtrTy, SuperMessageRefPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSendSuper2_fixup"); | | + "objc_msgSendSuper2_fixup"); |
---|
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getMessageSendSuper2StretFixupFn() { | | llvm::FunctionCallee getMessageSendSuper2StretFixupFn() { |
---|
| // id objc_msgSendSuper2_stret_fixup(struct objc_super *, | | // id objc_msgSendSuper2_stret_fixup(struct objc_super *, |
---|
| // struct _super_message_ref_t*, ...) | | // struct _super_message_ref_t*, ...) |
---|
| - llvm::Type *params[] = { SuperPtrTy, SuperMessageRefPtrTy }; | | + llvm::Type *params[] = {SuperPtrTy, SuperMessageRefPtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, true), | | + llvm::FunctionType::get(ObjectPtrTy, params, true), |
---|
| - "objc_msgSendSuper2_stret_fixup"); | | + "objc_msgSendSuper2_stret_fixup"); |
---|
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getObjCEndCatchFn() { | | llvm::FunctionCallee getObjCEndCatchFn() { |
---|
@@ -716,10 +701,9 @@ public: |
| } | | } |
---|
| | | |
---|
| llvm::FunctionCallee getObjCBeginCatchFn() { | | llvm::FunctionCallee getObjCBeginCatchFn() { |
---|
| - llvm::Type *params[] = { Int8PtrTy }; | | + llvm::Type *params[] = {Int8PtrTy}; |
---|
| - return CGM.CreateRuntimeFunction(llvm::FunctionType::get(Int8PtrTy, | | + return CGM.CreateRuntimeFunction( |
---|
| - params, false), | | + llvm::FunctionType::get(Int8PtrTy, params, false), "objc_begin_catch"); |
---|
| - "objc_begin_catch"); | | |
---|
| } | | } |
---|
| | | |
---|
| /// Class objc_loadClassref (void *) | | /// Class objc_loadClassref (void *) |
---|
@@ -733,21 +717,23 @@ public: |
| // | | // |
---|
| // Also it is safe to make it readnone, since we never load or store the | | // Also it is safe to make it readnone, since we never load or store the |
---|
| // classref except by calling this function. | | // classref except by calling this function. |
---|
| - llvm::Type *params[] = { Int8PtrPtrTy }; | | + llvm::Type *params[] = {Int8PtrPtrTy}; |
---|
| llvm::LLVMContext &C = CGM.getLLVMContext(); | | llvm::LLVMContext &C = CGM.getLLVMContext(); |
---|
| - llvm::AttributeSet AS = llvm::AttributeSet::get(C, { | | + llvm::AttributeSet AS = llvm::AttributeSet::get( |
---|
| - llvm::Attribute::get(C, llvm::Attribute::NonLazyBind), | | + C, { |
---|
| - llvm::Attribute::getWithMemoryEffects(C, llvm::MemoryEffects::none()), | | + llvm::Attribute::get(C, llvm::Attribute::NonLazyBind), |
---|
| - llvm::Attribute::get(C, llvm::Attribute::NoUnwind), | | + llvm::Attribute::getWithMemoryEffects( |
---|
| - }); | | + C, llvm::MemoryEffects::none()), |
---|
| | | + llvm::Attribute::get(C, llvm::Attribute::NoUnwind), |
---|
| | | + }); |
---|
| llvm::FunctionCallee F = CGM.CreateRuntimeFunction( | | llvm::FunctionCallee F = CGM.CreateRuntimeFunction( |
---|
| llvm::FunctionType::get(ClassnfABIPtrTy, params, false), | | llvm::FunctionType::get(ClassnfABIPtrTy, params, false), |
---|
| "objc_loadClassref", | | "objc_loadClassref", |
---|
| llvm::AttributeList::get(CGM.getLLVMContext(), | | llvm::AttributeList::get(CGM.getLLVMContext(), |
---|
| llvm::AttributeList::FunctionIndex, AS)); | | llvm::AttributeList::FunctionIndex, AS)); |
---|
| if (!CGM.getTriple().isOSBinFormatCOFF()) | | if (!CGM.getTriple().isOSBinFormatCOFF()) |
---|
| - cast<llvm::Function>(F.getCallee())->setLinkage( | | + cast<llvm::Function>(F.getCallee()) |
---|
| - llvm::Function::ExternalWeakLinkage); | | + ->setLinkage(llvm::Function::ExternalWeakLinkage); |
---|
| | | |
---|
| return F; | | return F; |
---|
| } | | } |
---|
@@ -772,9 +758,10 @@ public: |
| unsigned skip; | | unsigned skip; |
---|
| unsigned scan; | | unsigned scan; |
---|
| SKIP_SCAN(unsigned _skip = 0, unsigned _scan = 0) | | SKIP_SCAN(unsigned _skip = 0, unsigned _scan = 0) |
---|
| - : skip(_skip), scan(_scan) {} | | + : skip(_skip), scan(_scan) {} |
---|
| }; | | }; |
---|
| | | |
---|
| | | + // clang-format off |
---|
| /// opcode for captured block variables layout 'instructions'. | | /// opcode for captured block variables layout 'instructions'. |
---|
| /// In the following descriptions, 'I' is the value of the immediate field. | | /// In the following descriptions, 'I' is the value of the immediate field. |
---|
| /// (field following the opcode). | | /// (field following the opcode). |
---|
@@ -821,11 +808,12 @@ public: |
| /// | | /// |
---|
| /// This is included so that older tools can at least continue | | /// This is included so that older tools can at least continue |
---|
| /// processing the layout past such things. | | /// processing the layout past such things. |
---|
| - //BLOCK_LAYOUT_OWNERSHIP_UNKNOWN = 7..10, | | + // BLOCK_LAYOUT_OWNERSHIP_UNKNOWN = 7..10, |
---|
| | | |
---|
| /// All other opcodes are reserved. Halt interpretation and | | /// All other opcodes are reserved. Halt interpretation and |
---|
| /// treat everything else as opaque. | | /// treat everything else as opaque. |
---|
| }; | | }; |
---|
| | | + // clang-format on |
---|
| | | |
---|
| class RUN_SKIP { | | class RUN_SKIP { |
---|
| public: | | public: |
---|
@@ -835,7 +823,7 @@ public: |
| RUN_SKIP(enum BLOCK_LAYOUT_OPCODE Opcode = BLOCK_LAYOUT_OPERATOR, | | RUN_SKIP(enum BLOCK_LAYOUT_OPCODE Opcode = BLOCK_LAYOUT_OPERATOR, |
---|
| CharUnits BytePos = CharUnits::Zero(), | | CharUnits BytePos = CharUnits::Zero(), |
---|
| CharUnits Size = CharUnits::Zero()) | | CharUnits Size = CharUnits::Zero()) |
---|
| - : opcode(Opcode), block_var_bytepos(BytePos), block_var_size(Size) {} | | + : opcode(Opcode), block_var_bytepos(BytePos), block_var_size(Size) {} |
---|
| | | |
---|
| // Allow sorting based on byte pos. | | // Allow sorting based on byte pos. |
---|
| bool operator<(const RUN_SKIP &b) const { | | bool operator<(const RUN_SKIP &b) const { |
---|
@@ -853,70 +841,71 @@ protected: |
| | | |
---|
| /// LazySymbols - Symbols to generate a lazy reference for. See | | /// LazySymbols - Symbols to generate a lazy reference for. See |
---|
| /// DefinedSymbols and FinishModule(). | | /// DefinedSymbols and FinishModule(). |
---|
| - llvm::SetVector<IdentifierInfo*> LazySymbols; | | + llvm::SetVector<IdentifierInfo *> LazySymbols; |
---|
| | | |
---|
| /// DefinedSymbols - External symbols which are defined by this | | /// DefinedSymbols - External symbols which are defined by this |
---|
| /// module. The symbols in this list and LazySymbols are used to add | | /// module. The symbols in this list and LazySymbols are used to add |
---|
| /// special linker symbols which ensure that Objective-C modules are | | /// special linker symbols which ensure that Objective-C modules are |
---|
| /// linked properly. | | /// linked properly. |
---|
| - llvm::SetVector<IdentifierInfo*> DefinedSymbols; | | + llvm::SetVector<IdentifierInfo *> DefinedSymbols; |
---|
| | | |
---|
| /// ClassNames - uniqued class names. | | /// ClassNames - uniqued class names. |
---|
| - llvm::StringMap<llvm::GlobalVariable*> ClassNames; | | + llvm::StringMap<llvm::GlobalVariable *> ClassNames; |
---|
| | | |
---|
| /// MethodVarNames - uniqued method variable names. | | /// MethodVarNames - uniqued method variable names. |
---|
| - llvm::DenseMap<Selector, llvm::GlobalVariable*> MethodVarNames; | | + llvm::DenseMap<Selector, llvm::GlobalVariable *> MethodVarNames; |
---|
| | | |
---|
| /// DefinedCategoryNames - list of category names in form Class_Category. | | /// DefinedCategoryNames - list of category names in form Class_Category. |
---|
| llvm::SmallSetVector<llvm::CachedHashString, 16> DefinedCategoryNames; | | llvm::SmallSetVector<llvm::CachedHashString, 16> DefinedCategoryNames; |
---|
| | | |
---|
| /// MethodVarTypes - uniqued method type signatures. We have to use | | /// MethodVarTypes - uniqued method type signatures. We have to use |
---|
| /// a StringMap here because have no other unique reference. | | /// a StringMap here because have no other unique reference. |
---|
| - llvm::StringMap<llvm::GlobalVariable*> MethodVarTypes; | | + llvm::StringMap<llvm::GlobalVariable *> MethodVarTypes; |
---|
| | | |
---|
| /// MethodDefinitions - map of methods which have been defined in | | /// MethodDefinitions - map of methods which have been defined in |
---|
| /// this translation unit. | | /// this translation unit. |
---|
| - llvm::DenseMap<const ObjCMethodDecl*, llvm::Function*> MethodDefinitions; | | + llvm::DenseMap<const ObjCMethodDecl *, llvm::Function *> MethodDefinitions; |
---|
| | | |
---|
| /// DirectMethodDefinitions - map of direct methods which have been defined in | | /// DirectMethodDefinitions - map of direct methods which have been defined in |
---|
| /// this translation unit. | | /// this translation unit. |
---|
| - llvm::DenseMap<const ObjCMethodDecl*, llvm::Function*> DirectMethodDefinitions; | | + llvm::DenseMap<const ObjCMethodDecl *, llvm::Function *> |
---|
| | | + DirectMethodDefinitions; |
---|
| | | |
---|
| /// PropertyNames - uniqued method variable names. | | /// PropertyNames - uniqued method variable names. |
---|
| - llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> PropertyNames; | | + llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> PropertyNames; |
---|
| | | |
---|
| /// ClassReferences - uniqued class references. | | /// ClassReferences - uniqued class references. |
---|
| - llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> ClassReferences; | | + llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> ClassReferences; |
---|
| | | |
---|
| /// SelectorReferences - uniqued selector references. | | /// SelectorReferences - uniqued selector references. |
---|
| - llvm::DenseMap<Selector, llvm::GlobalVariable*> SelectorReferences; | | + llvm::DenseMap<Selector, llvm::GlobalVariable *> SelectorReferences; |
---|
| | | |
---|
| /// Protocols - Protocols for which an objc_protocol structure has | | /// Protocols - Protocols for which an objc_protocol structure has |
---|
| /// been emitted. Forward declarations are handled by creating an | | /// been emitted. Forward declarations are handled by creating an |
---|
| /// empty structure whose initializer is filled in when/if defined. | | /// empty structure whose initializer is filled in when/if defined. |
---|
| - llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> Protocols; | | + llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> Protocols; |
---|
| | | |
---|
| /// DefinedProtocols - Protocols which have actually been | | /// DefinedProtocols - Protocols which have actually been |
---|
| /// defined. We should not need this, see FIXME in GenerateProtocol. | | /// defined. We should not need this, see FIXME in GenerateProtocol. |
---|
| - llvm::DenseSet<IdentifierInfo*> DefinedProtocols; | | + llvm::DenseSet<IdentifierInfo *> DefinedProtocols; |
---|
| | | |
---|
| /// DefinedClasses - List of defined classes. | | /// DefinedClasses - List of defined classes. |
---|
| - SmallVector<llvm::GlobalValue*, 16> DefinedClasses; | | + SmallVector<llvm::GlobalValue *, 16> DefinedClasses; |
---|
| | | |
---|
| /// ImplementedClasses - List of @implemented classes. | | /// ImplementedClasses - List of @implemented classes. |
---|
| - SmallVector<const ObjCInterfaceDecl*, 16> ImplementedClasses; | | + SmallVector<const ObjCInterfaceDecl *, 16> ImplementedClasses; |
---|
| | | |
---|
| /// DefinedNonLazyClasses - List of defined "non-lazy" classes. | | /// DefinedNonLazyClasses - List of defined "non-lazy" classes. |
---|
| - SmallVector<llvm::GlobalValue*, 16> DefinedNonLazyClasses; | | + SmallVector<llvm::GlobalValue *, 16> DefinedNonLazyClasses; |
---|
| | | |
---|
| /// DefinedCategories - List of defined categories. | | /// DefinedCategories - List of defined categories. |
---|
| - SmallVector<llvm::GlobalValue*, 16> DefinedCategories; | | + SmallVector<llvm::GlobalValue *, 16> DefinedCategories; |
---|
| | | |
---|
| /// DefinedStubCategories - List of defined categories on class stubs. | | /// DefinedStubCategories - List of defined categories on class stubs. |
---|
| - SmallVector<llvm::GlobalValue*, 16> DefinedStubCategories; | | + SmallVector<llvm::GlobalValue *, 16> DefinedStubCategories; |
---|
| | | |
---|
| /// DefinedNonLazyCategories - List of defined "non-lazy" categories. | | /// DefinedNonLazyCategories - List of defined "non-lazy" categories. |
---|
| - SmallVector<llvm::GlobalValue*, 16> DefinedNonLazyCategories; | | + SmallVector<llvm::GlobalValue *, 16> DefinedNonLazyCategories; |
---|
| | | |
---|
| /// Cached reference to the class for constant strings. This value has type | | /// Cached reference to the class for constant strings. This value has type |
---|
| /// int * but is actually an Obj-C class pointer. | | /// int * but is actually an Obj-C class pointer. |
---|
@@ -963,10 +952,8 @@ protected: |
| /// building a weak layout. Does not guarantee that the layout will | | /// building a weak layout. Does not guarantee that the layout will |
---|
| /// actually have any entries, because the ivar might be under-aligned. | | /// actually have any entries, because the ivar might be under-aligned. |
---|
| llvm::Constant *BuildIvarLayout(const ObjCImplementationDecl *OI, | | llvm::Constant *BuildIvarLayout(const ObjCImplementationDecl *OI, |
---|
| - CharUnits beginOffset, | | + CharUnits beginOffset, CharUnits endOffset, |
---|
| - CharUnits endOffset, | | + bool forStrongLayout, bool hasMRCWeakIvars); |
---|
| - bool forStrongLayout, | | |
---|
| - bool hasMRCWeakIvars); | | |
---|
| | | |
---|
| llvm::Constant *BuildStrongIvarLayout(const ObjCImplementationDecl *OI, | | llvm::Constant *BuildStrongIvarLayout(const ObjCImplementationDecl *OI, |
---|
| CharUnits beginOffset, | | CharUnits beginOffset, |
---|
@@ -981,22 +968,19 @@ protected: |
| return BuildIvarLayout(OI, beginOffset, endOffset, false, hasMRCWeakIvars); | | return BuildIvarLayout(OI, beginOffset, endOffset, false, hasMRCWeakIvars); |
---|
| } | | } |
---|
| | | |
---|
| - Qualifiers::ObjCLifetime getBlockCaptureLifetime(QualType QT, bool ByrefLayout); | | + Qualifiers::ObjCLifetime getBlockCaptureLifetime(QualType QT, |
---|
| | | + bool ByrefLayout); |
---|
| | | |
---|
| - void UpdateRunSkipBlockVars(bool IsByref, | | + void UpdateRunSkipBlockVars(bool IsByref, Qualifiers::ObjCLifetime LifeTime, |
---|
| - Qualifiers::ObjCLifetime LifeTime, | | + CharUnits FieldOffset, CharUnits FieldSize); |
---|
| - CharUnits FieldOffset, | | |
---|
| - CharUnits FieldSize); | | |
---|
| | | |
---|
| - void BuildRCBlockVarRecordLayout(const RecordType *RT, | | + void BuildRCBlockVarRecordLayout(const RecordType *RT, CharUnits BytePos, |
---|
| - CharUnits BytePos, bool &HasUnion, | | + bool &HasUnion, bool ByrefLayout = false); |
---|
| - bool ByrefLayout=false); | | |
---|
| | | |
---|
| void BuildRCRecordLayout(const llvm::StructLayout *RecLayout, | | void BuildRCRecordLayout(const llvm::StructLayout *RecLayout, |
---|
| const RecordDecl *RD, | | const RecordDecl *RD, |
---|
| - ArrayRef<const FieldDecl*> RecFields, | | + ArrayRef<const FieldDecl *> RecFields, |
---|
| - CharUnits BytePos, bool &HasUnion, | | + CharUnits BytePos, bool &HasUnion, bool ByrefLayout); |
---|
| - bool ByrefLayout); | | |
---|
| | | |
---|
| uint64_t InlineLayoutInstruction(SmallVectorImpl<unsigned char> &Layout); | | uint64_t InlineLayoutInstruction(SmallVectorImpl<unsigned char> &Layout); |
---|
| | | |
---|
@@ -1009,17 +993,16 @@ protected: |
| | | |
---|
| /// EmitPropertyList - Emit the given property list. The return | | /// EmitPropertyList - Emit the given property list. The return |
---|
| /// value has type PropertyListPtrTy. | | /// value has type PropertyListPtrTy. |
---|
| - llvm::Constant *EmitPropertyList(Twine Name, | | + llvm::Constant *EmitPropertyList(Twine Name, const Decl *Container, |
---|
| - const Decl *Container, | | |
---|
| const ObjCContainerDecl *OCD, | | const ObjCContainerDecl *OCD, |
---|
| const ObjCCommonTypesHelper &ObjCTypes, | | const ObjCCommonTypesHelper &ObjCTypes, |
---|
| bool IsClassProperty); | | bool IsClassProperty); |
---|
| | | |
---|
| /// EmitProtocolMethodTypes - Generate the array of extended method type | | /// EmitProtocolMethodTypes - Generate the array of extended method type |
---|
| /// strings. The return value has type Int8PtrPtrTy. | | /// strings. The return value has type Int8PtrPtrTy. |
---|
| - llvm::Constant *EmitProtocolMethodTypes(Twine Name, | | + llvm::Constant * |
---|
| - ArrayRef<llvm::Constant*> MethodTypes, | | + EmitProtocolMethodTypes(Twine Name, ArrayRef<llvm::Constant *> MethodTypes, |
---|
| - const ObjCCommonTypesHelper &ObjCTypes); | | + const ObjCCommonTypesHelper &ObjCTypes); |
---|
| | | |
---|
| /// GetProtocolRef - Return a reference to the internal protocol | | /// GetProtocolRef - Return a reference to the internal protocol |
---|
| /// description, creating an empty one if it has not been | | /// description, creating an empty one if it has not been |
---|
@@ -1053,8 +1036,7 @@ public: |
| ConstantStructBuilder &Init, | | ConstantStructBuilder &Init, |
---|
| StringRef Section, CharUnits Align, | | StringRef Section, CharUnits Align, |
---|
| bool AddToUsed); | | bool AddToUsed); |
---|
| - llvm::GlobalVariable *CreateMetadataVar(Twine Name, | | + llvm::GlobalVariable *CreateMetadataVar(Twine Name, llvm::Constant *Init, |
---|
| - llvm::Constant *Init, | | |
---|
| StringRef Section, CharUnits Align, | | StringRef Section, CharUnits Align, |
---|
| bool AddToUsed); | | bool AddToUsed); |
---|
| | | |
---|
@@ -1065,12 +1047,9 @@ public: |
| | | |
---|
| protected: | | protected: |
---|
| CodeGen::RValue EmitMessageSend(CodeGen::CodeGenFunction &CGF, | | CodeGen::RValue EmitMessageSend(CodeGen::CodeGenFunction &CGF, |
---|
| - ReturnValueSlot Return, | | + ReturnValueSlot Return, QualType ResultType, |
---|
| - QualType ResultType, | | + Selector Sel, llvm::Value *Arg0, |
---|
| - Selector Sel, | | + QualType Arg0Ty, bool IsSuper, |
---|
| - llvm::Value *Arg0, | | |
---|
| - QualType Arg0Ty, | | |
---|
| - bool IsSuper, | | |
---|
| const CallArgList &CallArgs, | | const CallArgList &CallArgs, |
---|
| const ObjCMethodDecl *OMD, | | const ObjCMethodDecl *OMD, |
---|
| const ObjCInterfaceDecl *ClassReceiver, | | const ObjCInterfaceDecl *ClassReceiver, |
---|
@@ -1084,15 +1063,14 @@ public: |
| CGObjCCommonMac(CodeGen::CodeGenModule &cgm) | | CGObjCCommonMac(CodeGen::CodeGenModule &cgm) |
---|
| : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) {} | | : CGObjCRuntime(cgm), VMContext(cgm.getLLVMContext()) {} |
---|
| | | |
---|
| - bool isNonFragileABI() const { | | + bool isNonFragileABI() const { return ObjCABI == 2; } |
---|
| - return ObjCABI == 2; | | |
---|
| - } | | |
---|
| | | |
---|
| ConstantAddress GenerateConstantString(const StringLiteral *SL) override; | | ConstantAddress GenerateConstantString(const StringLiteral *SL) override; |
---|
| ConstantAddress GenerateConstantNSString(const StringLiteral *SL); | | ConstantAddress GenerateConstantNSString(const StringLiteral *SL); |
---|
| | | |
---|
| - llvm::Function *GenerateMethod(const ObjCMethodDecl *OMD, | | + llvm::Function * |
---|
| - const ObjCContainerDecl *CD=nullptr) override; | | + GenerateMethod(const ObjCMethodDecl *OMD, |
---|
| | | + const ObjCContainerDecl *CD = nullptr) override; |
---|
| | | |
---|
| llvm::Function *GenerateDirectMethod(const ObjCMethodDecl *OMD, | | llvm::Function *GenerateDirectMethod(const ObjCMethodDecl *OMD, |
---|
| const ObjCContainerDecl *CD); | | const ObjCContainerDecl *CD); |
---|
@@ -1107,7 +1085,7 @@ public: |
| /// object for the given declaration, emitting it if needed. These | | /// object for the given declaration, emitting it if needed. These |
---|
| /// forward references will be filled in with empty bodies if no | | /// forward references will be filled in with empty bodies if no |
---|
| /// definition is seen. The return value has type ProtocolPtrTy. | | /// definition is seen. The return value has type ProtocolPtrTy. |
---|
| - virtual llvm::Constant *GetOrEmitProtocolRef(const ObjCProtocolDecl *PD)=0; | | + virtual llvm::Constant *GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) = 0; |
---|
| | | |
---|
| virtual llvm::Constant *getNSConstantStringClassRef() = 0; | | virtual llvm::Constant *getNSConstantStringClassRef() = 0; |
---|
| | | |
---|
@@ -1148,9 +1126,7 @@ public: |
| OptionalInstanceMethods, | | OptionalInstanceMethods, |
---|
| OptionalClassMethods | | OptionalClassMethods |
---|
| }; | | }; |
---|
| - enum { | | + enum { NumProtocolMethodLists = 4 }; |
---|
| - NumProtocolMethodLists = 4 | | |
---|
| - }; | | |
---|
| | | |
---|
| static MethodListType getMethodListKind(Kind kind) { | | static MethodListType getMethodListKind(Kind kind) { |
---|
| switch (kind) { | | switch (kind) { |
---|
@@ -1172,8 +1148,8 @@ public: |
| ProtocolMethodLists result; | | ProtocolMethodLists result; |
---|
| | | |
---|
| for (auto *MD : PD->methods()) { | | for (auto *MD : PD->methods()) { |
---|
| - size_t index = (2 * size_t(MD->isOptional())) | | + size_t index = |
---|
| - + (size_t(MD->isClassMethod())); | | + (2 * size_t(MD->isOptional())) + (size_t(MD->isClassMethod())); |
---|
| result.Methods[index].push_back(MD); | | result.Methods[index].push_back(MD); |
---|
| } | | } |
---|
| | | |
---|
@@ -1181,14 +1157,14 @@ public: |
| } | | } |
---|
| | | |
---|
| template <class Self> | | template <class Self> |
---|
| - SmallVector<llvm::Constant*, 8> emitExtendedTypesArray(Self *self) const { | | + SmallVector<llvm::Constant *, 8> emitExtendedTypesArray(Self *self) const { |
---|
| // In both ABIs, the method types list is parallel with the | | // In both ABIs, the method types list is parallel with the |
---|
| // concatenation of the methods arrays in the following order: | | // concatenation of the methods arrays in the following order: |
---|
| // instance methods | | // instance methods |
---|
| // class methods | | // class methods |
---|
| // optional instance methods | | // optional instance methods |
---|
| // optional class methods | | // optional class methods |
---|
| - SmallVector<llvm::Constant*, 8> result; | | + SmallVector<llvm::Constant *, 8> result; |
---|
| | | |
---|
| // Methods is already in the correct order for both ABIs. | | // Methods is already in the correct order for both ABIs. |
---|
| for (auto &list : Methods) { | | for (auto &list : Methods) { |
---|
@@ -1233,16 +1209,13 @@ private: |
| /// has type ClassExtensionPtrTy. | | /// has type ClassExtensionPtrTy. |
---|
| llvm::Constant *EmitClassExtension(const ObjCImplementationDecl *ID, | | llvm::Constant *EmitClassExtension(const ObjCImplementationDecl *ID, |
---|
| CharUnits instanceSize, | | CharUnits instanceSize, |
---|
| - bool hasMRCWeakIvars, | | + bool hasMRCWeakIvars, bool isMetaclass); |
---|
| - bool isMetaclass); | | |
---|
| | | |
---|
| /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy, | | /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy, |
---|
| /// for the given class. | | /// for the given class. |
---|
| - llvm::Value *EmitClassRef(CodeGenFunction &CGF, | | + llvm::Value *EmitClassRef(CodeGenFunction &CGF, const ObjCInterfaceDecl *ID); |
---|
| - const ObjCInterfaceDecl *ID); | | |
---|
| | | |
---|
| - llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF, | | + llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF, IdentifierInfo *II); |
---|
| - IdentifierInfo *II); | | |
---|
| | | |
---|
| llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override; | | llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override; |
---|
| | | |
---|
@@ -1254,8 +1227,7 @@ private: |
| /// (i.e. metaclass ivars) is emitted, otherwise the list of | | /// (i.e. metaclass ivars) is emitted, otherwise the list of |
---|
| /// interface ivars will be emitted. The return value has type | | /// interface ivars will be emitted. The return value has type |
---|
| /// IvarListPtrTy. | | /// IvarListPtrTy. |
---|
| - llvm::Constant *EmitIvarList(const ObjCImplementationDecl *ID, | | + llvm::Constant *EmitIvarList(const ObjCImplementationDecl *ID, bool ForClass); |
---|
| - bool ForClass); | | |
---|
| | | |
---|
| /// EmitMetaClass - Emit a forward reference to the class structure | | /// EmitMetaClass - Emit a forward reference to the class structure |
---|
| /// for the metaclass of the given interface. The return value has | | /// for the metaclass of the given interface. The return value has |
---|
@@ -1294,9 +1266,8 @@ private: |
| /// structure used to store optional instance and class methods, and | | /// structure used to store optional instance and class methods, and |
---|
| /// protocol properties. The return value has type | | /// protocol properties. The return value has type |
---|
| /// ProtocolExtensionPtrTy. | | /// ProtocolExtensionPtrTy. |
---|
| - llvm::Constant * | | + llvm::Constant *EmitProtocolExtension(const ObjCProtocolDecl *PD, |
---|
| - EmitProtocolExtension(const ObjCProtocolDecl *PD, | | + const ProtocolMethodLists &methodLists); |
---|
| - const ProtocolMethodLists &methodLists); | | |
---|
| | | |
---|
| /// EmitProtocolList - Generate the list of referenced | | /// EmitProtocolList - Generate the list of referenced |
---|
| /// protocols. The return value has type ProtocolListPtrTy. | | /// protocols. The return value has type ProtocolListPtrTy. |
---|
@@ -1318,19 +1289,17 @@ public: |
| | | |
---|
| CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF, | | CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF, |
---|
| ReturnValueSlot Return, | | ReturnValueSlot Return, |
---|
| - QualType ResultType, | | + QualType ResultType, Selector Sel, |
---|
| - Selector Sel, llvm::Value *Receiver, | | + llvm::Value *Receiver, |
---|
| const CallArgList &CallArgs, | | const CallArgList &CallArgs, |
---|
| const ObjCInterfaceDecl *Class, | | const ObjCInterfaceDecl *Class, |
---|
| const ObjCMethodDecl *Method) override; | | const ObjCMethodDecl *Method) override; |
---|
| | | |
---|
| - CodeGen::RValue | | + CodeGen::RValue GenerateMessageSendSuper( |
---|
| - GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, |
---|
| - ReturnValueSlot Return, QualType ResultType, | | + QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class, |
---|
| - Selector Sel, const ObjCInterfaceDecl *Class, | | + bool isCategoryImpl, llvm::Value *Receiver, bool IsClassMessage, |
---|
| - bool isCategoryImpl, llvm::Value *Receiver, | | + const CallArgList &CallArgs, const ObjCMethodDecl *Method) override; |
---|
| - bool IsClassMessage, const CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method) override; | | |
---|
| | | |
---|
| llvm::Value *GetClass(CodeGenFunction &CGF, | | llvm::Value *GetClass(CodeGenFunction &CGF, |
---|
| const ObjCInterfaceDecl *ID) override; | | const ObjCInterfaceDecl *ID) override; |
---|
@@ -1370,22 +1339,19 @@ public: |
| const ObjCAtSynchronizedStmt &S) override; | | const ObjCAtSynchronizedStmt &S) override; |
---|
| void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const Stmt &S); | | void EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const Stmt &S); |
---|
| void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, | | void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, |
---|
| - bool ClearInsertionPoint=true) override; | | + bool ClearInsertionPoint = true) override; |
---|
| - llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, | | + llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, |
---|
| - Address AddrWeakObj) override; | | + Address AddrWeakObj) override; |
---|
| - void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, | | + void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - llvm::Value *src, Address dst) override; | | + Address dst) override; |
---|
| - void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, | | + void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - llvm::Value *src, Address dest, | | + Address dest, bool threadlocal = false) override; |
---|
| - bool threadlocal = false) override; | | + void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, | | + Address dest, llvm::Value *ivarOffset) override; |
---|
| - llvm::Value *src, Address dest, | | + void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - llvm::Value *ivarOffset) override; | | + Address dest) override; |
---|
| - void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, | | + void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, Address dest, |
---|
| - llvm::Value *src, Address dest) override; | | + Address src, llvm::Value *size) override; |
---|
| - void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, | | |
---|
| - Address dest, Address src, | | |
---|
| - llvm::Value *size) override; | | |
---|
| | | |
---|
| LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, | | LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, |
---|
| llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, | | llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, |
---|
@@ -1399,24 +1365,24 @@ class CGObjCNonFragileABIMac : public CGObjCCommonMac { |
| private: | | private: |
---|
| friend ProtocolMethodLists; | | friend ProtocolMethodLists; |
---|
| ObjCNonFragileABITypesHelper ObjCTypes; | | ObjCNonFragileABITypesHelper ObjCTypes; |
---|
| - llvm::GlobalVariable* ObjCEmptyCacheVar; | | + llvm::GlobalVariable *ObjCEmptyCacheVar; |
---|
| - llvm::Constant* ObjCEmptyVtableVar; | | + llvm::Constant *ObjCEmptyVtableVar; |
---|
| | | |
---|
| /// SuperClassReferences - uniqued super class references. | | /// SuperClassReferences - uniqued super class references. |
---|
| - llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> SuperClassReferences; | | + llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> SuperClassReferences; |
---|
| | | |
---|
| /// MetaClassReferences - uniqued meta class references. | | /// MetaClassReferences - uniqued meta class references. |
---|
| - llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> MetaClassReferences; | | + llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> MetaClassReferences; |
---|
| | | |
---|
| /// EHTypeReferences - uniqued class ehtype references. | | /// EHTypeReferences - uniqued class ehtype references. |
---|
| - llvm::DenseMap<IdentifierInfo*, llvm::GlobalVariable*> EHTypeReferences; | | + llvm::DenseMap<IdentifierInfo *, llvm::GlobalVariable *> EHTypeReferences; |
---|
| | | |
---|
| /// VTableDispatchMethods - List of methods for which we generate | | /// VTableDispatchMethods - List of methods for which we generate |
---|
| /// vtable-based message dispatch. | | /// vtable-based message dispatch. |
---|
| llvm::DenseSet<Selector> VTableDispatchMethods; | | llvm::DenseSet<Selector> VTableDispatchMethods; |
---|
| | | |
---|
| /// DefinedMetaClasses - List of defined meta-classes. | | /// DefinedMetaClasses - List of defined meta-classes. |
---|
| - std::vector<llvm::GlobalValue*> DefinedMetaClasses; | | + std::vector<llvm::GlobalValue *> DefinedMetaClasses; |
---|
| | | |
---|
| /// isVTableDispatchedSelector - Returns true if SEL is a | | /// isVTableDispatchedSelector - Returns true if SEL is a |
---|
| /// vtable-based selector. | | /// vtable-based selector. |
---|
@@ -1431,20 +1397,17 @@ private: |
| void AddModuleClassList(ArrayRef<llvm::GlobalValue *> Container, | | void AddModuleClassList(ArrayRef<llvm::GlobalValue *> Container, |
---|
| StringRef SymbolName, StringRef SectionName); | | StringRef SymbolName, StringRef SectionName); |
---|
| | | |
---|
| - llvm::GlobalVariable * BuildClassRoTInitializer(unsigned flags, | | + llvm::GlobalVariable * |
---|
| - unsigned InstanceStart, | | + BuildClassRoTInitializer(unsigned flags, unsigned InstanceStart, |
---|
| - unsigned InstanceSize, | | + unsigned InstanceSize, |
---|
| - const ObjCImplementationDecl *ID); | | + const ObjCImplementationDecl *ID); |
---|
| - llvm::GlobalVariable *BuildClassObject(const ObjCInterfaceDecl *CI, | | + llvm::GlobalVariable * |
---|
| - bool isMetaclass, | | + BuildClassObject(const ObjCInterfaceDecl *CI, bool isMetaclass, |
---|
| - llvm::Constant *IsAGV, | | + llvm::Constant *IsAGV, llvm::Constant *SuperClassGV, |
---|
| - llvm::Constant *SuperClassGV, | | + llvm::Constant *ClassRoGV, bool HiddenVisibility); |
---|
| - llvm::Constant *ClassRoGV, | | |
---|
| - bool HiddenVisibility); | | |
---|
| | | |
---|
| void emitMethodConstant(ConstantArrayBuilder &builder, | | void emitMethodConstant(ConstantArrayBuilder &builder, |
---|
| - const ObjCMethodDecl *MD, | | + const ObjCMethodDecl *MD, bool forProtocol); |
---|
| - bool forProtocol); | | |
---|
| | | |
---|
| /// Emit the method list for the given implementation. The return value | | /// Emit the method list for the given implementation. The return value |
---|
| /// has type MethodListnfABITy. | | /// has type MethodListnfABITy. |
---|
@@ -1479,23 +1442,17 @@ private: |
| ObjCProtocolDecl::protocol_iterator begin, | | ObjCProtocolDecl::protocol_iterator begin, |
---|
| ObjCProtocolDecl::protocol_iterator end); | | ObjCProtocolDecl::protocol_iterator end); |
---|
| | | |
---|
| - CodeGen::RValue EmitVTableMessageSend(CodeGen::CodeGenFunction &CGF, | | + CodeGen::RValue EmitVTableMessageSend( |
---|
| - ReturnValueSlot Return, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, |
---|
| - QualType ResultType, | | + QualType ResultType, Selector Sel, llvm::Value *Receiver, QualType Arg0Ty, |
---|
| - Selector Sel, | | + bool IsSuper, const CallArgList &CallArgs, const ObjCMethodDecl *Method); |
---|
| - llvm::Value *Receiver, | | |
---|
| - QualType Arg0Ty, | | |
---|
| - bool IsSuper, | | |
---|
| - const CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method); | | |
---|
| | | |
---|
| /// GetClassGlobal - Return the global variable for the Objective-C | | /// GetClassGlobal - Return the global variable for the Objective-C |
---|
| /// class of the given name. | | /// class of the given name. |
---|
| llvm::Constant *GetClassGlobal(StringRef Name, | | llvm::Constant *GetClassGlobal(StringRef Name, |
---|
| ForDefinition_t IsForDefinition, | | ForDefinition_t IsForDefinition, |
---|
| bool Weak = false, bool DLLImport = false); | | bool Weak = false, bool DLLImport = false); |
---|
| - llvm::Constant *GetClassGlobal(const ObjCInterfaceDecl *ID, | | + llvm::Constant *GetClassGlobal(const ObjCInterfaceDecl *ID, bool isMetaclass, |
---|
| - bool isMetaclass, | | |
---|
| ForDefinition_t isForDefinition); | | ForDefinition_t isForDefinition); |
---|
| | | |
---|
| llvm::Constant *GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID); | | llvm::Constant *GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID); |
---|
@@ -1506,11 +1463,9 @@ private: |
| | | |
---|
| /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy, | | /// EmitClassRef - Return a Value*, of type ObjCTypes.ClassPtrTy, |
---|
| /// for the given class reference. | | /// for the given class reference. |
---|
| - llvm::Value *EmitClassRef(CodeGenFunction &CGF, | | + llvm::Value *EmitClassRef(CodeGenFunction &CGF, const ObjCInterfaceDecl *ID); |
---|
| - const ObjCInterfaceDecl *ID); | | |
---|
| | | |
---|
| - llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF, | | + llvm::Value *EmitClassRefFromId(CodeGenFunction &CGF, IdentifierInfo *II, |
---|
| - IdentifierInfo *II, | | |
---|
| const ObjCInterfaceDecl *ID); | | const ObjCInterfaceDecl *ID); |
---|
| | | |
---|
| llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override; | | llvm::Value *EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) override; |
---|
@@ -1528,9 +1483,8 @@ private: |
| /// ObjCIvarOffsetVariable - Returns the ivar offset variable for | | /// ObjCIvarOffsetVariable - Returns the ivar offset variable for |
---|
| /// the given ivar. | | /// the given ivar. |
---|
| /// | | /// |
---|
| - llvm::GlobalVariable * ObjCIvarOffsetVariable( | | + llvm::GlobalVariable *ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, |
---|
| - const ObjCInterfaceDecl *ID, | | + const ObjCIvarDecl *Ivar); |
---|
| - const ObjCIvarDecl *Ivar); | | |
---|
| | | |
---|
| /// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy, | | /// EmitSelector - Return a Value*, of type ObjCTypes.SelectorPtrTy, |
---|
| /// for the given selector. | | /// for the given selector. |
---|
@@ -1547,16 +1501,15 @@ private: |
| StringRef getClassSymbolPrefix() const { return "OBJC_CLASS_$_"; } | | StringRef getClassSymbolPrefix() const { return "OBJC_CLASS_$_"; } |
---|
| | | |
---|
| void GetClassSizeInfo(const ObjCImplementationDecl *OID, | | void GetClassSizeInfo(const ObjCImplementationDecl *OID, |
---|
| - uint32_t &InstanceStart, | | + uint32_t &InstanceStart, uint32_t &InstanceSize); |
---|
| - uint32_t &InstanceSize); | | |
---|
| | | |
---|
| // Shamelessly stolen from Analysis/CFRefCount.cpp | | // Shamelessly stolen from Analysis/CFRefCount.cpp |
---|
| - Selector GetNullarySelector(const char* name) const { | | + Selector GetNullarySelector(const char *name) const { |
---|
| const IdentifierInfo *II = &CGM.getContext().Idents.get(name); | | const IdentifierInfo *II = &CGM.getContext().Idents.get(name); |
---|
| return CGM.getContext().Selectors.getSelector(0, &II); | | return CGM.getContext().Selectors.getSelector(0, &II); |
---|
| } | | } |
---|
| | | |
---|
| - Selector GetUnarySelector(const char* name) const { | | + Selector GetUnarySelector(const char *name) const { |
---|
| const IdentifierInfo *II = &CGM.getContext().Idents.get(name); | | const IdentifierInfo *II = &CGM.getContext().Idents.get(name); |
---|
| return CGM.getContext().Selectors.getSelector(1, &II); | | return CGM.getContext().Selectors.getSelector(1, &II); |
---|
| } | | } |
---|
@@ -1582,7 +1535,7 @@ private: |
| // and that the method may be inlined, this optimization actually | | // and that the method may be inlined, this optimization actually |
---|
| // can't be performed. | | // can't be performed. |
---|
| if (const ObjCMethodDecl *MD = | | if (const ObjCMethodDecl *MD = |
---|
| - dyn_cast_or_null<ObjCMethodDecl>(CGF.CurFuncDecl)) | | + dyn_cast_or_null<ObjCMethodDecl>(CGF.CurFuncDecl)) |
---|
| if (MD->isInstanceMethod() && !MD->isDirectMethod()) | | if (MD->isInstanceMethod() && !MD->isDirectMethod()) |
---|
| if (const ObjCInterfaceDecl *ID = MD->getClassInterface()) | | if (const ObjCInterfaceDecl *ID = MD->getClassInterface()) |
---|
| return IV->getContainingInterface()->isSuperClassOf(ID); | | return IV->getContainingInterface()->isSuperClassOf(ID); |
---|
@@ -1621,27 +1574,28 @@ public: |
| const ObjCInterfaceDecl *Class, | | const ObjCInterfaceDecl *Class, |
---|
| const ObjCMethodDecl *Method) override; | | const ObjCMethodDecl *Method) override; |
---|
| | | |
---|
| - CodeGen::RValue | | + CodeGen::RValue GenerateMessageSendSuper( |
---|
| - GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, |
---|
| - ReturnValueSlot Return, QualType ResultType, | | + QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class, |
---|
| - Selector Sel, const ObjCInterfaceDecl *Class, | | + bool isCategoryImpl, llvm::Value *Receiver, bool IsClassMessage, |
---|
| - bool isCategoryImpl, llvm::Value *Receiver, | | + const CallArgList &CallArgs, const ObjCMethodDecl *Method) override; |
---|
| - bool IsClassMessage, const CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method) override; | | |
---|
| | | |
---|
| llvm::Value *GetClass(CodeGenFunction &CGF, | | llvm::Value *GetClass(CodeGenFunction &CGF, |
---|
| const ObjCInterfaceDecl *ID) override; | | const ObjCInterfaceDecl *ID) override; |
---|
| | | |
---|
| - llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) override | | + llvm::Value *GetSelector(CodeGenFunction &CGF, Selector Sel) override { |
---|
| - { return EmitSelector(CGF, Sel); } | | + return EmitSelector(CGF, Sel); |
---|
| - Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) override | | + } |
---|
| - { return EmitSelectorAddr(Sel); } | | + Address GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) override { |
---|
| | | + return EmitSelectorAddr(Sel); |
---|
| | | + } |
---|
| | | |
---|
| /// The NeXT/Apple runtimes do not support typed selectors; just emit an | | /// The NeXT/Apple runtimes do not support typed selectors; just emit an |
---|
| /// untyped one. | | /// untyped one. |
---|
| llvm::Value *GetSelector(CodeGenFunction &CGF, | | llvm::Value *GetSelector(CodeGenFunction &CGF, |
---|
| - const ObjCMethodDecl *Method) override | | + const ObjCMethodDecl *Method) override { |
---|
| - { return EmitSelector(CGF, Method->getSelector()); } | | + return EmitSelector(CGF, Method->getSelector()); |
---|
| | | + } |
---|
| | | |
---|
| void GenerateCategory(const ObjCCategoryImplDecl *CMD) override; | | void GenerateCategory(const ObjCCategoryImplDecl *CMD) override; |
---|
| | | |
---|
@@ -1691,22 +1645,19 @@ public: |
| void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, | | void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
---|
| const ObjCAtSynchronizedStmt &S) override; | | const ObjCAtSynchronizedStmt &S) override; |
---|
| void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, | | void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, |
---|
| - bool ClearInsertionPoint=true) override; | | + bool ClearInsertionPoint = true) override; |
---|
| - llvm::Value * EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, | | + llvm::Value *EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, |
---|
| - Address AddrWeakObj) override; | | + Address AddrWeakObj) override; |
---|
| - void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, | | + void EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - llvm::Value *src, Address edst) override; | | + Address edst) override; |
---|
| - void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, | | + void EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - llvm::Value *src, Address dest, | | + Address dest, bool threadlocal = false) override; |
---|
| - bool threadlocal = false) override; | | + void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - void EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, | | + Address dest, llvm::Value *ivarOffset) override; |
---|
| - llvm::Value *src, Address dest, | | + void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, llvm::Value *src, |
---|
| - llvm::Value *ivarOffset) override; | | + Address dest) override; |
---|
| - void EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, | | + void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, Address dest, |
---|
| - llvm::Value *src, Address dest) override; | | + Address src, llvm::Value *size) override; |
---|
| - void EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, | | |
---|
| - Address dest, Address src, | | |
---|
| - llvm::Value *size) override; | | |
---|
| LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, | | LValue EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, QualType ObjectTy, |
---|
| llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, | | llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, |
---|
| unsigned CVRQualifiers) override; | | unsigned CVRQualifiers) override; |
---|
@@ -1740,14 +1691,12 @@ struct NullReturnState { |
| | | |
---|
| /// Complete the null-return operation. It is valid to call this | | /// Complete the null-return operation. It is valid to call this |
---|
| /// regardless of whether 'init' has been called. | | /// regardless of whether 'init' has been called. |
---|
| - RValue complete(CodeGenFunction &CGF, | | + RValue complete(CodeGenFunction &CGF, ReturnValueSlot returnSlot, |
---|
| - ReturnValueSlot returnSlot, | | + RValue result, QualType resultType, |
---|
| - RValue result, | | + const CallArgList &CallArgs, const ObjCMethodDecl *Method) { |
---|
| - QualType resultType, | | |
---|
| - const CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method) { | | |
---|
| // If we never had to do a null-check, just use the raw result. | | // If we never had to do a null-check, just use the raw result. |
---|
| - if (!NullBB) return result; | | + if (!NullBB) |
---|
| | | + return result; |
---|
| | | |
---|
| // The continuation block. This will be left null if we don't have an | | // The continuation block. This will be left null if we don't have an |
---|
| // IP, which can happen if the method we're calling is marked noreturn. | | // IP, which can happen if the method we're calling is marked noreturn. |
---|
@@ -1774,7 +1723,8 @@ struct NullReturnState { |
| // If we've got a void return, just jump to the continuation block. | | // If we've got a void return, just jump to the continuation block. |
---|
| if (result.isScalar() && resultType->isVoidType()) { | | if (result.isScalar() && resultType->isVoidType()) { |
---|
| // No jumps required if the message-send was noreturn. | | // No jumps required if the message-send was noreturn. |
---|
| - if (contBB) CGF.EmitBlock(contBB); | | + if (contBB) |
---|
| | | + CGF.EmitBlock(contBB); |
---|
| return result; | | return result; |
---|
| } | | } |
---|
| | | |
---|
@@ -1785,7 +1735,8 @@ struct NullReturnState { |
| CGF.EmitFromMemory(CGF.CGM.EmitNullConstant(resultType), resultType); | | CGF.EmitFromMemory(CGF.CGM.EmitNullConstant(resultType), resultType); |
---|
| | | |
---|
| // If no join is necessary, just flow out. | | // If no join is necessary, just flow out. |
---|
| - if (!contBB) return RValue::get(null); | | + if (!contBB) |
---|
| | | + return RValue::get(null); |
---|
| | | |
---|
| // Otherwise, build a phi. | | // Otherwise, build a phi. |
---|
| CGF.EmitBlock(contBB); | | CGF.EmitBlock(contBB); |
---|
@@ -1803,7 +1754,8 @@ struct NullReturnState { |
| assert(result.isAggregate() && "null init of non-aggregate result?"); | | assert(result.isAggregate() && "null init of non-aggregate result?"); |
---|
| if (!returnSlot.isUnused()) | | if (!returnSlot.isUnused()) |
---|
| CGF.EmitNullInitialization(result.getAggregateAddress(), resultType); | | CGF.EmitNullInitialization(result.getAggregateAddress(), resultType); |
---|
| - if (contBB) CGF.EmitBlock(contBB); | | + if (contBB) |
---|
| | | + CGF.EmitBlock(contBB); |
---|
| return result; | | return result; |
---|
| } | | } |
---|
| | | |
---|
@@ -1835,9 +1787,8 @@ static llvm::Constant *getConstantGEP(llvm::LLVMContext &VMContext, |
| llvm::GlobalVariable *C, unsigned idx0, | | llvm::GlobalVariable *C, unsigned idx0, |
---|
| unsigned idx1) { | | unsigned idx1) { |
---|
| llvm::Value *Idxs[] = { | | llvm::Value *Idxs[] = { |
---|
| - llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx0), | | + llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx0), |
---|
| - llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx1) | | + llvm::ConstantInt::get(llvm::Type::getInt32Ty(VMContext), idx1)}; |
---|
| - }; | | |
---|
| return llvm::ConstantExpr::getGetElementPtr(C->getValueType(), C, Idxs); | | return llvm::ConstantExpr::getGetElementPtr(C->getValueType(), C, Idxs); |
---|
| } | | } |
---|
| | | |
---|
@@ -1863,7 +1814,7 @@ getLinkageTypeForObjCMetadata(CodeGenModule &CGM, StringRef Section) { |
| /// A helper function to create an internal or private global variable. | | /// A helper function to create an internal or private global variable. |
---|
| static llvm::GlobalVariable * | | static llvm::GlobalVariable * |
---|
| finishAndCreateGlobal(ConstantInitBuilder::StructBuilder &Builder, | | finishAndCreateGlobal(ConstantInitBuilder::StructBuilder &Builder, |
---|
| - const llvm::Twine &Name, CodeGenModule &CGM) { | | + const llvm::Twine &Name, CodeGenModule &CGM) { |
---|
| std::string SectionName; | | std::string SectionName; |
---|
| if (CGM.getTriple().isOSBinFormatMachO()) | | if (CGM.getTriple().isOSBinFormatMachO()) |
---|
| SectionName = "__DATA, __objc_const"; | | SectionName = "__DATA, __objc_const"; |
---|
@@ -1876,8 +1827,8 @@ finishAndCreateGlobal(ConstantInitBuilder::StructBuilder &Builder, |
| | | |
---|
| /* *** CGObjCMac Public Interface *** */ | | /* *** CGObjCMac Public Interface *** */ |
---|
| | | |
---|
| -CGObjCMac::CGObjCMac(CodeGen::CodeGenModule &cgm) : CGObjCCommonMac(cgm), | | +CGObjCMac::CGObjCMac(CodeGen::CodeGenModule &cgm) |
---|
| - ObjCTypes(cgm) { | | + : CGObjCCommonMac(cgm), ObjCTypes(cgm) { |
---|
| ObjCABI = 1; | | ObjCABI = 1; |
---|
| EmitImageInfo(); | | EmitImageInfo(); |
---|
| } | | } |
---|
@@ -1896,24 +1847,22 @@ llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, Selector Sel) { |
| Address CGObjCMac::GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) { | | Address CGObjCMac::GetAddrOfSelector(CodeGenFunction &CGF, Selector Sel) { |
---|
| return EmitSelectorAddr(Sel); | | return EmitSelectorAddr(Sel); |
---|
| } | | } |
---|
| -llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, const ObjCMethodDecl | | +llvm::Value *CGObjCMac::GetSelector(CodeGenFunction &CGF, |
---|
| - *Method) { | | + const ObjCMethodDecl *Method) { |
---|
| return EmitSelector(CGF, Method->getSelector()); | | return EmitSelector(CGF, Method->getSelector()); |
---|
| } | | } |
---|
| | | |
---|
| llvm::Constant *CGObjCMac::GetEHType(QualType T) { | | llvm::Constant *CGObjCMac::GetEHType(QualType T) { |
---|
| - if (T->isObjCIdType() || | | + if (T->isObjCIdType() || T->isObjCQualifiedIdType()) { |
---|
| - T->isObjCQualifiedIdType()) { | | |
---|
| return CGM.GetAddrOfRTTIDescriptor( | | return CGM.GetAddrOfRTTIDescriptor( |
---|
| - CGM.getContext().getObjCIdRedefinitionType(), /*ForEH=*/true); | | + CGM.getContext().getObjCIdRedefinitionType(), /*ForEH=*/true); |
---|
| } | | } |
---|
| - if (T->isObjCClassType() || | | + if (T->isObjCClassType() || T->isObjCQualifiedClassType()) { |
---|
| - T->isObjCQualifiedClassType()) { | | |
---|
| return CGM.GetAddrOfRTTIDescriptor( | | return CGM.GetAddrOfRTTIDescriptor( |
---|
| - CGM.getContext().getObjCClassRedefinitionType(), /*ForEH=*/true); | | + CGM.getContext().getObjCClassRedefinitionType(), /*ForEH=*/true); |
---|
| } | | } |
---|
| if (T->isObjCObjectPointerType()) | | if (T->isObjCObjectPointerType()) |
---|
| - return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true); | | + return CGM.GetAddrOfRTTIDescriptor(T, /*ForEH=*/true); |
---|
| | | |
---|
| llvm_unreachable("asking for catch type for ObjC type in fragile runtime"); | | llvm_unreachable("asking for catch type for ObjC type in fragile runtime"); |
---|
| } | | } |
---|
@@ -1940,8 +1889,8 @@ llvm::Constant *CGObjCMac::GetEHType(QualType T) { |
| ConstantAddress | | ConstantAddress |
---|
| CGObjCCommonMac::GenerateConstantString(const StringLiteral *SL) { | | CGObjCCommonMac::GenerateConstantString(const StringLiteral *SL) { |
---|
| return (!CGM.getLangOpts().NoConstantCFStrings | | return (!CGM.getLangOpts().NoConstantCFStrings |
---|
| - ? CGM.GetAddrOfConstantCFString(SL) | | + ? CGM.GetAddrOfConstantCFString(SL) |
---|
| - : GenerateConstantNSString(SL)); | | + : GenerateConstantNSString(SL)); |
---|
| } | | } |
---|
| | | |
---|
| static llvm::StringMapEntry<llvm::GlobalVariable *> & | | static llvm::StringMapEntry<llvm::GlobalVariable *> & |
---|
@@ -1957,9 +1906,8 @@ llvm::Constant *CGObjCMac::getNSConstantStringClassRef() { |
| return cast<llvm::Constant>(V); | | return cast<llvm::Constant>(V); |
---|
| | | |
---|
| auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass; | | auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass; |
---|
| - std::string str = | | + std::string str = StringClass.empty() ? "_NSConstantStringClassReference" |
---|
| - StringClass.empty() ? "_NSConstantStringClassReference" | | + : "_" + StringClass + "ClassReference"; |
---|
| - : "_" + StringClass + "ClassReference"; | | |
---|
| | | |
---|
| llvm::Type *PTy = llvm::ArrayType::get(CGM.IntTy, 0); | | llvm::Type *PTy = llvm::ArrayType::get(CGM.IntTy, 0); |
---|
| auto GV = CGM.CreateRuntimeVariable(PTy, str); | | auto GV = CGM.CreateRuntimeVariable(PTy, str); |
---|
@@ -1972,9 +1920,8 @@ llvm::Constant *CGObjCNonFragileABIMac::getNSConstantStringClassRef() { |
| return cast<llvm::Constant>(V); | | return cast<llvm::Constant>(V); |
---|
| | | |
---|
| auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass; | | auto &StringClass = CGM.getLangOpts().ObjCConstantStringClass; |
---|
| - std::string str = | | + std::string str = StringClass.empty() ? "OBJC_CLASS_$_NSConstantString" |
---|
| - StringClass.empty() ? "OBJC_CLASS_$_NSConstantString" | | + : "OBJC_CLASS_$_" + StringClass; |
---|
| - : "OBJC_CLASS_$_" + StringClass; | | |
---|
| llvm::Constant *GV = GetClassGlobal(str, NotForDefinition); | | llvm::Constant *GV = GetClassGlobal(str, NotForDefinition); |
---|
| ConstantStringClassRef = GV; | | ConstantStringClassRef = GV; |
---|
| return GV; | | return GV; |
---|
@@ -1984,11 +1931,11 @@ ConstantAddress |
| CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) { | | CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) { |
---|
| unsigned StringLength = 0; | | unsigned StringLength = 0; |
---|
| llvm::StringMapEntry<llvm::GlobalVariable *> &Entry = | | llvm::StringMapEntry<llvm::GlobalVariable *> &Entry = |
---|
| - GetConstantStringEntry(NSConstantStringMap, Literal, StringLength); | | + GetConstantStringEntry(NSConstantStringMap, Literal, StringLength); |
---|
| | | |
---|
| if (auto *C = Entry.second) | | if (auto *C = Entry.second) |
---|
| - return ConstantAddress( | | + return ConstantAddress(C, C->getValueType(), |
---|
| - C, C->getValueType(), CharUnits::fromQuantity(C->getAlignment())); | | + CharUnits::fromQuantity(C->getAlignment())); |
---|
| | | |
---|
| // If we don't already have it, get _NSConstantStringClassReference. | | // If we don't already have it, get _NSConstantStringClassReference. |
---|
| llvm::Constant *Class = getNSConstantStringClassRef(); | | llvm::Constant *Class = getNSConstantStringClassRef(); |
---|
@@ -2008,7 +1955,7 @@ CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) { |
| | | |
---|
| // String pointer. | | // String pointer. |
---|
| llvm::Constant *C = | | llvm::Constant *C = |
---|
| - llvm::ConstantDataArray::getString(VMContext, Entry.first()); | | + llvm::ConstantDataArray::getString(VMContext, Entry.first()); |
---|
| | | |
---|
| llvm::GlobalValue::LinkageTypes Linkage = llvm::GlobalValue::PrivateLinkage; | | llvm::GlobalValue::LinkageTypes Linkage = llvm::GlobalValue::PrivateLinkage; |
---|
| bool isConstant = !CGM.getLangOpts().WritableStrings; | | bool isConstant = !CGM.getLangOpts().WritableStrings; |
---|
@@ -2041,30 +1988,22 @@ CGObjCCommonMac::GenerateConstantNSString(const StringLiteral *Literal) { |
| return ConstantAddress(GV, GV->getValueType(), Alignment); | | return ConstantAddress(GV, GV->getValueType(), Alignment); |
---|
| } | | } |
---|
| | | |
---|
| -enum { | | +enum { kCFTaggedObjectID_Integer = (1 << 1) + 1 }; |
---|
| - kCFTaggedObjectID_Integer = (1 << 1) + 1 | | |
---|
| -}; | | |
---|
| | | |
---|
| /// Generates a message send where the super is the receiver. This is | | /// Generates a message send where the super is the receiver. This is |
---|
| /// a message send to self with special delivery semantics indicating | | /// a message send to self with special delivery semantics indicating |
---|
| /// which class's method should be called. | | /// which class's method should be called. |
---|
| -CodeGen::RValue | | +CodeGen::RValue CGObjCMac::GenerateMessageSendSuper( |
---|
| -CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, |
---|
| - ReturnValueSlot Return, | | + Selector Sel, const ObjCInterfaceDecl *Class, bool isCategoryImpl, |
---|
| - QualType ResultType, | | + llvm::Value *Receiver, bool IsClassMessage, |
---|
| - Selector Sel, | | + const CodeGen::CallArgList &CallArgs, const ObjCMethodDecl *Method) { |
---|
| - const ObjCInterfaceDecl *Class, | | |
---|
| - bool isCategoryImpl, | | |
---|
| - llvm::Value *Receiver, | | |
---|
| - bool IsClassMessage, | | |
---|
| - const CodeGen::CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method) { | | |
---|
| // Create and init a super structure; this is a (receiver, class) | | // Create and init a super structure; this is a (receiver, class) |
---|
| // pair we will pass to objc_msgSendSuper. | | // pair we will pass to objc_msgSendSuper. |
---|
| RawAddress ObjCSuper = CGF.CreateTempAlloca( | | RawAddress ObjCSuper = CGF.CreateTempAlloca( |
---|
| ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super"); | | ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super"); |
---|
| llvm::Value *ReceiverAsObject = | | llvm::Value *ReceiverAsObject = |
---|
| - CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy); | | + CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy); |
---|
| CGF.Builder.CreateStore(ReceiverAsObject, | | CGF.Builder.CreateStore(ReceiverAsObject, |
---|
| CGF.Builder.CreateStructGEP(ObjCSuper, 0)); | | CGF.Builder.CreateStructGEP(ObjCSuper, 0)); |
---|
| | | |
---|
@@ -2102,7 +2041,7 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, |
| // FIXME: We shouldn't need to do this cast, rectify the ASTContext and | | // FIXME: We shouldn't need to do this cast, rectify the ASTContext and |
---|
| // ObjCTypes types. | | // ObjCTypes types. |
---|
| llvm::Type *ClassTy = | | llvm::Type *ClassTy = |
---|
| - CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType()); | | + CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType()); |
---|
| Target = CGF.Builder.CreateBitCast(Target, ClassTy); | | Target = CGF.Builder.CreateBitCast(Target, ClassTy); |
---|
| CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1)); | | CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1)); |
---|
| return EmitMessageSend(CGF, Return, ResultType, Sel, ObjCSuper.getPointer(), | | return EmitMessageSend(CGF, Return, ResultType, Sel, ObjCSuper.getPointer(), |
---|
@@ -2111,31 +2050,21 @@ CGObjCMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, |
| } | | } |
---|
| | | |
---|
| /// Generate code for a message send expression. | | /// Generate code for a message send expression. |
---|
| -CodeGen::RValue CGObjCMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF, | | +CodeGen::RValue CGObjCMac::GenerateMessageSend( |
---|
| - ReturnValueSlot Return, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, |
---|
| - QualType ResultType, | | + Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs, |
---|
| - Selector Sel, | | + const ObjCInterfaceDecl *Class, const ObjCMethodDecl *Method) { |
---|
| - llvm::Value *Receiver, | | |
---|
| - const CallArgList &CallArgs, | | |
---|
| - const ObjCInterfaceDecl *Class, | | |
---|
| - const ObjCMethodDecl *Method) { | | |
---|
| return EmitMessageSend(CGF, Return, ResultType, Sel, Receiver, | | return EmitMessageSend(CGF, Return, ResultType, Sel, Receiver, |
---|
| CGF.getContext().getObjCIdType(), false, CallArgs, | | CGF.getContext().getObjCIdType(), false, CallArgs, |
---|
| Method, Class, ObjCTypes); | | Method, Class, ObjCTypes); |
---|
| } | | } |
---|
| | | |
---|
| -CodeGen::RValue | | +CodeGen::RValue CGObjCCommonMac::EmitMessageSend( |
---|
| -CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, |
---|
| - ReturnValueSlot Return, | | + Selector Sel, llvm::Value *Arg0, QualType Arg0Ty, bool IsSuper, |
---|
| - QualType ResultType, | | + const CallArgList &CallArgs, const ObjCMethodDecl *Method, |
---|
| - Selector Sel, | | + const ObjCInterfaceDecl *ClassReceiver, |
---|
| - llvm::Value *Arg0, | | + const ObjCCommonTypesHelper &ObjCTypes) { |
---|
| - QualType Arg0Ty, | | |
---|
| - bool IsSuper, | | |
---|
| - const CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method, | | |
---|
| - const ObjCInterfaceDecl *ClassReceiver, | | |
---|
| - const ObjCCommonTypesHelper &ObjCTypes) { | | |
---|
| CodeGenTypes &Types = CGM.getTypes(); | | CodeGenTypes &Types = CGM.getTypes(); |
---|
| auto selTy = CGF.getContext().getObjCSelType(); | | auto selTy = CGF.getContext().getObjCSelType(); |
---|
| llvm::Value *SelValue = llvm::UndefValue::get(Types.ConvertType(selTy)); | | llvm::Value *SelValue = llvm::UndefValue::get(Types.ConvertType(selTy)); |
---|
@@ -2157,7 +2086,7 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, |
| "Result type mismatch!"); | | "Result type mismatch!"); |
---|
| | | |
---|
| bool ReceiverCanBeNull = | | bool ReceiverCanBeNull = |
---|
| - canMessageReceiverBeNull(CGF, Method, IsSuper, ClassReceiver, Arg0); | | + canMessageReceiverBeNull(CGF, Method, IsSuper, ClassReceiver, Arg0); |
---|
| | | |
---|
| bool RequiresNullCheck = false; | | bool RequiresNullCheck = false; |
---|
| bool RequiresSelValue = true; | | bool RequiresSelValue = true; |
---|
@@ -2170,22 +2099,23 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, |
| // so just don't bother with setting the `_cmd` argument. | | // so just don't bother with setting the `_cmd` argument. |
---|
| RequiresSelValue = false; | | RequiresSelValue = false; |
---|
| } else if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) { | | } else if (CGM.ReturnSlotInterferesWithArgs(MSI.CallInfo)) { |
---|
| - if (ReceiverCanBeNull) RequiresNullCheck = true; | | + if (ReceiverCanBeNull) |
---|
| - Fn = (ObjCABI == 2) ? ObjCTypes.getSendStretFn2(IsSuper) | | + RequiresNullCheck = true; |
---|
| - : ObjCTypes.getSendStretFn(IsSuper); | | + Fn = (ObjCABI == 2) ? ObjCTypes.getSendStretFn2(IsSuper) |
---|
| | | + : ObjCTypes.getSendStretFn(IsSuper); |
---|
| } else if (CGM.ReturnTypeUsesFPRet(ResultType)) { | | } else if (CGM.ReturnTypeUsesFPRet(ResultType)) { |
---|
| Fn = (ObjCABI == 2) ? ObjCTypes.getSendFpretFn2(IsSuper) | | Fn = (ObjCABI == 2) ? ObjCTypes.getSendFpretFn2(IsSuper) |
---|
| - : ObjCTypes.getSendFpretFn(IsSuper); | | + : ObjCTypes.getSendFpretFn(IsSuper); |
---|
| } else if (CGM.ReturnTypeUsesFP2Ret(ResultType)) { | | } else if (CGM.ReturnTypeUsesFP2Ret(ResultType)) { |
---|
| Fn = (ObjCABI == 2) ? ObjCTypes.getSendFp2RetFn2(IsSuper) | | Fn = (ObjCABI == 2) ? ObjCTypes.getSendFp2RetFn2(IsSuper) |
---|
| - : ObjCTypes.getSendFp2retFn(IsSuper); | | + : ObjCTypes.getSendFp2retFn(IsSuper); |
---|
| } else { | | } else { |
---|
| // arm64 uses objc_msgSend for stret methods and yet null receiver check | | // arm64 uses objc_msgSend for stret methods and yet null receiver check |
---|
| // must be made for it. | | // must be made for it. |
---|
| if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo)) | | if (ReceiverCanBeNull && CGM.ReturnTypeUsesSRet(MSI.CallInfo)) |
---|
| RequiresNullCheck = true; | | RequiresNullCheck = true; |
---|
| Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper) | | Fn = (ObjCABI == 2) ? ObjCTypes.getSendFn2(IsSuper) |
---|
| - : ObjCTypes.getSendFn(IsSuper); | | + : ObjCTypes.getSendFn(IsSuper); |
---|
| } | | } |
---|
| | | |
---|
| // Cast function to proper signature | | // Cast function to proper signature |
---|
@@ -2214,8 +2144,8 @@ CGObjCCommonMac::EmitMessageSend(CodeGen::CodeGenFunction &CGF, |
| | | |
---|
| llvm::CallBase *CallSite; | | llvm::CallBase *CallSite; |
---|
| CGCallee Callee = CGCallee::forDirect(BitcastFn); | | CGCallee Callee = CGCallee::forDirect(BitcastFn); |
---|
| - RValue rvalue = CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs, | | + RValue rvalue = |
---|
| - &CallSite); | | + CGF.EmitCall(MSI.CallInfo, Callee, Return, ActualArgs, &CallSite); |
---|
| | | |
---|
| // Mark the call as noreturn if the method is marked noreturn and the | | // Mark the call as noreturn if the method is marked noreturn and the |
---|
| // receiver cannot be null. | | // receiver cannot be null. |
---|
@@ -2240,13 +2170,19 @@ static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT, |
| | | |
---|
| if (auto ownership = FQT.getObjCLifetime()) { | | if (auto ownership = FQT.getObjCLifetime()) { |
---|
| // Ownership does not apply recursively to C pointer types. | | // Ownership does not apply recursively to C pointer types. |
---|
| - if (pointee) return Qualifiers::GCNone; | | + if (pointee) |
---|
| | | + return Qualifiers::GCNone; |
---|
| switch (ownership) { | | switch (ownership) { |
---|
| - case Qualifiers::OCL_Weak: return Qualifiers::Weak; | | + case Qualifiers::OCL_Weak: |
---|
| - case Qualifiers::OCL_Strong: return Qualifiers::Strong; | | + return Qualifiers::Weak; |
---|
| - case Qualifiers::OCL_ExplicitNone: return Qualifiers::GCNone; | | + case Qualifiers::OCL_Strong: |
---|
| - case Qualifiers::OCL_Autoreleasing: llvm_unreachable("autoreleasing ivar?"); | | + return Qualifiers::Strong; |
---|
| - case Qualifiers::OCL_None: llvm_unreachable("known nonzero"); | | + case Qualifiers::OCL_ExplicitNone: |
---|
| | | + return Qualifiers::GCNone; |
---|
| | | + case Qualifiers::OCL_Autoreleasing: |
---|
| | | + llvm_unreachable("autoreleasing ivar?"); |
---|
| | | + case Qualifiers::OCL_None: |
---|
| | | + llvm_unreachable("known nonzero"); |
---|
| } | | } |
---|
| llvm_unreachable("bad objc ownership"); | | llvm_unreachable("bad objc ownership"); |
---|
| } | | } |
---|
@@ -2265,76 +2201,73 @@ static Qualifiers::GC GetGCAttrTypeForType(ASTContext &Ctx, QualType FQT, |
| } | | } |
---|
| | | |
---|
| namespace { | | namespace { |
---|
| - struct IvarInfo { | | +struct IvarInfo { |
---|
| - CharUnits Offset; | | + CharUnits Offset; |
---|
| - uint64_t SizeInWords; | | + uint64_t SizeInWords; |
---|
| - IvarInfo(CharUnits offset, uint64_t sizeInWords) | | + IvarInfo(CharUnits offset, uint64_t sizeInWords) |
---|
| : Offset(offset), SizeInWords(sizeInWords) {} | | : Offset(offset), SizeInWords(sizeInWords) {} |
---|
| | | |
---|
| - // Allow sorting based on byte pos. | | + // Allow sorting based on byte pos. |
---|
| - bool operator<(const IvarInfo &other) const { | | + bool operator<(const IvarInfo &other) const { return Offset < other.Offset; } |
---|
| - return Offset < other.Offset; | | +}; |
---|
| - } | | |
---|
| - }; | | |
---|
| | | |
---|
| - /// A helper class for building GC layout strings. | | +/// A helper class for building GC layout strings. |
---|
| - class IvarLayoutBuilder { | | +class IvarLayoutBuilder { |
---|
| - CodeGenModule &CGM; | | + CodeGenModule &CGM; |
---|
| | | |
---|
| - /// The start of the layout. Offsets will be relative to this value, | | + /// The start of the layout. Offsets will be relative to this value, |
---|
| - /// and entries less than this value will be silently discarded. | | + /// and entries less than this value will be silently discarded. |
---|
| - CharUnits InstanceBegin; | | + CharUnits InstanceBegin; |
---|
| | | |
---|
| - /// The end of the layout. Offsets will never exceed this value. | | + /// The end of the layout. Offsets will never exceed this value. |
---|
| - CharUnits InstanceEnd; | | + CharUnits InstanceEnd; |
---|
| | | |
---|
| - /// Whether we're generating the strong layout or the weak layout. | | + /// Whether we're generating the strong layout or the weak layout. |
---|
| - bool ForStrongLayout; | | + bool ForStrongLayout; |
---|
| | | |
---|
| - /// Whether the offsets in IvarsInfo might be out-of-order. | | + /// Whether the offsets in IvarsInfo might be out-of-order. |
---|
| - bool IsDisordered = false; | | + bool IsDisordered = false; |
---|
| | | |
---|
| - llvm::SmallVector<IvarInfo, 8> IvarsInfo; | | + llvm::SmallVector<IvarInfo, 8> IvarsInfo; |
---|
| | | |
---|
| - public: | | +public: |
---|
| - IvarLayoutBuilder(CodeGenModule &CGM, CharUnits instanceBegin, | | + IvarLayoutBuilder(CodeGenModule &CGM, CharUnits instanceBegin, |
---|
| - CharUnits instanceEnd, bool forStrongLayout) | | + CharUnits instanceEnd, bool forStrongLayout) |
---|
| : CGM(CGM), InstanceBegin(instanceBegin), InstanceEnd(instanceEnd), | | : CGM(CGM), InstanceBegin(instanceBegin), InstanceEnd(instanceEnd), |
---|
| - ForStrongLayout(forStrongLayout) { | | + ForStrongLayout(forStrongLayout) {} |
---|
| - } | | |
---|
| | | |
---|
| - void visitRecord(const RecordType *RT, CharUnits offset); | | + void visitRecord(const RecordType *RT, CharUnits offset); |
---|
| | | |
---|
| - template <class Iterator, class GetOffsetFn> | | + template <class Iterator, class GetOffsetFn> |
---|
| - void visitAggregate(Iterator begin, Iterator end, | | + void visitAggregate(Iterator begin, Iterator end, CharUnits aggrOffset, |
---|
| - CharUnits aggrOffset, | | + const GetOffsetFn &getOffset); |
---|
| - const GetOffsetFn &getOffset); | | |
---|
| | | |
---|
| - void visitField(const FieldDecl *field, CharUnits offset); | | + void visitField(const FieldDecl *field, CharUnits offset); |
---|
| | | |
---|
| - /// Add the layout of a block implementation. | | + /// Add the layout of a block implementation. |
---|
| - void visitBlock(const CGBlockInfo &blockInfo); | | + void visitBlock(const CGBlockInfo &blockInfo); |
---|
| | | |
---|
| - /// Is there any information for an interesting bitmap? | | + /// Is there any information for an interesting bitmap? |
---|
| - bool hasBitmapData() const { return !IvarsInfo.empty(); } | | + bool hasBitmapData() const { return !IvarsInfo.empty(); } |
---|
| | | |
---|
| - llvm::Constant *buildBitmap(CGObjCCommonMac &CGObjC, | | + llvm::Constant *buildBitmap(CGObjCCommonMac &CGObjC, |
---|
| - llvm::SmallVectorImpl<unsigned char> &buffer); | | + llvm::SmallVectorImpl<unsigned char> &buffer); |
---|
| | | |
---|
| - static void dump(ArrayRef<unsigned char> buffer) { | | + static void dump(ArrayRef<unsigned char> buffer) { |
---|
| - const unsigned char *s = buffer.data(); | | + const unsigned char *s = buffer.data(); |
---|
| - for (unsigned i = 0, e = buffer.size(); i < e; i++) | | + for (unsigned i = 0, e = buffer.size(); i < e; i++) |
---|
| - if (!(s[i] & 0xf0)) | | + if (!(s[i] & 0xf0)) |
---|
| - printf("0x0%x%s", s[i], s[i] != 0 ? ", " : ""); | | + printf("0x0%x%s", s[i], s[i] != 0 ? ", " : ""); |
---|
| - else | | + else |
---|
| - printf("0x%x%s", s[i], s[i] != 0 ? ", " : ""); | | + printf("0x%x%s", s[i], s[i] != 0 ? ", " : ""); |
---|
| - printf("\n"); | | + printf("\n"); |
---|
| - } | | + } |
---|
| - }; | | +}; |
---|
| } // end anonymous namespace | | } // end anonymous namespace |
---|
| | | |
---|
| -llvm::Constant *CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM, | | +llvm::Constant * |
---|
| - const CGBlockInfo &blockInfo) { | | +CGObjCCommonMac::BuildGCBlockLayout(CodeGenModule &CGM, |
---|
| | | + const CGBlockInfo &blockInfo) { |
---|
| | | |
---|
| llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy); | | llvm::Constant *nullPtr = llvm::Constant::getNullValue(CGM.Int8PtrTy); |
---|
| if (CGM.getLangOpts().getGC() == LangOptions::NonGC) | | if (CGM.getLangOpts().getGC() == LangOptions::NonGC) |
---|
@@ -2378,7 +2311,8 @@ void IvarLayoutBuilder::visitBlock(const CGBlockInfo &blockInfo) { |
| const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable); | | const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable); |
---|
| | | |
---|
| // Ignore constant captures. | | // Ignore constant captures. |
---|
| - if (capture.isConstant()) continue; | | + if (capture.isConstant()) |
---|
| | | + continue; |
---|
| | | |
---|
| CharUnits fieldOffset = capture.getOffset(); | | CharUnits fieldOffset = capture.getOffset(); |
---|
| | | |
---|
@@ -2413,8 +2347,8 @@ void IvarLayoutBuilder::visitBlock(const CGBlockInfo &blockInfo) { |
| /// getBlockCaptureLifetime - This routine returns life time of the captured | | /// getBlockCaptureLifetime - This routine returns life time of the captured |
---|
| /// block variable for the purpose of block layout meta-data generation. FQT is | | /// block variable for the purpose of block layout meta-data generation. FQT is |
---|
| /// the type of the variable captured in the block. | | /// the type of the variable captured in the block. |
---|
| -Qualifiers::ObjCLifetime CGObjCCommonMac::getBlockCaptureLifetime(QualType FQT, | | +Qualifiers::ObjCLifetime |
---|
| - bool ByrefLayout) { | | +CGObjCCommonMac::getBlockCaptureLifetime(QualType FQT, bool ByrefLayout) { |
---|
| // If it has an ownership qualifier, we're done. | | // If it has an ownership qualifier, we're done. |
---|
| if (auto lifetime = FQT.getObjCLifetime()) | | if (auto lifetime = FQT.getObjCLifetime()) |
---|
| return lifetime; | | return lifetime; |
---|
@@ -2436,26 +2370,25 @@ void CGObjCCommonMac::UpdateRunSkipBlockVars(bool IsByref, |
| CharUnits FieldSize) { | | CharUnits FieldSize) { |
---|
| // __block variables are passed by their descriptor address. | | // __block variables are passed by their descriptor address. |
---|
| if (IsByref) | | if (IsByref) |
---|
| - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_BYREF, FieldOffset, | | + RunSkipBlockVars.push_back( |
---|
| - FieldSize)); | | + RUN_SKIP(BLOCK_LAYOUT_BYREF, FieldOffset, FieldSize)); |
---|
| else if (LifeTime == Qualifiers::OCL_Strong) | | else if (LifeTime == Qualifiers::OCL_Strong) |
---|
| - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_STRONG, FieldOffset, | | + RunSkipBlockVars.push_back( |
---|
| - FieldSize)); | | + RUN_SKIP(BLOCK_LAYOUT_STRONG, FieldOffset, FieldSize)); |
---|
| else if (LifeTime == Qualifiers::OCL_Weak) | | else if (LifeTime == Qualifiers::OCL_Weak) |
---|
| - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_WEAK, FieldOffset, | | + RunSkipBlockVars.push_back( |
---|
| - FieldSize)); | | + RUN_SKIP(BLOCK_LAYOUT_WEAK, FieldOffset, FieldSize)); |
---|
| else if (LifeTime == Qualifiers::OCL_ExplicitNone) | | else if (LifeTime == Qualifiers::OCL_ExplicitNone) |
---|
| - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_UNRETAINED, FieldOffset, | | + RunSkipBlockVars.push_back( |
---|
| - FieldSize)); | | + RUN_SKIP(BLOCK_LAYOUT_UNRETAINED, FieldOffset, FieldSize)); |
---|
| else | | else |
---|
| - RunSkipBlockVars.push_back(RUN_SKIP(BLOCK_LAYOUT_NON_OBJECT_BYTES, | | + RunSkipBlockVars.push_back( |
---|
| - FieldOffset, | | + RUN_SKIP(BLOCK_LAYOUT_NON_OBJECT_BYTES, FieldOffset, FieldSize)); |
---|
| - FieldSize)); | | |
---|
| } | | } |
---|
| | | |
---|
| void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, | | void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, |
---|
| const RecordDecl *RD, | | const RecordDecl *RD, |
---|
| - ArrayRef<const FieldDecl*> RecFields, | | + ArrayRef<const FieldDecl *> RecFields, |
---|
| CharUnits BytePos, bool &HasUnion, | | CharUnits BytePos, bool &HasUnion, |
---|
| bool ByrefLayout) { | | bool ByrefLayout) { |
---|
| bool IsUnion = (RD && RD->isUnion()); | | bool IsUnion = (RD && RD->isUnion()); |
---|
@@ -2475,7 +2408,7 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, |
| // although this dependency is hidden. | | // although this dependency is hidden. |
---|
| const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD); | | const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD); |
---|
| CharUnits FieldOffset = | | CharUnits FieldOffset = |
---|
| - CGM.getContext().toCharUnitsFromBits(RL.getFieldOffset(i)); | | + CGM.getContext().toCharUnitsFromBits(RL.getFieldOffset(i)); |
---|
| | | |
---|
| // Skip over unnamed or bitfields | | // Skip over unnamed or bitfields |
---|
| if (!Field->getIdentifier() || Field->isBitField()) { | | if (!Field->getIdentifier() || Field->isBitField()) { |
---|
@@ -2513,13 +2446,14 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, |
| // Replicate layout information for each array element. Note that | | // Replicate layout information for each array element. Note that |
---|
| // one element is already done. | | // one element is already done. |
---|
| uint64_t ElIx = 1; | | uint64_t ElIx = 1; |
---|
| - for (int FirstIndex = RunSkipBlockVars.size() - 1 ;ElIx < ElCount; ElIx++) { | | + for (int FirstIndex = RunSkipBlockVars.size() - 1; ElIx < ElCount; |
---|
| | | + ElIx++) { |
---|
| CharUnits Size = CGM.getContext().getTypeSizeInChars(RT); | | CharUnits Size = CGM.getContext().getTypeSizeInChars(RT); |
---|
| - for (int i = OldIndex+1; i <= FirstIndex; ++i) | | + for (int i = OldIndex + 1; i <= FirstIndex; ++i) |
---|
| RunSkipBlockVars.push_back( | | RunSkipBlockVars.push_back( |
---|
| - RUN_SKIP(RunSkipBlockVars[i].opcode, | | + RUN_SKIP(RunSkipBlockVars[i].opcode, |
---|
| - RunSkipBlockVars[i].block_var_bytepos + Size*ElIx, | | + RunSkipBlockVars[i].block_var_bytepos + Size * ElIx, |
---|
| - RunSkipBlockVars[i].block_var_size)); | | + RunSkipBlockVars[i].block_var_size)); |
---|
| } | | } |
---|
| continue; | | continue; |
---|
| } | | } |
---|
@@ -2533,10 +2467,8 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, |
| MaxFieldOffset = FieldOffset; | | MaxFieldOffset = FieldOffset; |
---|
| } | | } |
---|
| } else { | | } else { |
---|
| - UpdateRunSkipBlockVars(false, | | + UpdateRunSkipBlockVars(false, getBlockCaptureLifetime(FQT, ByrefLayout), |
---|
| - getBlockCaptureLifetime(FQT, ByrefLayout), | | + BytePos + FieldOffset, FieldSize); |
---|
| - BytePos + FieldOffset, | | |
---|
| - FieldSize); | | |
---|
| } | | } |
---|
| } | | } |
---|
| | | |
---|
@@ -2545,32 +2477,32 @@ void CGObjCCommonMac::BuildRCRecordLayout(const llvm::StructLayout *RecLayout, |
| // Last field was a bitfield. Must update the info. | | // Last field was a bitfield. Must update the info. |
---|
| uint64_t BitFieldSize = LastFieldBitfieldOrUnnamed->getBitWidthValue(); | | uint64_t BitFieldSize = LastFieldBitfieldOrUnnamed->getBitWidthValue(); |
---|
| unsigned UnsSize = (BitFieldSize / ByteSizeInBits) + | | unsigned UnsSize = (BitFieldSize / ByteSizeInBits) + |
---|
| - ((BitFieldSize % ByteSizeInBits) != 0); | | + ((BitFieldSize % ByteSizeInBits) != 0); |
---|
| CharUnits Size = CharUnits::fromQuantity(UnsSize); | | CharUnits Size = CharUnits::fromQuantity(UnsSize); |
---|
| Size += LastBitfieldOrUnnamedOffset; | | Size += LastBitfieldOrUnnamedOffset; |
---|
| - UpdateRunSkipBlockVars(false, | | + UpdateRunSkipBlockVars( |
---|
| - getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(), | | + false, |
---|
| - ByrefLayout), | | + getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(), |
---|
| - BytePos + LastBitfieldOrUnnamedOffset, | | + ByrefLayout), |
---|
| - Size); | | + BytePos + LastBitfieldOrUnnamedOffset, Size); |
---|
| } else { | | } else { |
---|
| - assert(!LastFieldBitfieldOrUnnamed->getIdentifier() &&"Expected unnamed"); | | + assert(!LastFieldBitfieldOrUnnamed->getIdentifier() && |
---|
| | | + "Expected unnamed"); |
---|
| // Last field was unnamed. Must update skip info. | | // Last field was unnamed. Must update skip info. |
---|
| - CharUnits FieldSize | | + CharUnits FieldSize = CGM.getContext().getTypeSizeInChars( |
---|
| - = CGM.getContext().getTypeSizeInChars(LastFieldBitfieldOrUnnamed->getType()); | | + LastFieldBitfieldOrUnnamed->getType()); |
---|
| - UpdateRunSkipBlockVars(false, | | + UpdateRunSkipBlockVars( |
---|
| - getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(), | | + false, |
---|
| - ByrefLayout), | | + getBlockCaptureLifetime(LastFieldBitfieldOrUnnamed->getType(), |
---|
| - BytePos + LastBitfieldOrUnnamedOffset, | | + ByrefLayout), |
---|
| - FieldSize); | | + BytePos + LastBitfieldOrUnnamedOffset, FieldSize); |
---|
| } | | } |
---|
| } | | } |
---|
| | | |
---|
| if (MaxField) | | if (MaxField) |
---|
| - UpdateRunSkipBlockVars(false, | | + UpdateRunSkipBlockVars( |
---|
| - getBlockCaptureLifetime(MaxField->getType(), ByrefLayout), | | + false, getBlockCaptureLifetime(MaxField->getType(), ByrefLayout), |
---|
| - BytePos + MaxFieldOffset, | | + BytePos + MaxFieldOffset, MaxUnionSize); |
---|
| - MaxUnionSize); | | |
---|
| } | | } |
---|
| | | |
---|
| void CGObjCCommonMac::BuildRCBlockVarRecordLayout(const RecordType *RT, | | void CGObjCCommonMac::BuildRCBlockVarRecordLayout(const RecordType *RT, |
---|
@@ -2578,105 +2510,104 @@ void CGObjCCommonMac::BuildRCBlockVarRecordLayout(const RecordType *RT, |
| bool &HasUnion, | | bool &HasUnion, |
---|
| bool ByrefLayout) { | | bool ByrefLayout) { |
---|
| const RecordDecl *RD = RT->getDecl(); | | const RecordDecl *RD = RT->getDecl(); |
---|
| - SmallVector<const FieldDecl*, 16> Fields(RD->fields()); | | + SmallVector<const FieldDecl *, 16> Fields(RD->fields()); |
---|
| llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0)); | | llvm::Type *Ty = CGM.getTypes().ConvertType(QualType(RT, 0)); |
---|
| const llvm::StructLayout *RecLayout = | | const llvm::StructLayout *RecLayout = |
---|
| - CGM.getDataLayout().getStructLayout(cast<llvm::StructType>(Ty)); | | + CGM.getDataLayout().getStructLayout(cast<llvm::StructType>(Ty)); |
---|
| | | |
---|
| BuildRCRecordLayout(RecLayout, RD, Fields, BytePos, HasUnion, ByrefLayout); | | BuildRCRecordLayout(RecLayout, RD, Fields, BytePos, HasUnion, ByrefLayout); |
---|
| } | | } |
---|
| | | |
---|
| /// InlineLayoutInstruction - This routine produce an inline instruction for the | | /// InlineLayoutInstruction - This routine produce an inline instruction for the |
---|
| /// block variable layout if it can. If not, it returns 0. Rules are as follow: | | /// block variable layout if it can. If not, it returns 0. Rules are as follow: |
---|
| -/// If ((uintptr_t) layout) < (1 << 12), the layout is inline. In the 64bit world, | | +/// If ((uintptr_t) layout) < (1 << 12), the layout is inline. In the 64bit |
---|
| -/// an inline layout of value 0x0000000000000xyz is interpreted as follows: | | +/// world, an inline layout of value 0x0000000000000xyz is interpreted as |
---|
| -/// x captured object pointers of BLOCK_LAYOUT_STRONG. Followed by | | +/// follows: x captured object pointers of BLOCK_LAYOUT_STRONG. Followed by y |
---|
| -/// y captured object of BLOCK_LAYOUT_BYREF. Followed by | | +/// captured object of BLOCK_LAYOUT_BYREF. Followed by z captured object of |
---|
| -/// z captured object of BLOCK_LAYOUT_WEAK. If any of the above is missing, zero | | +/// BLOCK_LAYOUT_WEAK. If any of the above is missing, zero replaces it. For |
---|
| -/// replaces it. For example, 0x00000x00 means x BLOCK_LAYOUT_STRONG and no | | +/// example, 0x00000x00 means x BLOCK_LAYOUT_STRONG and no BLOCK_LAYOUT_BYREF |
---|
| -/// BLOCK_LAYOUT_BYREF and no BLOCK_LAYOUT_WEAK objects are captured. | | +/// and no BLOCK_LAYOUT_WEAK objects are captured. |
---|
| uint64_t CGObjCCommonMac::InlineLayoutInstruction( | | uint64_t CGObjCCommonMac::InlineLayoutInstruction( |
---|
| - SmallVectorImpl<unsigned char> &Layout) { | | + SmallVectorImpl<unsigned char> &Layout) { |
---|
| uint64_t Result = 0; | | uint64_t Result = 0; |
---|
| if (Layout.size() <= 3) { | | if (Layout.size() <= 3) { |
---|
| unsigned size = Layout.size(); | | unsigned size = Layout.size(); |
---|
| - unsigned strong_word_count = 0, byref_word_count=0, weak_word_count=0; | | + unsigned strong_word_count = 0, byref_word_count = 0, weak_word_count = 0; |
---|
| unsigned char inst; | | unsigned char inst; |
---|
| - enum BLOCK_LAYOUT_OPCODE opcode ; | | + enum BLOCK_LAYOUT_OPCODE opcode; |
---|
| switch (size) { | | switch (size) { |
---|
| - case 3: | | + case 3: |
---|
| - inst = Layout[0]; | | + inst = Layout[0]; |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| - if (opcode == BLOCK_LAYOUT_STRONG) | | + if (opcode == BLOCK_LAYOUT_STRONG) |
---|
| - strong_word_count = (inst & 0xF)+1; | | + strong_word_count = (inst & 0xF) + 1; |
---|
| - else | | + else |
---|
| - return 0; | | + return 0; |
---|
| | | + inst = Layout[1]; |
---|
| | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| | | + if (opcode == BLOCK_LAYOUT_BYREF) |
---|
| | | + byref_word_count = (inst & 0xF) + 1; |
---|
| | | + else |
---|
| | | + return 0; |
---|
| | | + inst = Layout[2]; |
---|
| | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| | | + if (opcode == BLOCK_LAYOUT_WEAK) |
---|
| | | + weak_word_count = (inst & 0xF) + 1; |
---|
| | | + else |
---|
| | | + return 0; |
---|
| | | + break; |
---|
| | | + |
---|
| | | + case 2: |
---|
| | | + inst = Layout[0]; |
---|
| | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| | | + if (opcode == BLOCK_LAYOUT_STRONG) { |
---|
| | | + strong_word_count = (inst & 0xF) + 1; |
---|
| inst = Layout[1]; | | inst = Layout[1]; |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| if (opcode == BLOCK_LAYOUT_BYREF) | | if (opcode == BLOCK_LAYOUT_BYREF) |
---|
| - byref_word_count = (inst & 0xF)+1; | | + byref_word_count = (inst & 0xF) + 1; |
---|
| | | + else if (opcode == BLOCK_LAYOUT_WEAK) |
---|
| | | + weak_word_count = (inst & 0xF) + 1; |
---|
| else | | else |
---|
| return 0; | | return 0; |
---|
| - inst = Layout[2]; | | + } else if (opcode == BLOCK_LAYOUT_BYREF) { |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | + byref_word_count = (inst & 0xF) + 1; |
---|
| | | + inst = Layout[1]; |
---|
| | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| if (opcode == BLOCK_LAYOUT_WEAK) | | if (opcode == BLOCK_LAYOUT_WEAK) |
---|
| - weak_word_count = (inst & 0xF)+1; | | + weak_word_count = (inst & 0xF) + 1; |
---|
| - else | | |
---|
| - return 0; | | |
---|
| - break; | | |
---|
| - | | |
---|
| - case 2: | | |
---|
| - inst = Layout[0]; | | |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | |
---|
| - if (opcode == BLOCK_LAYOUT_STRONG) { | | |
---|
| - strong_word_count = (inst & 0xF)+1; | | |
---|
| - inst = Layout[1]; | | |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | |
---|
| - if (opcode == BLOCK_LAYOUT_BYREF) | | |
---|
| - byref_word_count = (inst & 0xF)+1; | | |
---|
| - else if (opcode == BLOCK_LAYOUT_WEAK) | | |
---|
| - weak_word_count = (inst & 0xF)+1; | | |
---|
| - else | | |
---|
| - return 0; | | |
---|
| - } | | |
---|
| - else if (opcode == BLOCK_LAYOUT_BYREF) { | | |
---|
| - byref_word_count = (inst & 0xF)+1; | | |
---|
| - inst = Layout[1]; | | |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | |
---|
| - if (opcode == BLOCK_LAYOUT_WEAK) | | |
---|
| - weak_word_count = (inst & 0xF)+1; | | |
---|
| - else | | |
---|
| - return 0; | | |
---|
| - } | | |
---|
| - else | | |
---|
| - return 0; | | |
---|
| - break; | | |
---|
| - | | |
---|
| - case 1: | | |
---|
| - inst = Layout[0]; | | |
---|
| - opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | |
---|
| - if (opcode == BLOCK_LAYOUT_STRONG) | | |
---|
| - strong_word_count = (inst & 0xF)+1; | | |
---|
| - else if (opcode == BLOCK_LAYOUT_BYREF) | | |
---|
| - byref_word_count = (inst & 0xF)+1; | | |
---|
| - else if (opcode == BLOCK_LAYOUT_WEAK) | | |
---|
| - weak_word_count = (inst & 0xF)+1; | | |
---|
| else | | else |
---|
| return 0; | | return 0; |
---|
| - break; | | + } else |
---|
| | | + return 0; |
---|
| | | + break; |
---|
| | | |
---|
| - default: | | + case 1: |
---|
| | | + inst = Layout[0]; |
---|
| | | + opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| | | + if (opcode == BLOCK_LAYOUT_STRONG) |
---|
| | | + strong_word_count = (inst & 0xF) + 1; |
---|
| | | + else if (opcode == BLOCK_LAYOUT_BYREF) |
---|
| | | + byref_word_count = (inst & 0xF) + 1; |
---|
| | | + else if (opcode == BLOCK_LAYOUT_WEAK) |
---|
| | | + weak_word_count = (inst & 0xF) + 1; |
---|
| | | + else |
---|
| return 0; | | return 0; |
---|
| | | + break; |
---|
| | | + |
---|
| | | + default: |
---|
| | | + return 0; |
---|
| } | | } |
---|
| | | |
---|
| // Cannot inline when any of the word counts is 15. Because this is one less | | // Cannot inline when any of the word counts is 15. Because this is one less |
---|
| // than the actual work count (so 15 means 16 actual word counts), | | // than the actual work count (so 15 means 16 actual word counts), |
---|
| // and we can only display 0 thru 15 word counts. | | // and we can only display 0 thru 15 word counts. |
---|
| - if (strong_word_count == 16 || byref_word_count == 16 || weak_word_count == 16) | | + if (strong_word_count == 16 || byref_word_count == 16 || |
---|
| | | + weak_word_count == 16) |
---|
| return 0; | | return 0; |
---|
| | | |
---|
| - unsigned count = | | + unsigned count = (strong_word_count != 0) + (byref_word_count != 0) + |
---|
| - (strong_word_count != 0) + (byref_word_count != 0) + (weak_word_count != 0); | | + (weak_word_count != 0); |
---|
| | | |
---|
| if (size == count) { | | if (size == count) { |
---|
| if (strong_word_count) | | if (strong_word_count) |
---|
@@ -2698,7 +2629,7 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) { |
| return nullPtr; | | return nullPtr; |
---|
| unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default); | | unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default); |
---|
| unsigned ByteSizeInBits = CGM.getTarget().getCharWidth(); | | unsigned ByteSizeInBits = CGM.getTarget().getCharWidth(); |
---|
| - unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits; | | + unsigned WordSizeInBytes = WordSizeInBits / ByteSizeInBits; |
---|
| | | |
---|
| // Sort on byte position; captures might not be allocated in order, | | // Sort on byte position; captures might not be allocated in order, |
---|
| // and unions can do funny things. | | // and unions can do funny things. |
---|
@@ -2710,21 +2641,20 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) { |
| enum BLOCK_LAYOUT_OPCODE opcode = RunSkipBlockVars[i].opcode; | | enum BLOCK_LAYOUT_OPCODE opcode = RunSkipBlockVars[i].opcode; |
---|
| CharUnits start_byte_pos = RunSkipBlockVars[i].block_var_bytepos; | | CharUnits start_byte_pos = RunSkipBlockVars[i].block_var_bytepos; |
---|
| CharUnits end_byte_pos = start_byte_pos; | | CharUnits end_byte_pos = start_byte_pos; |
---|
| - unsigned j = i+1; | | + unsigned j = i + 1; |
---|
| while (j < size) { | | while (j < size) { |
---|
| if (opcode == RunSkipBlockVars[j].opcode) { | | if (opcode == RunSkipBlockVars[j].opcode) { |
---|
| end_byte_pos = RunSkipBlockVars[j++].block_var_bytepos; | | end_byte_pos = RunSkipBlockVars[j++].block_var_bytepos; |
---|
| i++; | | i++; |
---|
| - } | | + } else |
---|
| - else | | |
---|
| break; | | break; |
---|
| } | | } |
---|
| CharUnits size_in_bytes = | | CharUnits size_in_bytes = |
---|
| - end_byte_pos - start_byte_pos + RunSkipBlockVars[j-1].block_var_size; | | + end_byte_pos - start_byte_pos + RunSkipBlockVars[j - 1].block_var_size; |
---|
| if (j < size) { | | if (j < size) { |
---|
| - CharUnits gap = | | + CharUnits gap = RunSkipBlockVars[j].block_var_bytepos - |
---|
| - RunSkipBlockVars[j].block_var_bytepos - | | + RunSkipBlockVars[j - 1].block_var_bytepos - |
---|
| - RunSkipBlockVars[j-1].block_var_bytepos - RunSkipBlockVars[j-1].block_var_size; | | + RunSkipBlockVars[j - 1].block_var_size; |
---|
| size_in_bytes += gap; | | size_in_bytes += gap; |
---|
| } | | } |
---|
| CharUnits residue_in_bytes = CharUnits::Zero(); | | CharUnits residue_in_bytes = CharUnits::Zero(); |
---|
@@ -2745,20 +2675,21 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) { |
| if (size_in_words > 0) { | | if (size_in_words > 0) { |
---|
| // Note that value in imm. is one less that the actual | | // Note that value in imm. is one less that the actual |
---|
| // value. So, we subtract 1 away! | | // value. So, we subtract 1 away! |
---|
| - unsigned char inst = (opcode << 4) | (size_in_words-1); | | + unsigned char inst = (opcode << 4) | (size_in_words - 1); |
---|
| Layout.push_back(inst); | | Layout.push_back(inst); |
---|
| } | | } |
---|
| if (residue_in_bytes > CharUnits::Zero()) { | | if (residue_in_bytes > CharUnits::Zero()) { |
---|
| - unsigned char inst = | | + unsigned char inst = (BLOCK_LAYOUT_NON_OBJECT_BYTES << 4) | |
---|
| - (BLOCK_LAYOUT_NON_OBJECT_BYTES << 4) | (residue_in_bytes.getQuantity()-1); | | + (residue_in_bytes.getQuantity() - 1); |
---|
| Layout.push_back(inst); | | Layout.push_back(inst); |
---|
| } | | } |
---|
| } | | } |
---|
| | | |
---|
| while (!Layout.empty()) { | | while (!Layout.empty()) { |
---|
| unsigned char inst = Layout.back(); | | unsigned char inst = Layout.back(); |
---|
| - enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | + enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| - if (opcode == BLOCK_LAYOUT_NON_OBJECT_BYTES || opcode == BLOCK_LAYOUT_NON_OBJECT_WORDS) | | + if (opcode == BLOCK_LAYOUT_NON_OBJECT_BYTES || |
---|
| | | + opcode == BLOCK_LAYOUT_NON_OBJECT_WORDS) |
---|
| Layout.pop_back(); | | Layout.pop_back(); |
---|
| else | | else |
---|
| break; | | break; |
---|
@@ -2774,11 +2705,11 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) { |
| printf("\n Inline block variable layout: "); | | printf("\n Inline block variable layout: "); |
---|
| printf("0x0%" PRIx64 "", Result); | | printf("0x0%" PRIx64 "", Result); |
---|
| if (auto numStrong = (Result & 0xF00) >> 8) | | if (auto numStrong = (Result & 0xF00) >> 8) |
---|
| - printf(", BL_STRONG:%d", (int) numStrong); | | + printf(", BL_STRONG:%d", (int)numStrong); |
---|
| if (auto numByref = (Result & 0x0F0) >> 4) | | if (auto numByref = (Result & 0x0F0) >> 4) |
---|
| - printf(", BL_BYREF:%d", (int) numByref); | | + printf(", BL_BYREF:%d", (int)numByref); |
---|
| if (auto numWeak = (Result & 0x00F) >> 0) | | if (auto numWeak = (Result & 0x00F) >> 0) |
---|
| - printf(", BL_WEAK:%d", (int) numWeak); | | + printf(", BL_WEAK:%d", (int)numWeak); |
---|
| printf(", BL_OPERATOR:0\n"); | | printf(", BL_OPERATOR:0\n"); |
---|
| } | | } |
---|
| return llvm::ConstantInt::get(CGM.IntPtrTy, Result); | | return llvm::ConstantInt::get(CGM.IntPtrTy, Result); |
---|
@@ -2797,36 +2728,36 @@ llvm::Constant *CGObjCCommonMac::getBitmapBlockLayout(bool ComputeByrefLayout) { |
| printf("\n Block variable layout: "); | | printf("\n Block variable layout: "); |
---|
| for (unsigned i = 0, e = BitMap.size(); i != e; i++) { | | for (unsigned i = 0, e = BitMap.size(); i != e; i++) { |
---|
| unsigned char inst = BitMap[i]; | | unsigned char inst = BitMap[i]; |
---|
| - enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE) (inst >> 4); | | + enum BLOCK_LAYOUT_OPCODE opcode = (enum BLOCK_LAYOUT_OPCODE)(inst >> 4); |
---|
| unsigned delta = 1; | | unsigned delta = 1; |
---|
| switch (opcode) { | | switch (opcode) { |
---|
| - case BLOCK_LAYOUT_OPERATOR: | | + case BLOCK_LAYOUT_OPERATOR: |
---|
| - printf("BL_OPERATOR:"); | | + printf("BL_OPERATOR:"); |
---|
| - delta = 0; | | + delta = 0; |
---|
| - break; | | + break; |
---|
| - case BLOCK_LAYOUT_NON_OBJECT_BYTES: | | + case BLOCK_LAYOUT_NON_OBJECT_BYTES: |
---|
| - printf("BL_NON_OBJECT_BYTES:"); | | + printf("BL_NON_OBJECT_BYTES:"); |
---|
| - break; | | + break; |
---|
| - case BLOCK_LAYOUT_NON_OBJECT_WORDS: | | + case BLOCK_LAYOUT_NON_OBJECT_WORDS: |
---|
| - printf("BL_NON_OBJECT_WORD:"); | | + printf("BL_NON_OBJECT_WORD:"); |
---|
| - break; | | + break; |
---|
| - case BLOCK_LAYOUT_STRONG: | | + case BLOCK_LAYOUT_STRONG: |
---|
| - printf("BL_STRONG:"); | | + printf("BL_STRONG:"); |
---|
| - break; | | + break; |
---|
| - case BLOCK_LAYOUT_BYREF: | | + case BLOCK_LAYOUT_BYREF: |
---|
| - printf("BL_BYREF:"); | | + printf("BL_BYREF:"); |
---|
| - break; | | + break; |
---|
| - case BLOCK_LAYOUT_WEAK: | | + case BLOCK_LAYOUT_WEAK: |
---|
| - printf("BL_WEAK:"); | | + printf("BL_WEAK:"); |
---|
| - break; | | + break; |
---|
| - case BLOCK_LAYOUT_UNRETAINED: | | + case BLOCK_LAYOUT_UNRETAINED: |
---|
| - printf("BL_UNRETAINED:"); | | + printf("BL_UNRETAINED:"); |
---|
| - break; | | + break; |
---|
| } | | } |
---|
| // Actual value of word count is one more that what is in the imm. | | // Actual value of word count is one more that what is in the imm. |
---|
| // field of the instruction | | // field of the instruction |
---|
| printf("%d", (inst & 0xf) + delta); | | printf("%d", (inst & 0xf) + delta); |
---|
| - if (i < e-1) | | + if (i < e - 1) |
---|
| printf(", "); | | printf(", "); |
---|
| else | | else |
---|
| printf("\n"); | | printf("\n"); |
---|
@@ -2884,13 +2815,13 @@ void CGObjCCommonMac::fillRunSkipBlockVars(CodeGenModule &CGM, |
| | | |
---|
| unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default); | | unsigned WordSizeInBits = CGM.getTarget().getPointerWidth(LangAS::Default); |
---|
| unsigned ByteSizeInBits = CGM.getTarget().getCharWidth(); | | unsigned ByteSizeInBits = CGM.getTarget().getCharWidth(); |
---|
| - unsigned WordSizeInBytes = WordSizeInBits/ByteSizeInBits; | | + unsigned WordSizeInBytes = WordSizeInBits / ByteSizeInBits; |
---|
| | | |
---|
| const BlockDecl *blockDecl = blockInfo.getBlockDecl(); | | const BlockDecl *blockDecl = blockInfo.getBlockDecl(); |
---|
| | | |
---|
| // Calculate the basic layout of the block structure. | | // Calculate the basic layout of the block structure. |
---|
| const llvm::StructLayout *layout = | | const llvm::StructLayout *layout = |
---|
| - CGM.getDataLayout().getStructLayout(blockInfo.StructureType); | | + CGM.getDataLayout().getStructLayout(blockInfo.StructureType); |
---|
| | | |
---|
| // Ignore the optional 'this' capture: C++ objects are not assumed | | // Ignore the optional 'this' capture: C++ objects are not assumed |
---|
| // to be GC'ed. | | // to be GC'ed. |
---|
@@ -2906,10 +2837,11 @@ void CGObjCCommonMac::fillRunSkipBlockVars(CodeGenModule &CGM, |
| const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable); | | const CGBlockInfo::Capture &capture = blockInfo.getCapture(variable); |
---|
| | | |
---|
| // Ignore constant captures. | | // Ignore constant captures. |
---|
| - if (capture.isConstant()) continue; | | + if (capture.isConstant()) |
---|
| | | + continue; |
---|
| | | |
---|
| CharUnits fieldOffset = | | CharUnits fieldOffset = |
---|
| - CharUnits::fromQuantity(layout->getElementOffset(capture.getIndex())); | | + CharUnits::fromQuantity(layout->getElementOffset(capture.getIndex())); |
---|
| | | |
---|
| assert(!type->isArrayType() && "array variable should not be caught"); | | assert(!type->isArrayType() && "array variable should not be caught"); |
---|
| if (!CI.isByRef()) | | if (!CI.isByRef()) |
---|
@@ -2948,7 +2880,8 @@ llvm::Constant *CGObjCCommonMac::BuildByrefLayout(CodeGen::CodeGenModule &CGM, |
| RunSkipBlockVars.clear(); | | RunSkipBlockVars.clear(); |
---|
| bool hasUnion = false; | | bool hasUnion = false; |
---|
| if (const RecordType *record = T->getAs<RecordType>()) { | | if (const RecordType *record = T->getAs<RecordType>()) { |
---|
| - BuildRCBlockVarRecordLayout(record, fieldOffset, hasUnion, true /*ByrefLayout */); | | + BuildRCBlockVarRecordLayout(record, fieldOffset, hasUnion, |
---|
| | | + true /*ByrefLayout */); |
---|
| llvm::Constant *Result = getBitmapBlockLayout(true); | | llvm::Constant *Result = getBitmapBlockLayout(true); |
---|
| if (isa<llvm::ConstantInt>(Result)) | | if (isa<llvm::ConstantInt>(Result)) |
---|
| Result = llvm::ConstantExpr::getIntToPtr(Result, CGM.Int8PtrTy); | | Result = llvm::ConstantExpr::getIntToPtr(Result, CGM.Int8PtrTy); |
---|
@@ -2986,10 +2919,10 @@ llvm::Constant *CGObjCCommonMac::GetProtocolRef(const ObjCProtocolDecl *PD) { |
| return GetOrEmitProtocolRef(PD); | | return GetOrEmitProtocolRef(PD); |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Value *CGObjCCommonMac::EmitClassRefViaRuntime( | | +llvm::Value * |
---|
| - CodeGenFunction &CGF, | | +CGObjCCommonMac::EmitClassRefViaRuntime(CodeGenFunction &CGF, |
---|
| - const ObjCInterfaceDecl *ID, | | + const ObjCInterfaceDecl *ID, |
---|
| - ObjCCommonTypesHelper &ObjCTypes) { | | + ObjCCommonTypesHelper &ObjCTypes) { |
---|
| llvm::FunctionCallee lookUpClassFn = ObjCTypes.getLookUpClassFn(); | | llvm::FunctionCallee lookUpClassFn = ObjCTypes.getLookUpClassFn(); |
---|
| | | |
---|
| llvm::Value *className = CGF.CGM | | llvm::Value *className = CGF.CGM |
---|
@@ -2997,10 +2930,8 @@ llvm::Value *CGObjCCommonMac::EmitClassRefViaRuntime( |
| ID->getObjCRuntimeNameAsString())) | | ID->getObjCRuntimeNameAsString())) |
---|
| .getPointer(); | | .getPointer(); |
---|
| ASTContext &ctx = CGF.CGM.getContext(); | | ASTContext &ctx = CGF.CGM.getContext(); |
---|
| - className = | | + className = CGF.Builder.CreateBitCast( |
---|
| - CGF.Builder.CreateBitCast(className, | | + className, CGF.ConvertType(ctx.getPointerType(ctx.CharTy.withConst()))); |
---|
| - CGF.ConvertType( | | |
---|
| - ctx.getPointerType(ctx.CharTy.withConst()))); | | |
---|
| llvm::CallInst *call = CGF.Builder.CreateCall(lookUpClassFn, className); | | llvm::CallInst *call = CGF.Builder.CreateCall(lookUpClassFn, className); |
---|
| call->setDoesNotThrow(); | | call->setDoesNotThrow(); |
---|
| return call; | | return call; |
---|
@@ -3042,20 +2973,19 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) { |
| values.add(GetClassName(PD->getObjCRuntimeNameAsString())); | | values.add(GetClassName(PD->getObjCRuntimeNameAsString())); |
---|
| values.add(EmitProtocolList("OBJC_PROTOCOL_REFS_" + PD->getName(), | | values.add(EmitProtocolList("OBJC_PROTOCOL_REFS_" + PD->getName(), |
---|
| PD->protocol_begin(), PD->protocol_end())); | | PD->protocol_begin(), PD->protocol_end())); |
---|
| - values.add(methodLists.emitMethodList(this, PD, | | + values.add(methodLists.emitMethodList( |
---|
| - ProtocolMethodLists::RequiredInstanceMethods)); | | + this, PD, ProtocolMethodLists::RequiredInstanceMethods)); |
---|
| - values.add(methodLists.emitMethodList(this, PD, | | + values.add(methodLists.emitMethodList( |
---|
| - ProtocolMethodLists::RequiredClassMethods)); | | + this, PD, ProtocolMethodLists::RequiredClassMethods)); |
---|
| | | |
---|
| if (Entry) { | | if (Entry) { |
---|
| // Already created, update the initializer. | | // Already created, update the initializer. |
---|
| assert(Entry->hasPrivateLinkage()); | | assert(Entry->hasPrivateLinkage()); |
---|
| values.finishAndSetAsInitializer(Entry); | | values.finishAndSetAsInitializer(Entry); |
---|
| } else { | | } else { |
---|
| - Entry = values.finishAndCreateGlobal("OBJC_PROTOCOL_" + PD->getName(), | | + Entry = values.finishAndCreateGlobal( |
---|
| - CGM.getPointerAlign(), | | + "OBJC_PROTOCOL_" + PD->getName(), CGM.getPointerAlign(), |
---|
| - /*constant*/ false, | | + /*constant*/ false, llvm::GlobalValue::PrivateLinkage); |
---|
| - llvm::GlobalValue::PrivateLinkage); | | |
---|
| Entry->setSection("__OBJC,__protocol,regular,no_dead_strip"); | | Entry->setSection("__OBJC,__protocol,regular,no_dead_strip"); |
---|
| | | |
---|
| Protocols[PD->getIdentifier()] = Entry; | | Protocols[PD->getIdentifier()] = Entry; |
---|
@@ -3096,36 +3026,30 @@ llvm::Constant *CGObjCMac::GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) { |
| llvm::Constant * | | llvm::Constant * |
---|
| CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD, | | CGObjCMac::EmitProtocolExtension(const ObjCProtocolDecl *PD, |
---|
| const ProtocolMethodLists &methodLists) { | | const ProtocolMethodLists &methodLists) { |
---|
| - auto optInstanceMethods = | | + auto optInstanceMethods = methodLists.emitMethodList( |
---|
| - methodLists.emitMethodList(this, PD, | | + this, PD, ProtocolMethodLists::OptionalInstanceMethods); |
---|
| - ProtocolMethodLists::OptionalInstanceMethods); | | + auto optClassMethods = methodLists.emitMethodList( |
---|
| - auto optClassMethods = | | + this, PD, ProtocolMethodLists::OptionalClassMethods); |
---|
| - methodLists.emitMethodList(this, PD, | | + |
---|
| - ProtocolMethodLists::OptionalClassMethods); | | + auto extendedMethodTypes = EmitProtocolMethodTypes( |
---|
| - | | + "OBJC_PROTOCOL_METHOD_TYPES_" + PD->getName(), |
---|
| - auto extendedMethodTypes = | | + methodLists.emitExtendedTypesArray(this), ObjCTypes); |
---|
| - EmitProtocolMethodTypes("OBJC_PROTOCOL_METHOD_TYPES_" + PD->getName(), | | + |
---|
| - methodLists.emitExtendedTypesArray(this), | | + auto instanceProperties = EmitPropertyList( |
---|
| - ObjCTypes); | | + "OBJC_$_PROP_PROTO_LIST_" + PD->getName(), nullptr, PD, ObjCTypes, false); |
---|
| - | | |
---|
| - auto instanceProperties = | | |
---|
| - EmitPropertyList("OBJC_$_PROP_PROTO_LIST_" + PD->getName(), nullptr, PD, | | |
---|
| - ObjCTypes, false); | | |
---|
| auto classProperties = | | auto classProperties = |
---|
| - EmitPropertyList("OBJC_$_CLASS_PROP_PROTO_LIST_" + PD->getName(), nullptr, | | + EmitPropertyList("OBJC_$_CLASS_PROP_PROTO_LIST_" + PD->getName(), nullptr, |
---|
| - PD, ObjCTypes, true); | | + PD, ObjCTypes, true); |
---|
| | | |
---|
| // Return null if no extension bits are used. | | // Return null if no extension bits are used. |
---|
| - if (optInstanceMethods->isNullValue() && | | + if (optInstanceMethods->isNullValue() && optClassMethods->isNullValue() && |
---|
| - optClassMethods->isNullValue() && | | + extendedMethodTypes->isNullValue() && instanceProperties->isNullValue() && |
---|
| - extendedMethodTypes->isNullValue() && | | |
---|
| - instanceProperties->isNullValue() && | | |
---|
| classProperties->isNullValue()) { | | classProperties->isNullValue()) { |
---|
| return llvm::Constant::getNullValue(ObjCTypes.ProtocolExtensionPtrTy); | | return llvm::Constant::getNullValue(ObjCTypes.ProtocolExtensionPtrTy); |
---|
| } | | } |
---|
| | | |
---|
| uint64_t size = | | uint64_t size = |
---|
| - CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolExtensionTy); | | + CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolExtensionTy); |
---|
| | | |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto values = builder.beginStruct(ObjCTypes.ProtocolExtensionTy); | | auto values = builder.beginStruct(ObjCTypes.ProtocolExtensionTy); |
---|
@@ -3187,11 +3111,10 @@ CGObjCMac::EmitProtocolList(Twine name, |
| return GV; | | return GV; |
---|
| } | | } |
---|
| | | |
---|
| -static void | | +static void PushProtocolProperties( |
---|
| -PushProtocolProperties(llvm::SmallPtrSet<const IdentifierInfo*,16> &PropertySet, | | + llvm::SmallPtrSet<const IdentifierInfo *, 16> &PropertySet, |
---|
| - SmallVectorImpl<const ObjCPropertyDecl *> &Properties, | | + SmallVectorImpl<const ObjCPropertyDecl *> &Properties, |
---|
| - const ObjCProtocolDecl *Proto, | | + const ObjCProtocolDecl *Proto, bool IsClassProperty) { |
---|
| - bool IsClassProperty) { | | |
---|
| for (const auto *PD : Proto->properties()) { | | for (const auto *PD : Proto->properties()) { |
---|
| if (IsClassProperty != PD->isClassProperty()) | | if (IsClassProperty != PD->isClassProperty()) |
---|
| continue; | | continue; |
---|
@@ -3216,11 +3139,9 @@ PushProtocolProperties(llvm::SmallPtrSet<const IdentifierInfo*,16> &PropertySet, |
| struct _objc_property[prop_count]; | | struct _objc_property[prop_count]; |
---|
| }; | | }; |
---|
| */ | | */ |
---|
| -llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, | | +llvm::Constant *CGObjCCommonMac::EmitPropertyList( |
---|
| - const Decl *Container, | | + Twine Name, const Decl *Container, const ObjCContainerDecl *OCD, |
---|
| - const ObjCContainerDecl *OCD, | | + const ObjCCommonTypesHelper &ObjCTypes, bool IsClassProperty) { |
---|
| - const ObjCCommonTypesHelper &ObjCTypes, | | |
---|
| - bool IsClassProperty) { | | |
---|
| if (IsClassProperty) { | | if (IsClassProperty) { |
---|
| // Make this entry NULL for OS X with deployment target < 10.11, for iOS | | // Make this entry NULL for OS X with deployment target < 10.11, for iOS |
---|
| // with deployment target < 9.0. | | // with deployment target < 9.0. |
---|
@@ -3231,7 +3152,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, |
| } | | } |
---|
| | | |
---|
| SmallVector<const ObjCPropertyDecl *, 16> Properties; | | SmallVector<const ObjCPropertyDecl *, 16> Properties; |
---|
| - llvm::SmallPtrSet<const IdentifierInfo*, 16> PropertySet; | | + llvm::SmallPtrSet<const IdentifierInfo *, 16> PropertySet; |
---|
| | | |
---|
| if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) | | if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) |
---|
| for (const ObjCCategoryDecl *ClassExt : OID->known_extensions()) | | for (const ObjCCategoryDecl *ClassExt : OID->known_extensions()) |
---|
@@ -3259,8 +3180,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, |
| if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) { | | if (const ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(OCD)) { |
---|
| for (const auto *P : OID->all_referenced_protocols()) | | for (const auto *P : OID->all_referenced_protocols()) |
---|
| PushProtocolProperties(PropertySet, Properties, P, IsClassProperty); | | PushProtocolProperties(PropertySet, Properties, P, IsClassProperty); |
---|
| - } | | + } else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(OCD)) { |
---|
| - else if (const ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(OCD)) { | | |
---|
| for (const auto *P : CD->protocols()) | | for (const auto *P : CD->protocols()) |
---|
| PushProtocolProperties(PropertySet, Properties, P, IsClassProperty); | | PushProtocolProperties(PropertySet, Properties, P, IsClassProperty); |
---|
| } | | } |
---|
@@ -3270,7 +3190,7 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, |
| return llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); | | return llvm::Constant::getNullValue(ObjCTypes.PropertyListPtrTy); |
---|
| | | |
---|
| unsigned propertySize = | | unsigned propertySize = |
---|
| - CGM.getDataLayout().getTypeAllocSize(ObjCTypes.PropertyTy); | | + CGM.getDataLayout().getTypeAllocSize(ObjCTypes.PropertyTy); |
---|
| | | |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto values = builder.beginStruct(); | | auto values = builder.beginStruct(); |
---|
@@ -3295,16 +3215,15 @@ llvm::Constant *CGObjCCommonMac::EmitPropertyList(Twine Name, |
| return GV; | | return GV; |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Constant * | | +llvm::Constant *CGObjCCommonMac::EmitProtocolMethodTypes( |
---|
| -CGObjCCommonMac::EmitProtocolMethodTypes(Twine Name, | | + Twine Name, ArrayRef<llvm::Constant *> MethodTypes, |
---|
| - ArrayRef<llvm::Constant*> MethodTypes, | | + const ObjCCommonTypesHelper &ObjCTypes) { |
---|
| - const ObjCCommonTypesHelper &ObjCTypes) { | | |
---|
| // Return null for empty list. | | // Return null for empty list. |
---|
| if (MethodTypes.empty()) | | if (MethodTypes.empty()) |
---|
| return llvm::Constant::getNullValue(ObjCTypes.Int8PtrPtrTy); | | return llvm::Constant::getNullValue(ObjCTypes.Int8PtrPtrTy); |
---|
| | | |
---|
| - llvm::ArrayType *AT = llvm::ArrayType::get(ObjCTypes.Int8PtrTy, | | + llvm::ArrayType *AT = |
---|
| - MethodTypes.size()); | | + llvm::ArrayType::get(ObjCTypes.Int8PtrTy, MethodTypes.size()); |
---|
| llvm::Constant *Init = llvm::ConstantArray::get(AT, MethodTypes); | | llvm::Constant *Init = llvm::ConstantArray::get(AT, MethodTypes); |
---|
| | | |
---|
| StringRef Section; | | StringRef Section; |
---|
@@ -3337,20 +3256,16 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) { |
| // @implementation so everyone else can live life under a clear blue sky. | | // @implementation so everyone else can live life under a clear blue sky. |
---|
| const ObjCInterfaceDecl *Interface = OCD->getClassInterface(); | | const ObjCInterfaceDecl *Interface = OCD->getClassInterface(); |
---|
| const ObjCCategoryDecl *Category = | | const ObjCCategoryDecl *Category = |
---|
| - Interface->FindCategoryDeclaration(OCD->getIdentifier()); | | + Interface->FindCategoryDeclaration(OCD->getIdentifier()); |
---|
| | | |
---|
| SmallString<256> ExtName; | | SmallString<256> ExtName; |
---|
| - llvm::raw_svector_ostream(ExtName) << Interface->getName() << '_' | | + llvm::raw_svector_ostream(ExtName) |
---|
| - << OCD->getName(); | | + << Interface->getName() << '_' << OCD->getName(); |
---|
| | | |
---|
| ConstantInitBuilder Builder(CGM); | | ConstantInitBuilder Builder(CGM); |
---|
| auto Values = Builder.beginStruct(ObjCTypes.CategoryTy); | | auto Values = Builder.beginStruct(ObjCTypes.CategoryTy); |
---|
| | | |
---|
| - enum { | | + enum { InstanceMethods, ClassMethods, NumMethodLists }; |
---|
| - InstanceMethods, | | |
---|
| - ClassMethods, | | |
---|
| - NumMethodLists | | |
---|
| - }; | | |
---|
| SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists]; | | SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists]; |
---|
| for (const auto *MD : OCD->methods()) { | | for (const auto *MD : OCD->methods()) { |
---|
| if (!MD->isDirectMethod()) | | if (!MD->isDirectMethod()) |
---|
@@ -3366,9 +3281,9 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) { |
| Values.add(emitMethodList(ExtName, MethodListType::CategoryClassMethods, | | Values.add(emitMethodList(ExtName, MethodListType::CategoryClassMethods, |
---|
| Methods[ClassMethods])); | | Methods[ClassMethods])); |
---|
| if (Category) { | | if (Category) { |
---|
| - Values.add( | | + Values.add(EmitProtocolList("OBJC_CATEGORY_PROTOCOLS_" + ExtName.str(), |
---|
| - EmitProtocolList("OBJC_CATEGORY_PROTOCOLS_" + ExtName.str(), | | + Category->protocol_begin(), |
---|
| - Category->protocol_begin(), Category->protocol_end())); | | + Category->protocol_end())); |
---|
| } else { | | } else { |
---|
| Values.addNullPointer(ObjCTypes.ProtocolListPtrTy); | | Values.addNullPointer(ObjCTypes.ProtocolListPtrTy); |
---|
| } | | } |
---|
@@ -3376,25 +3291,25 @@ void CGObjCMac::GenerateCategory(const ObjCCategoryImplDecl *OCD) { |
| | | |
---|
| // If there is no category @interface then there can be no properties. | | // If there is no category @interface then there can be no properties. |
---|
| if (Category) { | | if (Category) { |
---|
| - Values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" + ExtName.str(), | | + Values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" + ExtName.str(), OCD, |
---|
| - OCD, Category, ObjCTypes, false)); | | + Category, ObjCTypes, false)); |
---|
| - Values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + ExtName.str(), | | + Values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + ExtName.str(), OCD, |
---|
| - OCD, Category, ObjCTypes, true)); | | + Category, ObjCTypes, true)); |
---|
| } else { | | } else { |
---|
| Values.addNullPointer(ObjCTypes.PropertyListPtrTy); | | Values.addNullPointer(ObjCTypes.PropertyListPtrTy); |
---|
| Values.addNullPointer(ObjCTypes.PropertyListPtrTy); | | Values.addNullPointer(ObjCTypes.PropertyListPtrTy); |
---|
| } | | } |
---|
| | | |
---|
| - llvm::GlobalVariable *GV = | | + llvm::GlobalVariable *GV = CreateMetadataVar( |
---|
| - CreateMetadataVar("OBJC_CATEGORY_" + ExtName.str(), Values, | | + "OBJC_CATEGORY_" + ExtName.str(), Values, |
---|
| - "__OBJC,__category,regular,no_dead_strip", | | + "__OBJC,__category,regular,no_dead_strip", CGM.getPointerAlign(), true); |
---|
| - CGM.getPointerAlign(), true); | | |
---|
| DefinedCategories.push_back(GV); | | DefinedCategories.push_back(GV); |
---|
| DefinedCategoryNames.insert(llvm::CachedHashString(ExtName)); | | DefinedCategoryNames.insert(llvm::CachedHashString(ExtName)); |
---|
| // method definition entries must be clear for next implementation. | | // method definition entries must be clear for next implementation. |
---|
| MethodDefinitions.clear(); | | MethodDefinitions.clear(); |
---|
| } | | } |
---|
| | | |
---|
| | | +// clang-format off |
---|
| enum FragileClassFlags { | | enum FragileClassFlags { |
---|
| /// Apparently: is not a meta-class. | | /// Apparently: is not a meta-class. |
---|
| FragileABI_Class_Factory = 0x00001, | | FragileABI_Class_Factory = 0x00001, |
---|
@@ -3445,6 +3360,7 @@ enum NonFragileClassFlags { |
| /// Exclusive with CompiledByARC. | | /// Exclusive with CompiledByARC. |
---|
| NonFragileABI_Class_HasMRCWeakIvars = 0x00200, | | NonFragileABI_Class_HasMRCWeakIvars = 0x00200, |
---|
| }; | | }; |
---|
| | | +// clang-format on |
---|
| | | |
---|
| static bool hasWeakMember(QualType type) { | | static bool hasWeakMember(QualType type) { |
---|
| if (type.getObjCLifetime() == Qualifiers::OCL_Weak) { | | if (type.getObjCLifetime() == Qualifiers::OCL_Weak) { |
---|
@@ -3466,11 +3382,12 @@ static bool hasWeakMember(QualType type) { |
| /// __weak ivars. | | /// __weak ivars. |
---|
| static bool hasMRCWeakIvars(CodeGenModule &CGM, | | static bool hasMRCWeakIvars(CodeGenModule &CGM, |
---|
| const ObjCImplementationDecl *ID) { | | const ObjCImplementationDecl *ID) { |
---|
| - if (!CGM.getLangOpts().ObjCWeak) return false; | | + if (!CGM.getLangOpts().ObjCWeak) |
---|
| | | + return false; |
---|
| assert(CGM.getLangOpts().getGC() == LangOptions::NonGC); | | assert(CGM.getLangOpts().getGC() == LangOptions::NonGC); |
---|
| | | |
---|
| for (const ObjCIvarDecl *ivar = | | for (const ObjCIvarDecl *ivar = |
---|
| - ID->getClassInterface()->all_declared_ivar_begin(); | | + ID->getClassInterface()->all_declared_ivar_begin(); |
---|
| ivar; ivar = ivar->getNextIvar()) { | | ivar; ivar = ivar->getNextIvar()) { |
---|
| if (hasWeakMember(ivar->getType())) | | if (hasWeakMember(ivar->getType())) |
---|
| return true; | | return true; |
---|
@@ -3506,7 +3423,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| std::string ClassName = ID->getNameAsString(); | | std::string ClassName = ID->getNameAsString(); |
---|
| // FIXME: Gross | | // FIXME: Gross |
---|
| ObjCInterfaceDecl *Interface = | | ObjCInterfaceDecl *Interface = |
---|
| - const_cast<ObjCInterfaceDecl*>(ID->getClassInterface()); | | + const_cast<ObjCInterfaceDecl *>(ID->getClassInterface()); |
---|
| llvm::Constant *Protocols = | | llvm::Constant *Protocols = |
---|
| EmitProtocolList("OBJC_CLASS_PROTOCOLS_" + ID->getName(), | | EmitProtocolList("OBJC_CLASS_PROTOCOLS_" + ID->getName(), |
---|
| Interface->all_referenced_protocol_begin(), | | Interface->all_referenced_protocol_begin(), |
---|
@@ -3523,17 +3440,13 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| Flags |= FragileABI_Class_HasMRCWeakIvars; | | Flags |= FragileABI_Class_HasMRCWeakIvars; |
---|
| | | |
---|
| CharUnits Size = | | CharUnits Size = |
---|
| - CGM.getContext().getASTObjCImplementationLayout(ID).getSize(); | | + CGM.getContext().getASTObjCImplementationLayout(ID).getSize(); |
---|
| | | |
---|
| // FIXME: Set CXX-structors flag. | | // FIXME: Set CXX-structors flag. |
---|
| if (ID->getClassInterface()->getVisibility() == HiddenVisibility) | | if (ID->getClassInterface()->getVisibility() == HiddenVisibility) |
---|
| Flags |= FragileABI_Class_Hidden; | | Flags |= FragileABI_Class_Hidden; |
---|
| | | |
---|
| - enum { | | + enum { InstanceMethods, ClassMethods, NumMethodLists }; |
---|
| - InstanceMethods, | | |
---|
| - ClassMethods, | | |
---|
| - NumMethodLists | | |
---|
| - }; | | |
---|
| SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists]; | | SmallVector<const ObjCMethodDecl *, 16> Methods[NumMethodLists]; |
---|
| for (const auto *MD : ID->methods()) { | | for (const auto *MD : ID->methods()) { |
---|
| if (!MD->isDirectMethod()) | | if (!MD->isDirectMethod()) |
---|
@@ -3599,9 +3512,10 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| MethodDefinitions.clear(); | | MethodDefinitions.clear(); |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID, | | +llvm::Constant * |
---|
| - llvm::Constant *Protocols, | | +CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID, |
---|
| - ArrayRef<const ObjCMethodDecl*> Methods) { | | + llvm::Constant *Protocols, |
---|
| | | + ArrayRef<const ObjCMethodDecl *> Methods) { |
---|
| unsigned Flags = FragileABI_Class_Meta; | | unsigned Flags = FragileABI_Class_Meta; |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassTy); |
---|
| | | |
---|
@@ -3629,16 +3543,16 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID, |
| values.addInt(ObjCTypes.LongTy, Flags); | | values.addInt(ObjCTypes.LongTy, Flags); |
---|
| values.addInt(ObjCTypes.LongTy, Size); | | values.addInt(ObjCTypes.LongTy, Size); |
---|
| values.add(EmitIvarList(ID, true)); | | values.add(EmitIvarList(ID, true)); |
---|
| - values.add(emitMethodList(ID->getName(), MethodListType::ClassMethods, | | + values.add( |
---|
| - Methods)); | | + emitMethodList(ID->getName(), MethodListType::ClassMethods, Methods)); |
---|
| // cache is always NULL. | | // cache is always NULL. |
---|
| values.addNullPointer(ObjCTypes.CachePtrTy); | | values.addNullPointer(ObjCTypes.CachePtrTy); |
---|
| values.add(Protocols); | | values.add(Protocols); |
---|
| // ivar_layout for metaclass is always NULL. | | // ivar_layout for metaclass is always NULL. |
---|
| values.addNullPointer(ObjCTypes.Int8PtrTy); | | values.addNullPointer(ObjCTypes.Int8PtrTy); |
---|
| // The class extension is used to store class properties for metaclasses. | | // The class extension is used to store class properties for metaclasses. |
---|
| - values.add(EmitClassExtension(ID, CharUnits::Zero(), false/*hasMRCWeak*/, | | + values.add(EmitClassExtension(ID, CharUnits::Zero(), false /*hasMRCWeak*/, |
---|
| - /*isMetaclass*/true)); | | + /*isMetaclass*/ true)); |
---|
| | | |
---|
| std::string Name("OBJC_METACLASS_"); | | std::string Name("OBJC_METACLASS_"); |
---|
| Name += ID->getName(); | | Name += ID->getName(); |
---|
@@ -3707,10 +3621,10 @@ llvm::Value *CGObjCMac::EmitSuperClassRef(const ObjCInterfaceDecl *ID) { |
| struct _objc_property_list *properties; | | struct _objc_property_list *properties; |
---|
| }; | | }; |
---|
| */ | | */ |
---|
| -llvm::Constant * | | +llvm::Constant *CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID, |
---|
| -CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID, | | + CharUnits InstanceSize, |
---|
| - CharUnits InstanceSize, bool hasMRCWeakIvars, | | + bool hasMRCWeakIvars, |
---|
| - bool isMetaclass) { | | + bool isMetaclass) { |
---|
| // Weak ivar layout. | | // Weak ivar layout. |
---|
| llvm::Constant *layout; | | llvm::Constant *layout; |
---|
| if (isMetaclass) { | | if (isMetaclass) { |
---|
@@ -3722,10 +3636,10 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID, |
| | | |
---|
| // Properties. | | // Properties. |
---|
| llvm::Constant *propertyList = | | llvm::Constant *propertyList = |
---|
| - EmitPropertyList((isMetaclass ? Twine("_OBJC_$_CLASS_PROP_LIST_") | | + EmitPropertyList((isMetaclass ? Twine("_OBJC_$_CLASS_PROP_LIST_") |
---|
| - : Twine("_OBJC_$_PROP_LIST_")) | | + : Twine("_OBJC_$_PROP_LIST_")) + |
---|
| - + ID->getName(), | | + ID->getName(), |
---|
| - ID, ID->getClassInterface(), ObjCTypes, isMetaclass); | | + ID, ID->getClassInterface(), ObjCTypes, isMetaclass); |
---|
| | | |
---|
| // Return null if no extension bits are used. | | // Return null if no extension bits are used. |
---|
| if (layout->isNullValue() && propertyList->isNullValue()) { | | if (layout->isNullValue() && propertyList->isNullValue()) { |
---|
@@ -3733,7 +3647,7 @@ CGObjCMac::EmitClassExtension(const ObjCImplementationDecl *ID, |
| } | | } |
---|
| | | |
---|
| uint64_t size = | | uint64_t size = |
---|
| - CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassExtensionTy); | | + CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassExtensionTy); |
---|
| | | |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto values = builder.beginStruct(ObjCTypes.ClassExtensionTy); | | auto values = builder.beginStruct(ObjCTypes.ClassExtensionTy); |
---|
@@ -3775,8 +3689,8 @@ llvm::Constant *CGObjCMac::EmitIvarList(const ObjCImplementationDecl *ID, |
| auto countSlot = ivarList.addPlaceholder(); | | auto countSlot = ivarList.addPlaceholder(); |
---|
| auto ivars = ivarList.beginArray(ObjCTypes.IvarTy); | | auto ivars = ivarList.beginArray(ObjCTypes.IvarTy); |
---|
| | | |
---|
| - for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin(); | | + for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin(); IVD; |
---|
| - IVD; IVD = IVD->getNextIvar()) { | | + IVD = IVD->getNextIvar()) { |
---|
| // Ignore unnamed bit-fields. | | // Ignore unnamed bit-fields. |
---|
| if (!IVD->getDeclName()) | | if (!IVD->getDeclName()) |
---|
| continue; | | continue; |
---|
@@ -3852,8 +3766,9 @@ void CGObjCMac::emitMethodConstant(ConstantArrayBuilder &builder, |
| /// int count; | | /// int count; |
---|
| /// struct objc_method_description list[count]; | | /// struct objc_method_description list[count]; |
---|
| /// }; | | /// }; |
---|
| -llvm::Constant *CGObjCMac::emitMethodList(Twine name, MethodListType MLT, | | +llvm::Constant * |
---|
| - ArrayRef<const ObjCMethodDecl *> methods) { | | +CGObjCMac::emitMethodList(Twine name, MethodListType MLT, |
---|
| | | + ArrayRef<const ObjCMethodDecl *> methods) { |
---|
| StringRef prefix; | | StringRef prefix; |
---|
| StringRef section; | | StringRef section; |
---|
| bool forProtocol = false; | | bool forProtocol = false; |
---|
@@ -3902,9 +3817,9 @@ llvm::Constant *CGObjCMac::emitMethodList(Twine name, MethodListType MLT, |
| | | |
---|
| // Return null for empty list. | | // Return null for empty list. |
---|
| if (methods.empty()) | | if (methods.empty()) |
---|
| - return llvm::Constant::getNullValue(forProtocol | | + return llvm::Constant::getNullValue( |
---|
| - ? ObjCTypes.MethodDescriptionListPtrTy | | + forProtocol ? ObjCTypes.MethodDescriptionListPtrTy |
---|
| - : ObjCTypes.MethodListPtrTy); | | + : ObjCTypes.MethodListPtrTy); |
---|
| | | |
---|
| // For protocols, this is an objc_method_description_list, which has | | // For protocols, this is an objc_method_description_list, which has |
---|
| // a slightly different structure. | | // a slightly different structure. |
---|
@@ -3952,9 +3867,8 @@ llvm::Function *CGObjCCommonMac::GenerateMethod(const ObjCMethodDecl *OMD, |
| CodeGenTypes &Types = CGM.getTypes(); | | CodeGenTypes &Types = CGM.getTypes(); |
---|
| llvm::FunctionType *MethodTy = | | llvm::FunctionType *MethodTy = |
---|
| Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD)); | | Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD)); |
---|
| - Method = | | + Method = llvm::Function::Create( |
---|
| - llvm::Function::Create(MethodTy, llvm::GlobalValue::InternalLinkage, | | + MethodTy, llvm::GlobalValue::InternalLinkage, Name, &CGM.getModule()); |
---|
| - Name, &CGM.getModule()); | | |
---|
| } | | } |
---|
| | | |
---|
| MethodDefinitions.insert(std::make_pair(OMD, Method)); | | MethodDefinitions.insert(std::make_pair(OMD, Method)); |
---|
@@ -3986,7 +3900,7 @@ CGObjCCommonMac::GenerateDirectMethod(const ObjCMethodDecl *OMD, |
| | | |
---|
| CodeGenTypes &Types = CGM.getTypes(); | | CodeGenTypes &Types = CGM.getTypes(); |
---|
| llvm::FunctionType *MethodTy = | | llvm::FunctionType *MethodTy = |
---|
| - Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD)); | | + Types.GetFunctionType(Types.arrangeObjCMethodDeclaration(OMD)); |
---|
| | | |
---|
| if (OldFn) { | | if (OldFn) { |
---|
| Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage, | | Fn = llvm::Function::Create(MethodTy, llvm::GlobalValue::ExternalLinkage, |
---|
@@ -4096,11 +4010,10 @@ void CGObjCCommonMac::GenerateDirectMethodPrologue( |
| } | | } |
---|
| } | | } |
---|
| | | |
---|
| -llvm::GlobalVariable *CGObjCCommonMac::CreateMetadataVar(Twine Name, | | +llvm::GlobalVariable * |
---|
| - ConstantStructBuilder &Init, | | +CGObjCCommonMac::CreateMetadataVar(Twine Name, ConstantStructBuilder &Init, |
---|
| - StringRef Section, | | + StringRef Section, CharUnits Align, |
---|
| - CharUnits Align, | | + bool AddToUsed) { |
---|
| - bool AddToUsed) { | | |
---|
| llvm::GlobalValue::LinkageTypes LT = | | llvm::GlobalValue::LinkageTypes LT = |
---|
| getLinkageTypeForObjCMetadata(CGM, Section); | | getLinkageTypeForObjCMetadata(CGM, Section); |
---|
| llvm::GlobalVariable *GV = | | llvm::GlobalVariable *GV = |
---|
@@ -4136,10 +4049,18 @@ CGObjCCommonMac::CreateCStringLiteral(StringRef Name, ObjCLabelType Type, |
| bool NullTerminate) { | | bool NullTerminate) { |
---|
| StringRef Label; | | StringRef Label; |
---|
| switch (Type) { | | switch (Type) { |
---|
| - case ObjCLabelType::ClassName: Label = "OBJC_CLASS_NAME_"; break; | | + case ObjCLabelType::ClassName: |
---|
| - case ObjCLabelType::MethodVarName: Label = "OBJC_METH_VAR_NAME_"; break; | | + Label = "OBJC_CLASS_NAME_"; |
---|
| - case ObjCLabelType::MethodVarType: Label = "OBJC_METH_VAR_TYPE_"; break; | | + break; |
---|
| - case ObjCLabelType::PropertyName: Label = "OBJC_PROP_NAME_ATTR_"; break; | | + case ObjCLabelType::MethodVarName: |
---|
| | | + Label = "OBJC_METH_VAR_NAME_"; |
---|
| | | + break; |
---|
| | | + case ObjCLabelType::MethodVarType: |
---|
| | | + Label = "OBJC_METH_VAR_TYPE_"; |
---|
| | | + break; |
---|
| | | + case ObjCLabelType::PropertyName: |
---|
| | | + Label = "OBJC_PROP_NAME_ATTR_"; |
---|
| | | + break; |
---|
| } | | } |
---|
| | | |
---|
| bool NonFragile = ForceNonFragileABI || isNonFragileABI(); | | bool NonFragile = ForceNonFragileABI || isNonFragileABI(); |
---|
@@ -4166,10 +4087,9 @@ CGObjCCommonMac::CreateCStringLiteral(StringRef Name, ObjCLabelType Type, |
| | | |
---|
| llvm::Constant *Value = | | llvm::Constant *Value = |
---|
| llvm::ConstantDataArray::getString(VMContext, Name, NullTerminate); | | llvm::ConstantDataArray::getString(VMContext, Name, NullTerminate); |
---|
| - llvm::GlobalVariable *GV = | | + llvm::GlobalVariable *GV = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), Value->getType(), | | + CGM.getModule(), Value->getType(), |
---|
| - /*isConstant=*/true, | | + /*isConstant=*/true, llvm::GlobalValue::PrivateLinkage, Value, Label); |
---|
| - llvm::GlobalValue::PrivateLinkage, Value, Label); | | |
---|
| if (CGM.getTriple().isOSBinFormatMachO()) | | if (CGM.getTriple().isOSBinFormatMachO()) |
---|
| GV->setSection(Section); | | GV->setSection(Section); |
---|
| GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); | | GV->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global); |
---|
@@ -4228,85 +4148,84 @@ void CGObjCMac::EmitSynchronizedStmt(CodeGenFunction &CGF, |
| } | | } |
---|
| | | |
---|
| namespace { | | namespace { |
---|
| - struct PerformFragileFinally final : EHScopeStack::Cleanup { | | +struct PerformFragileFinally final : EHScopeStack::Cleanup { |
---|
| - const Stmt &S; | | + const Stmt &S; |
---|
| - Address SyncArgSlot; | | + Address SyncArgSlot; |
---|
| - Address CallTryExitVar; | | + Address CallTryExitVar; |
---|
| - Address ExceptionData; | | + Address ExceptionData; |
---|
| - ObjCTypesHelper &ObjCTypes; | | + ObjCTypesHelper &ObjCTypes; |
---|
| - PerformFragileFinally(const Stmt *S, | | + PerformFragileFinally(const Stmt *S, Address SyncArgSlot, |
---|
| - Address SyncArgSlot, | | + Address CallTryExitVar, Address ExceptionData, |
---|
| - Address CallTryExitVar, | | + ObjCTypesHelper *ObjCTypes) |
---|
| - Address ExceptionData, | | |
---|
| - ObjCTypesHelper *ObjCTypes) | | |
---|
| : S(*S), SyncArgSlot(SyncArgSlot), CallTryExitVar(CallTryExitVar), | | : S(*S), SyncArgSlot(SyncArgSlot), CallTryExitVar(CallTryExitVar), |
---|
| ExceptionData(ExceptionData), ObjCTypes(*ObjCTypes) {} | | ExceptionData(ExceptionData), ObjCTypes(*ObjCTypes) {} |
---|
| | | |
---|
| - void Emit(CodeGenFunction &CGF, Flags flags) override { | | + void Emit(CodeGenFunction &CGF, Flags flags) override { |
---|
| - // Check whether we need to call objc_exception_try_exit. | | + // Check whether we need to call objc_exception_try_exit. |
---|
| - // In optimized code, this branch will always be folded. | | + // In optimized code, this branch will always be folded. |
---|
| - llvm::BasicBlock *FinallyCallExit = | | + llvm::BasicBlock *FinallyCallExit = |
---|
| CGF.createBasicBlock("finally.call_exit"); | | CGF.createBasicBlock("finally.call_exit"); |
---|
| - llvm::BasicBlock *FinallyNoCallExit = | | + llvm::BasicBlock *FinallyNoCallExit = |
---|
| CGF.createBasicBlock("finally.no_call_exit"); | | CGF.createBasicBlock("finally.no_call_exit"); |
---|
| - CGF.Builder.CreateCondBr(CGF.Builder.CreateLoad(CallTryExitVar), | | + CGF.Builder.CreateCondBr(CGF.Builder.CreateLoad(CallTryExitVar), |
---|
| - FinallyCallExit, FinallyNoCallExit); | | + FinallyCallExit, FinallyNoCallExit); |
---|
| | | |
---|
| - CGF.EmitBlock(FinallyCallExit); | | + CGF.EmitBlock(FinallyCallExit); |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryExitFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryExitFn(), |
---|
| - ExceptionData.emitRawPointer(CGF)); | | + ExceptionData.emitRawPointer(CGF)); |
---|
| | | |
---|
| - CGF.EmitBlock(FinallyNoCallExit); | | + CGF.EmitBlock(FinallyNoCallExit); |
---|
| | | |
---|
| - if (isa<ObjCAtTryStmt>(S)) { | | + if (isa<ObjCAtTryStmt>(S)) { |
---|
| - if (const ObjCAtFinallyStmt* FinallyStmt = | | + if (const ObjCAtFinallyStmt *FinallyStmt = |
---|
| cast<ObjCAtTryStmt>(S).getFinallyStmt()) { | | cast<ObjCAtTryStmt>(S).getFinallyStmt()) { |
---|
| - // Don't try to do the @finally if this is an EH cleanup. | | + // Don't try to do the @finally if this is an EH cleanup. |
---|
| - if (flags.isForEHCleanup()) return; | | + if (flags.isForEHCleanup()) |
---|
| | | + return; |
---|
| | | |
---|
| - // Save the current cleanup destination in case there's | | + // Save the current cleanup destination in case there's |
---|
| - // control flow inside the finally statement. | | + // control flow inside the finally statement. |
---|
| - llvm::Value *CurCleanupDest = | | + llvm::Value *CurCleanupDest = |
---|
| CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot()); | | CGF.Builder.CreateLoad(CGF.getNormalCleanupDestSlot()); |
---|
| | | |
---|
| - CGF.EmitStmt(FinallyStmt->getFinallyBody()); | | + CGF.EmitStmt(FinallyStmt->getFinallyBody()); |
---|
| | | |
---|
| - if (CGF.HaveInsertPoint()) { | | + if (CGF.HaveInsertPoint()) { |
---|
| - CGF.Builder.CreateStore(CurCleanupDest, | | + CGF.Builder.CreateStore(CurCleanupDest, |
---|
| - CGF.getNormalCleanupDestSlot()); | | + CGF.getNormalCleanupDestSlot()); |
---|
| - } else { | | + } else { |
---|
| - // Currently, the end of the cleanup must always exist. | | + // Currently, the end of the cleanup must always exist. |
---|
| - CGF.EnsureInsertPoint(); | | + CGF.EnsureInsertPoint(); |
---|
| - } | | |
---|
| } | | } |
---|
| - } else { | | |
---|
| - // Emit objc_sync_exit(expr); as finally's sole statement for | | |
---|
| - // @synchronized. | | |
---|
| - llvm::Value *SyncArg = CGF.Builder.CreateLoad(SyncArgSlot); | | |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncExitFn(), SyncArg); | | |
---|
| } | | } |
---|
| | | + } else { |
---|
| | | + // Emit objc_sync_exit(expr); as finally's sole statement for |
---|
| | | + // @synchronized. |
---|
| | | + llvm::Value *SyncArg = CGF.Builder.CreateLoad(SyncArgSlot); |
---|
| | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncExitFn(), SyncArg); |
---|
| } | | } |
---|
| - }; | | + } |
---|
| | | +}; |
---|
| | | |
---|
| - class FragileHazards { | | +class FragileHazards { |
---|
| - CodeGenFunction &CGF; | | + CodeGenFunction &CGF; |
---|
| - SmallVector<llvm::Value*, 20> Locals; | | + SmallVector<llvm::Value *, 20> Locals; |
---|
| - llvm::DenseSet<llvm::BasicBlock*> BlocksBeforeTry; | | + llvm::DenseSet<llvm::BasicBlock *> BlocksBeforeTry; |
---|
| | | |
---|
| - llvm::InlineAsm *ReadHazard; | | + llvm::InlineAsm *ReadHazard; |
---|
| - llvm::InlineAsm *WriteHazard; | | + llvm::InlineAsm *WriteHazard; |
---|
| | | |
---|
| - llvm::FunctionType *GetAsmFnType(); | | + llvm::FunctionType *GetAsmFnType(); |
---|
| | | |
---|
| - void collectLocals(); | | + void collectLocals(); |
---|
| - void emitReadHazard(CGBuilderTy &Builder); | | + void emitReadHazard(CGBuilderTy &Builder); |
---|
| | | |
---|
| - public: | | +public: |
---|
| - FragileHazards(CodeGenFunction &CGF); | | + FragileHazards(CodeGenFunction &CGF); |
---|
| | | |
---|
| - void emitWriteHazard(); | | + void emitWriteHazard(); |
---|
| - void emitHazardsInNewBlocks(); | | + void emitHazardsInNewBlocks(); |
---|
| - }; | | +}; |
---|
| } // end anonymous namespace | | } // end anonymous namespace |
---|
| | | |
---|
| /// Create the fragile-ABI read and write hazards based on the current | | /// Create the fragile-ABI read and write hazards based on the current |
---|
@@ -4317,11 +4236,12 @@ namespace { |
| FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { | | FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { |
---|
| collectLocals(); | | collectLocals(); |
---|
| | | |
---|
| - if (Locals.empty()) return; | | + if (Locals.empty()) |
---|
| | | + return; |
---|
| | | |
---|
| // Collect all the blocks in the function. | | // Collect all the blocks in the function. |
---|
| - for (llvm::Function::iterator | | + for (llvm::Function::iterator I = CGF.CurFn->begin(), E = CGF.CurFn->end(); |
---|
| - I = CGF.CurFn->begin(), E = CGF.CurFn->end(); I != E; ++I) | | + I != E; ++I) |
---|
| BlocksBeforeTry.insert(&*I); | | BlocksBeforeTry.insert(&*I); |
---|
| | | |
---|
| llvm::FunctionType *AsmFnTy = GetAsmFnType(); | | llvm::FunctionType *AsmFnTy = GetAsmFnType(); |
---|
@@ -4334,7 +4254,8 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { |
| { | | { |
---|
| std::string Constraint; | | std::string Constraint; |
---|
| for (unsigned I = 0, E = Locals.size(); I != E; ++I) { | | for (unsigned I = 0, E = Locals.size(); I != E; ++I) { |
---|
| - if (I) Constraint += ','; | | + if (I) |
---|
| | | + Constraint += ','; |
---|
| Constraint += "*m"; | | Constraint += "*m"; |
---|
| } | | } |
---|
| | | |
---|
@@ -4348,7 +4269,8 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { |
| { | | { |
---|
| std::string Constraint; | | std::string Constraint; |
---|
| for (unsigned I = 0, E = Locals.size(); I != E; ++I) { | | for (unsigned I = 0, E = Locals.size(); I != E; ++I) { |
---|
| - if (I) Constraint += ','; | | + if (I) |
---|
| | | + Constraint += ','; |
---|
| Constraint += "=*m"; | | Constraint += "=*m"; |
---|
| } | | } |
---|
| | | |
---|
@@ -4358,13 +4280,16 @@ FragileHazards::FragileHazards(CodeGenFunction &CGF) : CGF(CGF) { |
| | | |
---|
| /// Emit a write hazard at the current location. | | /// Emit a write hazard at the current location. |
---|
| void FragileHazards::emitWriteHazard() { | | void FragileHazards::emitWriteHazard() { |
---|
| - if (Locals.empty()) return; | | + if (Locals.empty()) |
---|
| | | + return; |
---|
| | | |
---|
| llvm::CallInst *Call = CGF.EmitNounwindRuntimeCall(WriteHazard, Locals); | | llvm::CallInst *Call = CGF.EmitNounwindRuntimeCall(WriteHazard, Locals); |
---|
| for (auto Pair : llvm::enumerate(Locals)) | | for (auto Pair : llvm::enumerate(Locals)) |
---|
| - Call->addParamAttr(Pair.index(), llvm::Attribute::get( | | + Call->addParamAttr( |
---|
| - CGF.getLLVMContext(), llvm::Attribute::ElementType, | | + Pair.index(), |
---|
| - cast<llvm::AllocaInst>(Pair.value())->getAllocatedType())); | | + llvm::Attribute::get( |
---|
| | | + CGF.getLLVMContext(), llvm::Attribute::ElementType, |
---|
| | | + cast<llvm::AllocaInst>(Pair.value())->getAllocatedType())); |
---|
| } | | } |
---|
| | | |
---|
| void FragileHazards::emitReadHazard(CGBuilderTy &Builder) { | | void FragileHazards::emitReadHazard(CGBuilderTy &Builder) { |
---|
@@ -4373,27 +4298,31 @@ void FragileHazards::emitReadHazard(CGBuilderTy &Builder) { |
| call->setDoesNotThrow(); | | call->setDoesNotThrow(); |
---|
| call->setCallingConv(CGF.getRuntimeCC()); | | call->setCallingConv(CGF.getRuntimeCC()); |
---|
| for (auto Pair : llvm::enumerate(Locals)) | | for (auto Pair : llvm::enumerate(Locals)) |
---|
| - call->addParamAttr(Pair.index(), llvm::Attribute::get( | | + call->addParamAttr( |
---|
| - Builder.getContext(), llvm::Attribute::ElementType, | | + Pair.index(), |
---|
| - cast<llvm::AllocaInst>(Pair.value())->getAllocatedType())); | | + llvm::Attribute::get( |
---|
| | | + Builder.getContext(), llvm::Attribute::ElementType, |
---|
| | | + cast<llvm::AllocaInst>(Pair.value())->getAllocatedType())); |
---|
| } | | } |
---|
| | | |
---|
| /// Emit read hazards in all the protected blocks, i.e. all the blocks | | /// Emit read hazards in all the protected blocks, i.e. all the blocks |
---|
| /// which have been inserted since the beginning of the try. | | /// which have been inserted since the beginning of the try. |
---|
| void FragileHazards::emitHazardsInNewBlocks() { | | void FragileHazards::emitHazardsInNewBlocks() { |
---|
| - if (Locals.empty()) return; | | + if (Locals.empty()) |
---|
| | | + return; |
---|
| | | |
---|
| CGBuilderTy Builder(CGF, CGF.getLLVMContext()); | | CGBuilderTy Builder(CGF, CGF.getLLVMContext()); |
---|
| | | |
---|
| // Iterate through all blocks, skipping those prior to the try. | | // Iterate through all blocks, skipping those prior to the try. |
---|
| - for (llvm::Function::iterator | | + for (llvm::Function::iterator FI = CGF.CurFn->begin(), FE = CGF.CurFn->end(); |
---|
| - FI = CGF.CurFn->begin(), FE = CGF.CurFn->end(); FI != FE; ++FI) { | | + FI != FE; ++FI) { |
---|
| llvm::BasicBlock &BB = *FI; | | llvm::BasicBlock &BB = *FI; |
---|
| - if (BlocksBeforeTry.count(&BB)) continue; | | + if (BlocksBeforeTry.count(&BB)) |
---|
| | | + continue; |
---|
| | | |
---|
| // Walk through all the calls in the block. | | // Walk through all the calls in the block. |
---|
| - for (llvm::BasicBlock::iterator | | + for (llvm::BasicBlock::iterator BI = BB.begin(), BE = BB.end(); BI != BE; |
---|
| - BI = BB.begin(), BE = BB.end(); BI != BE; ++BI) { | | + ++BI) { |
---|
| llvm::Instruction &I = *BI; | | llvm::Instruction &I = *BI; |
---|
| | | |
---|
| // Ignore instructions that aren't non-intrinsic calls. | | // Ignore instructions that aren't non-intrinsic calls. |
---|
@@ -4419,7 +4348,7 @@ void FragileHazards::emitHazardsInNewBlocks() { |
| } | | } |
---|
| } | | } |
---|
| | | |
---|
| -static void addIfPresent(llvm::DenseSet<llvm::Value*> &S, Address V) { | | +static void addIfPresent(llvm::DenseSet<llvm::Value *> &S, Address V) { |
---|
| if (V.isValid()) | | if (V.isValid()) |
---|
| if (llvm::Value *Ptr = V.getBasePointer()) | | if (llvm::Value *Ptr = V.getBasePointer()) |
---|
| S.insert(Ptr); | | S.insert(Ptr); |
---|
@@ -4427,15 +4356,15 @@ static void addIfPresent(llvm::DenseSet<llvm::Value*> &S, Address V) { |
| | | |
---|
| void FragileHazards::collectLocals() { | | void FragileHazards::collectLocals() { |
---|
| // Compute a set of allocas to ignore. | | // Compute a set of allocas to ignore. |
---|
| - llvm::DenseSet<llvm::Value*> AllocasToIgnore; | | + llvm::DenseSet<llvm::Value *> AllocasToIgnore; |
---|
| addIfPresent(AllocasToIgnore, CGF.ReturnValue); | | addIfPresent(AllocasToIgnore, CGF.ReturnValue); |
---|
| addIfPresent(AllocasToIgnore, CGF.NormalCleanupDest); | | addIfPresent(AllocasToIgnore, CGF.NormalCleanupDest); |
---|
| | | |
---|
| // Collect all the allocas currently in the function. This is | | // Collect all the allocas currently in the function. This is |
---|
| // probably way too aggressive. | | // probably way too aggressive. |
---|
| llvm::BasicBlock &Entry = CGF.CurFn->getEntryBlock(); | | llvm::BasicBlock &Entry = CGF.CurFn->getEntryBlock(); |
---|
| - for (llvm::BasicBlock::iterator | | + for (llvm::BasicBlock::iterator I = Entry.begin(), E = Entry.end(); I != E; |
---|
| - I = Entry.begin(), E = Entry.end(); I != E; ++I) | | + ++I) |
---|
| if (isa<llvm::AllocaInst>(*I) && !AllocasToIgnore.count(&*I)) | | if (isa<llvm::AllocaInst>(*I) && !AllocasToIgnore.count(&*I)) |
---|
| Locals.push_back(&*I); | | Locals.push_back(&*I); |
---|
| } | | } |
---|
@@ -4562,12 +4491,12 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| // A destination for the fall-through edges of the catch handlers to | | // A destination for the fall-through edges of the catch handlers to |
---|
| // jump to. | | // jump to. |
---|
| CodeGenFunction::JumpDest FinallyEnd = | | CodeGenFunction::JumpDest FinallyEnd = |
---|
| - CGF.getJumpDestInCurrentScope("finally.end"); | | + CGF.getJumpDestInCurrentScope("finally.end"); |
---|
| | | |
---|
| // A destination for the rethrow edge of the catch handlers to jump | | // A destination for the rethrow edge of the catch handlers to jump |
---|
| // to. | | // to. |
---|
| CodeGenFunction::JumpDest FinallyRethrow = | | CodeGenFunction::JumpDest FinallyRethrow = |
---|
| - CGF.getJumpDestInCurrentScope("finally.rethrow"); | | + CGF.getJumpDestInCurrentScope("finally.rethrow"); |
---|
| | | |
---|
| // For @synchronized, call objc_sync_enter(sync.expr). The | | // For @synchronized, call objc_sync_enter(sync.expr). The |
---|
| // evaluation of the expression must occur before we enter the | | // evaluation of the expression must occur before we enter the |
---|
@@ -4577,7 +4506,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| Address SyncArgSlot = Address::invalid(); | | Address SyncArgSlot = Address::invalid(); |
---|
| if (!isTry) { | | if (!isTry) { |
---|
| llvm::Value *SyncArg = | | llvm::Value *SyncArg = |
---|
| - CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr()); | | + CGF.EmitScalarExpr(cast<ObjCAtSynchronizedStmt>(S).getSynchExpr()); |
---|
| SyncArg = CGF.Builder.CreateBitCast(SyncArg, ObjCTypes.ObjectPtrTy); | | SyncArg = CGF.Builder.CreateBitCast(SyncArg, ObjCTypes.ObjectPtrTy); |
---|
| CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncEnterFn(), SyncArg); | | CGF.EmitNounwindRuntimeCall(ObjCTypes.getSyncEnterFn(), SyncArg); |
---|
| | | |
---|
@@ -4588,9 +4517,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| | | |
---|
| // Allocate memory for the setjmp buffer. This needs to be kept | | // Allocate memory for the setjmp buffer. This needs to be kept |
---|
| // live throughout the try and catch blocks. | | // live throughout the try and catch blocks. |
---|
| - Address ExceptionData = CGF.CreateTempAlloca(ObjCTypes.ExceptionDataTy, | | + Address ExceptionData = CGF.CreateTempAlloca( |
---|
| - CGF.getPointerAlign(), | | + ObjCTypes.ExceptionDataTy, CGF.getPointerAlign(), "exceptiondata.ptr"); |
---|
| - "exceptiondata.ptr"); | | |
---|
| | | |
---|
| // Create the fragile hazards. Note that this will not capture any | | // Create the fragile hazards. Note that this will not capture any |
---|
| // of the allocas required for exception processing, but will | | // of the allocas required for exception processing, but will |
---|
@@ -4606,9 +4534,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| // The setjmp-safety rule here is that we should always store to this | | // The setjmp-safety rule here is that we should always store to this |
---|
| // variable in a place that dominates the branch through the cleanup | | // variable in a place that dominates the branch through the cleanup |
---|
| // without passing through any setjmps. | | // without passing through any setjmps. |
---|
| - Address CallTryExitVar = CGF.CreateTempAlloca(CGF.Builder.getInt1Ty(), | | + Address CallTryExitVar = CGF.CreateTempAlloca( |
---|
| - CharUnits::One(), | | + CGF.Builder.getInt1Ty(), CharUnits::One(), "_call_try_exit"); |
---|
| - "_call_try_exit"); | | |
---|
| | | |
---|
| // A slot containing the exception to rethrow. Only needed when we | | // A slot containing the exception to rethrow. Only needed when we |
---|
| // have both a @catch and a @finally. | | // have both a @catch and a @finally. |
---|
@@ -4616,10 +4543,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| | | |
---|
| // Push a normal cleanup to leave the try scope. | | // Push a normal cleanup to leave the try scope. |
---|
| CGF.EHStack.pushCleanup<PerformFragileFinally>(NormalAndEHCleanup, &S, | | CGF.EHStack.pushCleanup<PerformFragileFinally>(NormalAndEHCleanup, &S, |
---|
| - SyncArgSlot, | | + SyncArgSlot, CallTryExitVar, |
---|
| - CallTryExitVar, | | + ExceptionData, &ObjCTypes); |
---|
| - ExceptionData, | | |
---|
| - &ObjCTypes); | | |
---|
| | | |
---|
| // Enter a try block: | | // Enter a try block: |
---|
| // - Call objc_exception_try_enter to push ExceptionData on top of | | // - Call objc_exception_try_enter to push ExceptionData on top of |
---|
@@ -4629,7 +4554,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| | | |
---|
| // - Call setjmp on the exception data buffer. | | // - Call setjmp on the exception data buffer. |
---|
| llvm::Constant *Zero = llvm::ConstantInt::get(CGF.Builder.getInt32Ty(), 0); | | llvm::Constant *Zero = llvm::ConstantInt::get(CGF.Builder.getInt32Ty(), 0); |
---|
| - llvm::Value *GEPIndexes[] = { Zero, Zero, Zero }; | | + llvm::Value *GEPIndexes[] = {Zero, Zero, Zero}; |
---|
| llvm::Value *SetJmpBuffer = CGF.Builder.CreateGEP( | | llvm::Value *SetJmpBuffer = CGF.Builder.CreateGEP( |
---|
| ObjCTypes.ExceptionDataTy, ExceptionData.emitRawPointer(CGF), GEPIndexes, | | ObjCTypes.ExceptionDataTy, ExceptionData.emitRawPointer(CGF), GEPIndexes, |
---|
| "setjmp_buffer"); | | "setjmp_buffer"); |
---|
@@ -4642,7 +4567,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| llvm::BasicBlock *TryBlock = CGF.createBasicBlock("try"); | | llvm::BasicBlock *TryBlock = CGF.createBasicBlock("try"); |
---|
| llvm::BasicBlock *TryHandler = CGF.createBasicBlock("try.handler"); | | llvm::BasicBlock *TryHandler = CGF.createBasicBlock("try.handler"); |
---|
| llvm::Value *DidCatch = | | llvm::Value *DidCatch = |
---|
| - CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception"); | | + CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception"); |
---|
| CGF.Builder.CreateCondBr(DidCatch, TryHandler, TryBlock); | | CGF.Builder.CreateCondBr(DidCatch, TryHandler, TryBlock); |
---|
| | | |
---|
| // Emit the protected block. | | // Emit the protected block. |
---|
@@ -4678,7 +4603,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| // benefit of any @throws in the handlers. | | // benefit of any @throws in the handlers. |
---|
| CGF.ObjCEHValueStack.push_back(Caught); | | CGF.ObjCEHValueStack.push_back(Caught); |
---|
| | | |
---|
| - const ObjCAtTryStmt* AtTryStmt = cast<ObjCAtTryStmt>(&S); | | + const ObjCAtTryStmt *AtTryStmt = cast<ObjCAtTryStmt>(&S); |
---|
| | | |
---|
| bool HasFinally = (AtTryStmt->getFinallyStmt() != nullptr); | | bool HasFinally = (AtTryStmt->getFinallyStmt() != nullptr); |
---|
| | | |
---|
@@ -4687,9 +4612,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| if (HasFinally) { | | if (HasFinally) { |
---|
| // Save the currently-propagating exception before | | // Save the currently-propagating exception before |
---|
| // objc_exception_try_enter clears the exception slot. | | // objc_exception_try_enter clears the exception slot. |
---|
| - PropagatingExnVar = CGF.CreateTempAlloca(Caught->getType(), | | + PropagatingExnVar = CGF.CreateTempAlloca( |
---|
| - CGF.getPointerAlign(), | | + Caught->getType(), CGF.getPointerAlign(), "propagating_exception"); |
---|
| - "propagating_exception"); | | |
---|
| CGF.Builder.CreateStore(Caught, PropagatingExnVar); | | CGF.Builder.CreateStore(Caught, PropagatingExnVar); |
---|
| | | |
---|
| // Enter a new exception try block (in case a @catch block | | // Enter a new exception try block (in case a @catch block |
---|
@@ -4697,13 +4621,12 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryEnterFn(), | | CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionTryEnterFn(), |
---|
| ExceptionData.emitRawPointer(CGF)); | | ExceptionData.emitRawPointer(CGF)); |
---|
| | | |
---|
| - llvm::CallInst *SetJmpResult = | | + llvm::CallInst *SetJmpResult = CGF.EmitNounwindRuntimeCall( |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getSetJmpFn(), | | + ObjCTypes.getSetJmpFn(), SetJmpBuffer, "setjmp.result"); |
---|
| - SetJmpBuffer, "setjmp.result"); | | |
---|
| SetJmpResult->setCanReturnTwice(); | | SetJmpResult->setCanReturnTwice(); |
---|
| | | |
---|
| llvm::Value *Threw = | | llvm::Value *Threw = |
---|
| - CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception"); | | + CGF.Builder.CreateIsNotNull(SetJmpResult, "did_catch_exception"); |
---|
| | | |
---|
| CatchBlock = CGF.createBasicBlock("catch"); | | CatchBlock = CGF.createBasicBlock("catch"); |
---|
| CatchHandler = CGF.createBasicBlock("catch_for_catch"); | | CatchHandler = CGF.createBasicBlock("catch_for_catch"); |
---|
@@ -4767,10 +4690,9 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| // Check if the @catch block matches the exception object. | | // Check if the @catch block matches the exception object. |
---|
| llvm::Value *Class = EmitClassRef(CGF, IDecl); | | llvm::Value *Class = EmitClassRef(CGF, IDecl); |
---|
| | | |
---|
| - llvm::Value *matchArgs[] = { Class, Caught }; | | + llvm::Value *matchArgs[] = {Class, Caught}; |
---|
| - llvm::CallInst *Match = | | + llvm::CallInst *Match = CGF.EmitNounwindRuntimeCall( |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getExceptionMatchFn(), | | + ObjCTypes.getExceptionMatchFn(), matchArgs, "match"); |
---|
| - matchArgs, "match"); | | |
---|
| | | |
---|
| llvm::BasicBlock *MatchedBlock = CGF.createBasicBlock("match"); | | llvm::BasicBlock *MatchedBlock = CGF.createBasicBlock("match"); |
---|
| llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch.next"); | | llvm::BasicBlock *NextCatchBlock = CGF.createBasicBlock("catch.next"); |
---|
@@ -4789,9 +4711,8 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?"); | | assert(CGF.HaveInsertPoint() && "DeclStmt destroyed insert point?"); |
---|
| | | |
---|
| // Initialize the catch variable. | | // Initialize the catch variable. |
---|
| - llvm::Value *Tmp = | | + llvm::Value *Tmp = CGF.Builder.CreateBitCast( |
---|
| - CGF.Builder.CreateBitCast(Caught, | | + Caught, CGF.ConvertType(CatchParam->getType())); |
---|
| - CGF.ConvertType(CatchParam->getType())); | | |
---|
| EmitInitOfCatchParam(CGF, Tmp, CatchParam); | | EmitInitOfCatchParam(CGF, Tmp, CatchParam); |
---|
| | | |
---|
| CGF.EmitStmt(CatchStmt->getCatchBody()); | | CGF.EmitStmt(CatchStmt->getCatchBody()); |
---|
@@ -4821,7 +4742,7 @@ void CGObjCMac::EmitTryOrSynchronizedStmt(CodeGen::CodeGenFunction &CGF, |
| // In theory we might now need a write hazard, but actually it's | | // In theory we might now need a write hazard, but actually it's |
---|
| // unnecessary because there's no local-accessing code between | | // unnecessary because there's no local-accessing code between |
---|
| // the try's write hazard and here. | | // the try's write hazard and here. |
---|
| - //Hazards.emitWriteHazard(); | | + // Hazards.emitWriteHazard(); |
---|
| | | |
---|
| // Extract the new exception and save it to the | | // Extract the new exception and save it to the |
---|
| // propagating-exception slot. | | // propagating-exception slot. |
---|
@@ -4879,7 +4800,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, |
| if (const Expr *ThrowExpr = S.getThrowExpr()) { | | if (const Expr *ThrowExpr = S.getThrowExpr()) { |
---|
| llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr); | | llvm::Value *Exception = CGF.EmitObjCThrowOperand(ThrowExpr); |
---|
| ExceptionAsObject = | | ExceptionAsObject = |
---|
| - CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy); | | + CGF.Builder.CreateBitCast(Exception, ObjCTypes.ObjectPtrTy); |
---|
| } else { | | } else { |
---|
| assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) && | | assert((!CGF.ObjCEHValueStack.empty() && CGF.ObjCEHValueStack.back()) && |
---|
| "Unexpected rethrow outside @catch block."); | | "Unexpected rethrow outside @catch block."); |
---|
@@ -4887,7 +4808,7 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, |
| } | | } |
---|
| | | |
---|
| CGF.EmitRuntimeCall(ObjCTypes.getExceptionThrowFn(), ExceptionAsObject) | | CGF.EmitRuntimeCall(ObjCTypes.getExceptionThrowFn(), ExceptionAsObject) |
---|
| - ->setDoesNotReturn(); | | + ->setDoesNotReturn(); |
---|
| CGF.Builder.CreateUnreachable(); | | CGF.Builder.CreateUnreachable(); |
---|
| | | |
---|
| // Clear the insertion point to indicate we are in unreachable code. | | // Clear the insertion point to indicate we are in unreachable code. |
---|
@@ -4898,14 +4819,13 @@ void CGObjCMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, |
| /// EmitObjCWeakRead - Code gen for loading value of a __weak | | /// EmitObjCWeakRead - Code gen for loading value of a __weak |
---|
| /// object: objc_read_weak (id *src) | | /// object: objc_read_weak (id *src) |
---|
| /// | | /// |
---|
| -llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, | | +llvm::Value *CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, |
---|
| - Address AddrWeakObj) { | | + Address AddrWeakObj) { |
---|
| - llvm::Type* DestTy = AddrWeakObj.getElementType(); | | + llvm::Type *DestTy = AddrWeakObj.getElementType(); |
---|
| llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast( | | llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast( |
---|
| AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy); | | AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy); |
---|
| - llvm::Value *read_weak = | | + llvm::Value *read_weak = CGF.EmitNounwindRuntimeCall( |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcReadWeakFn(), | | + ObjCTypes.getGcReadWeakFn(), AddrWeakObjVal, "weakread"); |
---|
| - AddrWeakObjVal, "weakread"); | | |
---|
| read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy); | | read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy); |
---|
| return read_weak; | | return read_weak; |
---|
| } | | } |
---|
@@ -4915,7 +4835,7 @@ llvm::Value * CGObjCMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, |
| /// | | /// |
---|
| void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, | | void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, |
---|
| llvm::Value *src, Address dst) { | | llvm::Value *src, Address dst) { |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
@@ -4926,9 +4846,9 @@ void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, |
| src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); | | src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); |
---|
| llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), | | llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), |
---|
| ObjCTypes.PtrObjectPtrTy); | | ObjCTypes.PtrObjectPtrTy); |
---|
| - llvm::Value *args[] = { src, dstVal }; | | + llvm::Value *args[] = {src, dstVal}; |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), args, |
---|
| - args, "weakassign"); | | + "weakassign"); |
---|
| } | | } |
---|
| | | |
---|
| /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. | | /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. |
---|
@@ -4937,7 +4857,7 @@ void CGObjCMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, |
| void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, | | void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, |
---|
| llvm::Value *src, Address dst, | | llvm::Value *src, Address dst, |
---|
| bool threadlocal) { | | bool threadlocal) { |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
@@ -4950,11 +4870,11 @@ void CGObjCMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, |
| ObjCTypes.PtrObjectPtrTy); | | ObjCTypes.PtrObjectPtrTy); |
---|
| llvm::Value *args[] = {src, dstVal}; | | llvm::Value *args[] = {src, dstVal}; |
---|
| if (!threadlocal) | | if (!threadlocal) |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(), args, |
---|
| - args, "globalassign"); | | + "globalassign"); |
---|
| else | | else |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), args, |
---|
| - args, "threadlocalassign"); | | + "threadlocalassign"); |
---|
| } | | } |
---|
| | | |
---|
| /// EmitObjCIvarAssign - Code gen for assigning to a __strong object. | | /// EmitObjCIvarAssign - Code gen for assigning to a __strong object. |
---|
@@ -4964,7 +4884,7 @@ void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, |
| llvm::Value *src, Address dst, | | llvm::Value *src, Address dst, |
---|
| llvm::Value *ivarOffset) { | | llvm::Value *ivarOffset) { |
---|
| assert(ivarOffset && "EmitObjCIvarAssign - ivarOffset is NULL"); | | assert(ivarOffset && "EmitObjCIvarAssign - ivarOffset is NULL"); |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
@@ -4984,7 +4904,7 @@ void CGObjCMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, |
| /// | | /// |
---|
| void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, | | void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, |
---|
| llvm::Value *src, Address dst) { | | llvm::Value *src, Address dst) { |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
@@ -4996,8 +4916,8 @@ void CGObjCMac::EmitObjCStrongCastAssign(CodeGen::CodeGenFunction &CGF, |
| llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), | | llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), |
---|
| ObjCTypes.PtrObjectPtrTy); | | ObjCTypes.PtrObjectPtrTy); |
---|
| llvm::Value *args[] = {src, dstVal}; | | llvm::Value *args[] = {src, dstVal}; |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), args, |
---|
| - args, "strongassign"); | | + "strongassign"); |
---|
| } | | } |
---|
| | | |
---|
| void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, | | void CGObjCMac::EmitGCMemmoveCollectable(CodeGen::CodeGenFunction &CGF, |
---|
@@ -5016,7 +4936,7 @@ LValue CGObjCMac::EmitObjCValueForIvar(CodeGen::CodeGenFunction &CGF, |
| const ObjCIvarDecl *Ivar, | | const ObjCIvarDecl *Ivar, |
---|
| unsigned CVRQualifiers) { | | unsigned CVRQualifiers) { |
---|
| const ObjCInterfaceDecl *ID = | | const ObjCInterfaceDecl *ID = |
---|
| - ObjectTy->castAs<ObjCObjectType>()->getInterface(); | | + ObjectTy->castAs<ObjCObjectType>()->getInterface(); |
---|
| return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers, | | return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers, |
---|
| EmitIvarOffset(CGF, ID, Ivar)); | | EmitIvarOffset(CGF, ID, Ivar)); |
---|
| } | | } |
---|
@@ -5026,8 +4946,7 @@ llvm::Value *CGObjCMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF, |
| const ObjCIvarDecl *Ivar) { | | const ObjCIvarDecl *Ivar) { |
---|
| uint64_t Offset = ComputeIvarBaseOffset(CGM, Interface, Ivar); | | uint64_t Offset = ComputeIvarBaseOffset(CGM, Interface, Ivar); |
---|
| return llvm::ConstantInt::get( | | return llvm::ConstantInt::get( |
---|
| - CGM.getTypes().ConvertType(CGM.getContext().LongTy), | | + CGM.getTypes().ConvertType(CGM.getContext().LongTy), Offset); |
---|
| - Offset); | | |
---|
| } | | } |
---|
| | | |
---|
| /* *** Private Interface *** */ | | /* *** Private Interface *** */ |
---|
@@ -5060,6 +4979,7 @@ std::string CGObjCCommonMac::GetSectionName(StringRef Section, |
| llvm_unreachable("Unhandled llvm::Triple::ObjectFormatType enum"); | | llvm_unreachable("Unhandled llvm::Triple::ObjectFormatType enum"); |
---|
| } | | } |
---|
| | | |
---|
| | | +// clang-format off |
---|
| /// EmitImageInfo - Emit the image info marker used to encode some module | | /// EmitImageInfo - Emit the image info marker used to encode some module |
---|
| /// level information. | | /// level information. |
---|
| /// | | /// |
---|
@@ -5081,6 +5001,7 @@ enum ImageInfoFlags { |
| eImageInfo_ImageIsSimulated = (1 << 5), | | eImageInfo_ImageIsSimulated = (1 << 5), |
---|
| eImageInfo_ClassProperties = (1 << 6) | | eImageInfo_ClassProperties = (1 << 6) |
---|
| }; | | }; |
---|
| | | +// clang-format on |
---|
| | | |
---|
| void CGObjCCommonMac::EmitImageInfo() { | | void CGObjCCommonMac::EmitImageInfo() { |
---|
| unsigned version = 0; // Version is unused? | | unsigned version = 0; // Version is unused? |
---|
@@ -5103,15 +5024,13 @@ void CGObjCCommonMac::EmitImageInfo() { |
| auto Int8Ty = llvm::Type::getInt8Ty(VMContext); | | auto Int8Ty = llvm::Type::getInt8Ty(VMContext); |
---|
| if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { | | if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { |
---|
| // Non-GC overrides those files which specify GC. | | // Non-GC overrides those files which specify GC. |
---|
| - Mod.addModuleFlag(llvm::Module::Error, | | + Mod.addModuleFlag(llvm::Module::Error, "Objective-C Garbage Collection", |
---|
| - "Objective-C Garbage Collection", | | + llvm::ConstantInt::get(Int8Ty, 0)); |
---|
| - llvm::ConstantInt::get(Int8Ty,0)); | | |
---|
| } else { | | } else { |
---|
| // Add the ObjC garbage collection value. | | // Add the ObjC garbage collection value. |
---|
| - Mod.addModuleFlag(llvm::Module::Error, | | + Mod.addModuleFlag( |
---|
| - "Objective-C Garbage Collection", | | + llvm::Module::Error, "Objective-C Garbage Collection", |
---|
| - llvm::ConstantInt::get(Int8Ty, | | + llvm::ConstantInt::get(Int8Ty, (uint8_t)eImageInfo_GarbageCollected)); |
---|
| - (uint8_t)eImageInfo_GarbageCollected)); | | |
---|
| | | |
---|
| if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) { | | if (CGM.getLangOpts().getGC() == LangOptions::GCOnly) { |
---|
| // Add the ObjC GC Only value. | | // Add the ObjC GC Only value. |
---|
@@ -5121,8 +5040,8 @@ void CGObjCCommonMac::EmitImageInfo() { |
| // Require that GC be specified and set to eImageInfo_GarbageCollected. | | // Require that GC be specified and set to eImageInfo_GarbageCollected. |
---|
| llvm::Metadata *Ops[2] = { | | llvm::Metadata *Ops[2] = { |
---|
| llvm::MDString::get(VMContext, "Objective-C Garbage Collection"), | | llvm::MDString::get(VMContext, "Objective-C Garbage Collection"), |
---|
| - llvm::ConstantAsMetadata::get(llvm::ConstantInt::get( | | + llvm::ConstantAsMetadata::get( |
---|
| - Int8Ty, eImageInfo_GarbageCollected))}; | | + llvm::ConstantInt::get(Int8Ty, eImageInfo_GarbageCollected))}; |
---|
| Mod.addModuleFlag(llvm::Module::Require, "Objective-C GC Only", | | Mod.addModuleFlag(llvm::Module::Require, "Objective-C GC Only", |
---|
| llvm::MDNode::get(VMContext, Ops)); | | llvm::MDNode::get(VMContext, Ops)); |
---|
| } | | } |
---|
@@ -5181,7 +5100,7 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() { |
| // The runtime expects exactly the list of defined classes followed | | // The runtime expects exactly the list of defined classes followed |
---|
| // by the list of defined categories, in a single array. | | // by the list of defined categories, in a single array. |
---|
| auto array = values.beginArray(ObjCTypes.Int8PtrTy); | | auto array = values.beginArray(ObjCTypes.Int8PtrTy); |
---|
| - for (unsigned i=0; i<NumClasses; i++) { | | + for (unsigned i = 0; i < NumClasses; i++) { |
---|
| const ObjCInterfaceDecl *ID = ImplementedClasses[i]; | | const ObjCInterfaceDecl *ID = ImplementedClasses[i]; |
---|
| assert(ID); | | assert(ID); |
---|
| if (ObjCImplementationDecl *IMP = ID->getImplementation()) | | if (ObjCImplementationDecl *IMP = ID->getImplementation()) |
---|
@@ -5191,7 +5110,7 @@ llvm::Constant *CGObjCMac::EmitModuleSymbols() { |
| | | |
---|
| array.add(DefinedClasses[i]); | | array.add(DefinedClasses[i]); |
---|
| } | | } |
---|
| - for (unsigned i=0; i<NumCategories; i++) | | + for (unsigned i = 0; i < NumCategories; i++) |
---|
| array.add(DefinedCategories[i]); | | array.add(DefinedCategories[i]); |
---|
| | | |
---|
| array.finishAndAddTo(values); | | array.finishAndAddTo(values); |
---|
@@ -5255,10 +5174,10 @@ ConstantAddress CGObjCMac::EmitSelectorAddr(Selector Sel) { |
| } | | } |
---|
| | | |
---|
| llvm::Constant *CGObjCCommonMac::GetClassName(StringRef RuntimeName) { | | llvm::Constant *CGObjCCommonMac::GetClassName(StringRef RuntimeName) { |
---|
| - llvm::GlobalVariable *&Entry = ClassNames[RuntimeName]; | | + llvm::GlobalVariable *&Entry = ClassNames[RuntimeName]; |
---|
| - if (!Entry) | | + if (!Entry) |
---|
| - Entry = CreateCStringLiteral(RuntimeName, ObjCLabelType::ClassName); | | + Entry = CreateCStringLiteral(RuntimeName, ObjCLabelType::ClassName); |
---|
| - return getConstantGEP(VMContext, Entry, 0, 0); | | + return getConstantGEP(VMContext, Entry, 0, 0); |
---|
| } | | } |
---|
| | | |
---|
| llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) { | | llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) { |
---|
@@ -5267,13 +5186,13 @@ llvm::Function *CGObjCCommonMac::GetMethodDefinition(const ObjCMethodDecl *MD) { |
| | | |
---|
| /// GetIvarLayoutName - Returns a unique constant for the given | | /// GetIvarLayoutName - Returns a unique constant for the given |
---|
| /// ivar layout bitmap. | | /// ivar layout bitmap. |
---|
| -llvm::Constant *CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident, | | +llvm::Constant * |
---|
| - const ObjCCommonTypesHelper &ObjCTypes) { | | +CGObjCCommonMac::GetIvarLayoutName(IdentifierInfo *Ident, |
---|
| | | + const ObjCCommonTypesHelper &ObjCTypes) { |
---|
| return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); | | return llvm::Constant::getNullValue(ObjCTypes.Int8PtrTy); |
---|
| } | | } |
---|
| | | |
---|
| -void IvarLayoutBuilder::visitRecord(const RecordType *RT, | | +void IvarLayoutBuilder::visitRecord(const RecordType *RT, CharUnits offset) { |
---|
| - CharUnits offset) { | | |
---|
| const RecordDecl *RD = RT->getDecl(); | | const RecordDecl *RD = RT->getDecl(); |
---|
| | | |
---|
| // If this is a union, remember that we had one, because it might mess | | // If this is a union, remember that we had one, because it might mess |
---|
@@ -5284,11 +5203,12 @@ void IvarLayoutBuilder::visitRecord(const RecordType *RT, |
| const ASTRecordLayout *recLayout = nullptr; | | const ASTRecordLayout *recLayout = nullptr; |
---|
| visitAggregate(RD->field_begin(), RD->field_end(), offset, | | visitAggregate(RD->field_begin(), RD->field_end(), offset, |
---|
| [&](const FieldDecl *field) -> CharUnits { | | [&](const FieldDecl *field) -> CharUnits { |
---|
| - if (!recLayout) | | + if (!recLayout) |
---|
| - recLayout = &CGM.getContext().getASTRecordLayout(RD); | | + recLayout = &CGM.getContext().getASTRecordLayout(RD); |
---|
| - auto offsetInBits = recLayout->getFieldOffset(field->getFieldIndex()); | | + auto offsetInBits = |
---|
| - return CGM.getContext().toCharUnitsFromBits(offsetInBits); | | + recLayout->getFieldOffset(field->getFieldIndex()); |
---|
| - }); | | + return CGM.getContext().toCharUnitsFromBits(offsetInBits); |
---|
| | | + }); |
---|
| } | | } |
---|
| | | |
---|
| template <class Iterator, class GetOffsetFn> | | template <class Iterator, class GetOffsetFn> |
---|
@@ -5331,7 +5251,8 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field, |
| | | |
---|
| // If we ended up with a zero-sized array, we've done what we can do within | | // If we ended up with a zero-sized array, we've done what we can do within |
---|
| // the limits of this layout encoding. | | // the limits of this layout encoding. |
---|
| - if (numElts == 0) return; | | + if (numElts == 0) |
---|
| | | + return; |
---|
| | | |
---|
| // Recurse if the base element type is a record type. | | // Recurse if the base element type is a record type. |
---|
| if (auto recType = fieldType->getAs<RecordType>()) { | | if (auto recType = fieldType->getAs<RecordType>()) { |
---|
@@ -5361,10 +5282,10 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field, |
| Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), fieldType); | | Qualifiers::GC GCAttr = GetGCAttrTypeForType(CGM.getContext(), fieldType); |
---|
| | | |
---|
| // If it matches what we're looking for, add an entry. | | // If it matches what we're looking for, add an entry. |
---|
| - if ((ForStrongLayout && GCAttr == Qualifiers::Strong) | | + if ((ForStrongLayout && GCAttr == Qualifiers::Strong) || |
---|
| - || (!ForStrongLayout && GCAttr == Qualifiers::Weak)) { | | + (!ForStrongLayout && GCAttr == Qualifiers::Weak)) { |
---|
| - assert(CGM.getContext().getTypeSizeInChars(fieldType) | | + assert(CGM.getContext().getTypeSizeInChars(fieldType) == |
---|
| - == CGM.getPointerSize()); | | + CGM.getPointerSize()); |
---|
| IvarsInfo.push_back(IvarInfo(fieldOffset, numElts)); | | IvarsInfo.push_back(IvarInfo(fieldOffset, numElts)); |
---|
| } | | } |
---|
| } | | } |
---|
@@ -5372,8 +5293,9 @@ void IvarLayoutBuilder::visitField(const FieldDecl *field, |
| /// buildBitmap - This routine does the horsework of taking the offsets of | | /// buildBitmap - This routine does the horsework of taking the offsets of |
---|
| /// strong/weak references and creating a bitmap. The bitmap is also | | /// strong/weak references and creating a bitmap. The bitmap is also |
---|
| /// returned in the given buffer, suitable for being passed to \c dump(). | | /// returned in the given buffer, suitable for being passed to \c dump(). |
---|
| -llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, | | +llvm::Constant * |
---|
| - llvm::SmallVectorImpl<unsigned char> &buffer) { | | +IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, |
---|
| | | + llvm::SmallVectorImpl<unsigned char> &buffer) { |
---|
| // The bitmap is a series of skip/scan instructions, aligned to word | | // The bitmap is a series of skip/scan instructions, aligned to word |
---|
| // boundaries. The skip is performed first. | | // boundaries. The skip is performed first. |
---|
| const unsigned char MaxNibble = 0xF; | | const unsigned char MaxNibble = 0xF; |
---|
@@ -5454,7 +5376,8 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, |
| | | |
---|
| // Ignore scan requests that don't start at an even multiple of the | | // Ignore scan requests that don't start at an even multiple of the |
---|
| // word size. We can't encode them. | | // word size. We can't encode them. |
---|
| - if ((beginOfScan % WordSize) != 0) continue; | | + if ((beginOfScan % WordSize) != 0) |
---|
| | | + continue; |
---|
| | | |
---|
| // Ignore scan requests that start before the instance start. | | // Ignore scan requests that start before the instance start. |
---|
| // This assumes that scans never span that boundary. The boundary | | // This assumes that scans never span that boundary. The boundary |
---|
@@ -5479,7 +5402,8 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, |
| beginOfScanInWords = endOfLastScanInWords; | | beginOfScanInWords = endOfLastScanInWords; |
---|
| | | |
---|
| // If that leaves us with nothing to scan, ignore this request. | | // If that leaves us with nothing to scan, ignore this request. |
---|
| - if (beginOfScanInWords >= endOfScanInWords) continue; | | + if (beginOfScanInWords >= endOfScanInWords) |
---|
| | | + continue; |
---|
| } | | } |
---|
| | | |
---|
| // Scan to the end of the request. | | // Scan to the end of the request. |
---|
@@ -5496,7 +5420,7 @@ llvm::Constant *IvarLayoutBuilder::buildBitmap(CGObjCCommonMac &CGObjC, |
| // or necessary for the ARC-style layout strings. | | // or necessary for the ARC-style layout strings. |
---|
| if (CGM.getLangOpts().getGC() != LangOptions::NonGC) { | | if (CGM.getLangOpts().getGC() != LangOptions::NonGC) { |
---|
| unsigned lastOffsetInWords = | | unsigned lastOffsetInWords = |
---|
| - (InstanceEnd - InstanceBegin + WordSize - CharUnits::One()) / WordSize; | | + (InstanceEnd - InstanceBegin + WordSize - CharUnits::One()) / WordSize; |
---|
| if (lastOffsetInWords > endOfLastScanInWords) { | | if (lastOffsetInWords > endOfLastScanInWords) { |
---|
| skip(lastOffsetInWords - endOfLastScanInWords); | | skip(lastOffsetInWords - endOfLastScanInWords); |
---|
| } | | } |
---|
@@ -5539,7 +5463,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, |
| return llvm::Constant::getNullValue(PtrTy); | | return llvm::Constant::getNullValue(PtrTy); |
---|
| | | |
---|
| const ObjCInterfaceDecl *OI = OMD->getClassInterface(); | | const ObjCInterfaceDecl *OI = OMD->getClassInterface(); |
---|
| - SmallVector<const ObjCIvarDecl*, 32> ivars; | | + SmallVector<const ObjCIvarDecl *, 32> ivars; |
---|
| | | |
---|
| // GC layout strings include the complete object layout, possibly | | // GC layout strings include the complete object layout, possibly |
---|
| // inaccurately in the non-fragile ABI; the runtime knows how to fix this | | // inaccurately in the non-fragile ABI; the runtime knows how to fix this |
---|
@@ -5553,22 +5477,21 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, |
| // MRC weak layout strings follow the ARC style. | | // MRC weak layout strings follow the ARC style. |
---|
| CharUnits baseOffset; | | CharUnits baseOffset; |
---|
| if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { | | if (CGM.getLangOpts().getGC() == LangOptions::NonGC) { |
---|
| - for (const ObjCIvarDecl *IVD = OI->all_declared_ivar_begin(); | | + for (const ObjCIvarDecl *IVD = OI->all_declared_ivar_begin(); IVD; |
---|
| - IVD; IVD = IVD->getNextIvar()) | | + IVD = IVD->getNextIvar()) |
---|
| ivars.push_back(IVD); | | ivars.push_back(IVD); |
---|
| | | |
---|
| if (isNonFragileABI()) { | | if (isNonFragileABI()) { |
---|
| baseOffset = beginOffset; // InstanceStart | | baseOffset = beginOffset; // InstanceStart |
---|
| } else if (!ivars.empty()) { | | } else if (!ivars.empty()) { |
---|
| baseOffset = | | baseOffset = |
---|
| - CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivars[0])); | | + CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivars[0])); |
---|
| } else { | | } else { |
---|
| baseOffset = CharUnits::Zero(); | | baseOffset = CharUnits::Zero(); |
---|
| } | | } |
---|
| | | |
---|
| baseOffset = baseOffset.alignTo(CGM.getPointerAlign()); | | baseOffset = baseOffset.alignTo(CGM.getPointerAlign()); |
---|
| - } | | + } else { |
---|
| - else { | | |
---|
| CGM.getContext().DeepCollectObjCIvars(OI, true, ivars); | | CGM.getContext().DeepCollectObjCIvars(OI, true, ivars); |
---|
| | | |
---|
| baseOffset = CharUnits::Zero(); | | baseOffset = CharUnits::Zero(); |
---|
@@ -5581,8 +5504,9 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, |
| | | |
---|
| builder.visitAggregate(ivars.begin(), ivars.end(), CharUnits::Zero(), | | builder.visitAggregate(ivars.begin(), ivars.end(), CharUnits::Zero(), |
---|
| [&](const ObjCIvarDecl *ivar) -> CharUnits { | | [&](const ObjCIvarDecl *ivar) -> CharUnits { |
---|
| - return CharUnits::fromQuantity(ComputeIvarBaseOffset(CGM, OMD, ivar)); | | + return CharUnits::fromQuantity( |
---|
| - }); | | + ComputeIvarBaseOffset(CGM, OMD, ivar)); |
---|
| | | + }); |
---|
| | | |
---|
| if (!builder.hasBitmapData()) | | if (!builder.hasBitmapData()) |
---|
| return llvm::Constant::getNullValue(PtrTy); | | return llvm::Constant::getNullValue(PtrTy); |
---|
@@ -5590,7 +5514,7 @@ CGObjCCommonMac::BuildIvarLayout(const ObjCImplementationDecl *OMD, |
| llvm::SmallVector<unsigned char, 4> buffer; | | llvm::SmallVector<unsigned char, 4> buffer; |
---|
| llvm::Constant *C = builder.buildBitmap(*this, buffer); | | llvm::Constant *C = builder.buildBitmap(*this, buffer); |
---|
| | | |
---|
| - if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { | | + if (CGM.getLangOpts().ObjCGCBitmapPrint && !buffer.empty()) { |
---|
| printf("\n%s ivar layout for class '%s': ", | | printf("\n%s ivar layout for class '%s': ", |
---|
| ForStrongLayout ? "strong" : "weak", | | ForStrongLayout ? "strong" : "weak", |
---|
| OMD->getClassInterface()->getName().str().c_str()); | | OMD->getClassInterface()->getName().str().c_str()); |
---|
@@ -5603,7 +5527,8 @@ llvm::Constant *CGObjCCommonMac::GetMethodVarName(Selector Sel) { |
| llvm::GlobalVariable *&Entry = MethodVarNames[Sel]; | | llvm::GlobalVariable *&Entry = MethodVarNames[Sel]; |
---|
| // FIXME: Avoid std::string in "Sel.getAsString()" | | // FIXME: Avoid std::string in "Sel.getAsString()" |
---|
| if (!Entry) | | if (!Entry) |
---|
| - Entry = CreateCStringLiteral(Sel.getAsString(), ObjCLabelType::MethodVarName); | | + Entry = |
---|
| | | + CreateCStringLiteral(Sel.getAsString(), ObjCLabelType::MethodVarName); |
---|
| return getConstantGEP(VMContext, Entry, 0, 0); | | return getConstantGEP(VMContext, Entry, 0, 0); |
---|
| } | | } |
---|
| | | |
---|
@@ -5625,7 +5550,7 @@ llvm::Constant *CGObjCCommonMac::GetMethodVarType(const FieldDecl *Field) { |
| llvm::Constant *CGObjCCommonMac::GetMethodVarType(const ObjCMethodDecl *D, | | llvm::Constant *CGObjCCommonMac::GetMethodVarType(const ObjCMethodDecl *D, |
---|
| bool Extended) { | | bool Extended) { |
---|
| std::string TypeStr = | | std::string TypeStr = |
---|
| - CGM.getContext().getObjCEncodingForMethodDecl(D, Extended); | | + CGM.getContext().getObjCEncodingForMethodDecl(D, Extended); |
---|
| | | |
---|
| llvm::GlobalVariable *&Entry = MethodVarTypes[TypeStr]; | | llvm::GlobalVariable *&Entry = MethodVarTypes[TypeStr]; |
---|
| if (!Entry) | | if (!Entry) |
---|
@@ -5647,7 +5572,7 @@ llvm::Constant * |
| CGObjCCommonMac::GetPropertyTypeString(const ObjCPropertyDecl *PD, | | CGObjCCommonMac::GetPropertyTypeString(const ObjCPropertyDecl *PD, |
---|
| const Decl *Container) { | | const Decl *Container) { |
---|
| std::string TypeStr = | | std::string TypeStr = |
---|
| - CGM.getContext().getObjCEncodingForPropertyDecl(PD, Container); | | + CGM.getContext().getObjCEncodingForPropertyDecl(PD, Container); |
---|
| return GetPropertyName(&CGM.getContext().Idents.get(TypeStr)); | | return GetPropertyName(&CGM.getContext().Idents.get(TypeStr)); |
---|
| } | | } |
---|
| | | |
---|
@@ -5707,8 +5632,8 @@ CGObjCNonFragileABIMac::CGObjCNonFragileABIMac(CodeGen::CodeGenModule &cgm) |
| /* *** */ | | /* *** */ |
---|
| | | |
---|
| ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) | | ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) |
---|
| - : VMContext(cgm.getLLVMContext()), CGM(cgm), ExternalProtocolPtrTy(nullptr) | | + : VMContext(cgm.getLLVMContext()), CGM(cgm), |
---|
| -{ | | + ExternalProtocolPtrTy(nullptr) { |
---|
| CodeGen::CodeGenTypes &Types = CGM.getTypes(); | | CodeGen::CodeGenTypes &Types = CGM.getTypes(); |
---|
| ASTContext &Ctx = CGM.getContext(); | | ASTContext &Ctx = CGM.getContext(); |
---|
| unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace(); | | unsigned ProgramAS = CGM.getDataLayout().getProgramAddressSpace(); |
---|
@@ -5727,12 +5652,10 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) |
| else | | else |
---|
| IvarOffsetVarTy = LongTy; | | IvarOffsetVarTy = LongTy; |
---|
| | | |
---|
| - ObjectPtrTy = | | + ObjectPtrTy = cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCIdType())); |
---|
| - cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCIdType())); | | + PtrObjectPtrTy = llvm::PointerType::getUnqual(ObjectPtrTy); |
---|
| - PtrObjectPtrTy = | | |
---|
| - llvm::PointerType::getUnqual(ObjectPtrTy); | | |
---|
| SelectorPtrTy = | | SelectorPtrTy = |
---|
| - cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCSelType())); | | + cast<llvm::PointerType>(Types.ConvertType(Ctx.getObjCSelType())); |
---|
| | | |
---|
| // I'm not sure I like this. The implicit coordination is a bit | | // I'm not sure I like this. The implicit coordination is a bit |
---|
| // gross. We should solve this in a reasonable fashion because this | | // gross. We should solve this in a reasonable fashion because this |
---|
@@ -5793,7 +5716,7 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm) |
| } | | } |
---|
| | | |
---|
| ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) | | ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) |
---|
| - : ObjCCommonTypesHelper(cgm) { | | + : ObjCCommonTypesHelper(cgm) { |
---|
| // struct _objc_method_description { | | // struct _objc_method_description { |
---|
| // SEL name; | | // SEL name; |
---|
| // char *types; | | // char *types; |
---|
@@ -5811,7 +5734,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) |
| | | |
---|
| // struct _objc_method_description_list * | | // struct _objc_method_description_list * |
---|
| MethodDescriptionListPtrTy = | | MethodDescriptionListPtrTy = |
---|
| - llvm::PointerType::getUnqual(MethodDescriptionListTy); | | + llvm::PointerType::getUnqual(MethodDescriptionListTy); |
---|
| | | |
---|
| // Protocol description structures | | // Protocol description structures |
---|
| | | |
---|
@@ -5867,13 +5790,12 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) |
| IntTy); | | IntTy); |
---|
| | | |
---|
| // struct _objc_ivar_list * | | // struct _objc_ivar_list * |
---|
| - IvarListTy = | | + IvarListTy = llvm::StructType::create(VMContext, "struct._objc_ivar_list"); |
---|
| - llvm::StructType::create(VMContext, "struct._objc_ivar_list"); | | |
---|
| IvarListPtrTy = llvm::PointerType::getUnqual(IvarListTy); | | IvarListPtrTy = llvm::PointerType::getUnqual(IvarListTy); |
---|
| | | |
---|
| // struct _objc_method_list * | | // struct _objc_method_list * |
---|
| MethodListTy = | | MethodListTy = |
---|
| - llvm::StructType::create(VMContext, "struct._objc_method_list"); | | + llvm::StructType::create(VMContext, "struct._objc_method_list"); |
---|
| MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy); | | MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy); |
---|
| | | |
---|
| // struct _objc_class_extension * | | // struct _objc_class_extension * |
---|
@@ -5954,8 +5876,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm) |
| llvm::ArrayType::get(CGM.Int32Ty, SetJmpBufferSize), StackPtrTy); | | llvm::ArrayType::get(CGM.Int32Ty, SetJmpBufferSize), StackPtrTy); |
---|
| } | | } |
---|
| | | |
---|
| -ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModule &cgm) | | +ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper( |
---|
| - : ObjCCommonTypesHelper(cgm) { | | + CodeGen::CodeGenModule &cgm) |
---|
| | | + : ObjCCommonTypesHelper(cgm) { |
---|
| // struct _method_list_t { | | // struct _method_list_t { |
---|
| // uint32_t entsize; // sizeof(struct _objc_method) | | // uint32_t entsize; // sizeof(struct _objc_method) |
---|
| // uint32_t method_count; | | // uint32_t method_count; |
---|
@@ -6122,7 +6045,6 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul |
| // SuperMessageRefPtrTy - LLVM for struct _super_message_ref_t* | | // SuperMessageRefPtrTy - LLVM for struct _super_message_ref_t* |
---|
| SuperMessageRefPtrTy = llvm::PointerType::getUnqual(SuperMessageRefTy); | | SuperMessageRefPtrTy = llvm::PointerType::getUnqual(SuperMessageRefTy); |
---|
| | | |
---|
| - | | |
---|
| // struct objc_typeinfo { | | // struct objc_typeinfo { |
---|
| // const void** vtable; // objc_ehtype_vtable + 2 | | // const void** vtable; // objc_ehtype_vtable + 2 |
---|
| // const char* name; // c++ typeinfo string | | // const char* name; // c++ typeinfo string |
---|
@@ -6148,14 +6070,12 @@ void CGObjCNonFragileABIMac::AddModuleClassList( |
| if (!NumClasses) | | if (!NumClasses) |
---|
| return; | | return; |
---|
| | | |
---|
| - SmallVector<llvm::Constant*, 8> Symbols(NumClasses); | | + SmallVector<llvm::Constant *, 8> Symbols(NumClasses); |
---|
| - for (unsigned i=0; i<NumClasses; i++) | | + for (unsigned i = 0; i < NumClasses; i++) |
---|
| Symbols[i] = Container[i]; | | Symbols[i] = Container[i]; |
---|
| | | |
---|
| - llvm::Constant *Init = | | + llvm::Constant *Init = llvm::ConstantArray::get( |
---|
| - llvm::ConstantArray::get(llvm::ArrayType::get(ObjCTypes.Int8PtrTy, | | + llvm::ArrayType::get(ObjCTypes.Int8PtrTy, Symbols.size()), Symbols); |
---|
| - Symbols.size()), | | |
---|
| - Symbols); | | |
---|
| | | |
---|
| // Section name is obtained by calling GetSectionName, which returns | | // Section name is obtained by calling GetSectionName, which returns |
---|
| // sections in the __DATA segment on MachO. | | // sections in the __DATA segment on MachO. |
---|
@@ -6176,36 +6096,37 @@ void CGObjCNonFragileABIMac::FinishNonFragileABIModule() { |
| // Build list of all implemented class addresses in array | | // Build list of all implemented class addresses in array |
---|
| // L_OBJC_LABEL_CLASS_$. | | // L_OBJC_LABEL_CLASS_$. |
---|
| | | |
---|
| - for (unsigned i=0, NumClasses=ImplementedClasses.size(); i<NumClasses; i++) { | | + for (unsigned i = 0, NumClasses = ImplementedClasses.size(); i < NumClasses; |
---|
| | | + i++) { |
---|
| const ObjCInterfaceDecl *ID = ImplementedClasses[i]; | | const ObjCInterfaceDecl *ID = ImplementedClasses[i]; |
---|
| assert(ID); | | assert(ID); |
---|
| if (ObjCImplementationDecl *IMP = ID->getImplementation()) | | if (ObjCImplementationDecl *IMP = ID->getImplementation()) |
---|
| // We are implementing a weak imported interface. Give it external linkage | | // We are implementing a weak imported interface. Give it external linkage |
---|
| if (ID->isWeakImported() && !IMP->isWeakImported()) { | | if (ID->isWeakImported() && !IMP->isWeakImported()) { |
---|
| DefinedClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage); | | DefinedClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage); |
---|
| - DefinedMetaClasses[i]->setLinkage(llvm::GlobalVariable::ExternalLinkage); | | + DefinedMetaClasses[i]->setLinkage( |
---|
| | | + llvm::GlobalVariable::ExternalLinkage); |
---|
| } | | } |
---|
| } | | } |
---|
| | | |
---|
| - AddModuleClassList(DefinedClasses, "OBJC_LABEL_CLASS_$", | | + AddModuleClassList( |
---|
| - GetSectionName("__objc_classlist", | | + DefinedClasses, "OBJC_LABEL_CLASS_$", |
---|
| - "regular,no_dead_strip")); | | + GetSectionName("__objc_classlist", "regular,no_dead_strip")); |
---|
| | | |
---|
| - AddModuleClassList(DefinedNonLazyClasses, "OBJC_LABEL_NONLAZY_CLASS_$", | | + AddModuleClassList( |
---|
| - GetSectionName("__objc_nlclslist", | | + DefinedNonLazyClasses, "OBJC_LABEL_NONLAZY_CLASS_$", |
---|
| - "regular,no_dead_strip")); | | + GetSectionName("__objc_nlclslist", "regular,no_dead_strip")); |
---|
| | | |
---|
| // Build list of all implemented category addresses in array | | // Build list of all implemented category addresses in array |
---|
| // L_OBJC_LABEL_CATEGORY_$. | | // L_OBJC_LABEL_CATEGORY_$. |
---|
| AddModuleClassList(DefinedCategories, "OBJC_LABEL_CATEGORY_$", | | AddModuleClassList(DefinedCategories, "OBJC_LABEL_CATEGORY_$", |
---|
| - GetSectionName("__objc_catlist", | | + GetSectionName("__objc_catlist", "regular,no_dead_strip")); |
---|
| - "regular,no_dead_strip")); | | + AddModuleClassList( |
---|
| - AddModuleClassList(DefinedStubCategories, "OBJC_LABEL_STUB_CATEGORY_$", | | + DefinedStubCategories, "OBJC_LABEL_STUB_CATEGORY_$", |
---|
| - GetSectionName("__objc_catlist2", | | + GetSectionName("__objc_catlist2", "regular,no_dead_strip")); |
---|
| - "regular,no_dead_strip")); | | + AddModuleClassList( |
---|
| - AddModuleClassList(DefinedNonLazyCategories, "OBJC_LABEL_NONLAZY_CATEGORY_$", | | + DefinedNonLazyCategories, "OBJC_LABEL_NONLAZY_CATEGORY_$", |
---|
| - GetSectionName("__objc_nlcatlist", | | + GetSectionName("__objc_nlcatlist", "regular,no_dead_strip")); |
---|
| - "regular,no_dead_strip")); | | |
---|
| | | |
---|
| EmitImageInfo(); | | EmitImageInfo(); |
---|
| } | | } |
---|
@@ -6264,7 +6185,7 @@ bool CGObjCNonFragileABIMac::isVTableDispatchedSelector(Selector Sel) { |
| &CGM.getContext().Idents.get("objects"), | | &CGM.getContext().Idents.get("objects"), |
---|
| &CGM.getContext().Idents.get("count")}; | | &CGM.getContext().Idents.get("count")}; |
---|
| VTableDispatchMethods.insert( | | VTableDispatchMethods.insert( |
---|
| - CGM.getContext().Selectors.getSelector(3, KeyIdents)); | | + CGM.getContext().Selectors.getSelector(3, KeyIdents)); |
---|
| } | | } |
---|
| } | | } |
---|
| | | |
---|
@@ -6286,11 +6207,9 @@ bool CGObjCNonFragileABIMac::isVTableDispatchedSelector(Selector Sel) { |
| /// const struct _prop_list_t * const properties; | | /// const struct _prop_list_t * const properties; |
---|
| /// } | | /// } |
---|
| /// | | /// |
---|
| -llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( | | +llvm::GlobalVariable *CGObjCNonFragileABIMac::BuildClassRoTInitializer( |
---|
| - unsigned flags, | | + unsigned flags, unsigned InstanceStart, unsigned InstanceSize, |
---|
| - unsigned InstanceStart, | | + const ObjCImplementationDecl *ID) { |
---|
| - unsigned InstanceSize, | | |
---|
| - const ObjCImplementationDecl *ID) { | | |
---|
| std::string ClassName = std::string(ID->getObjCRuntimeNameAsString()); | | std::string ClassName = std::string(ID->getObjCRuntimeNameAsString()); |
---|
| | | |
---|
| CharUnits beginInstance = CharUnits::fromQuantity(InstanceStart); | | CharUnits beginInstance = CharUnits::fromQuantity(InstanceStart); |
---|
@@ -6309,12 +6228,12 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( |
| values.addInt(ObjCTypes.IntTy, InstanceStart); | | values.addInt(ObjCTypes.IntTy, InstanceStart); |
---|
| values.addInt(ObjCTypes.IntTy, InstanceSize); | | values.addInt(ObjCTypes.IntTy, InstanceSize); |
---|
| values.add((flags & NonFragileABI_Class_Meta) | | values.add((flags & NonFragileABI_Class_Meta) |
---|
| - ? GetIvarLayoutName(nullptr, ObjCTypes) | | + ? GetIvarLayoutName(nullptr, ObjCTypes) |
---|
| - : BuildStrongIvarLayout(ID, beginInstance, endInstance)); | | + : BuildStrongIvarLayout(ID, beginInstance, endInstance)); |
---|
| values.add(GetClassName(ID->getObjCRuntimeNameAsString())); | | values.add(GetClassName(ID->getObjCRuntimeNameAsString())); |
---|
| | | |
---|
| // const struct _method_list_t * const baseMethods; | | // const struct _method_list_t * const baseMethods; |
---|
| - SmallVector<const ObjCMethodDecl*, 16> methods; | | + SmallVector<const ObjCMethodDecl *, 16> methods; |
---|
| if (flags & NonFragileABI_Class_Meta) { | | if (flags & NonFragileABI_Class_Meta) { |
---|
| for (const auto *MD : ID->class_methods()) | | for (const auto *MD : ID->class_methods()) |
---|
| if (!MD->isDirectMethod()) | | if (!MD->isDirectMethod()) |
---|
@@ -6327,29 +6246,29 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( |
| | | |
---|
| values.add(emitMethodList(ID->getObjCRuntimeNameAsString(), | | values.add(emitMethodList(ID->getObjCRuntimeNameAsString(), |
---|
| (flags & NonFragileABI_Class_Meta) | | (flags & NonFragileABI_Class_Meta) |
---|
| - ? MethodListType::ClassMethods | | + ? MethodListType::ClassMethods |
---|
| - : MethodListType::InstanceMethods, | | + : MethodListType::InstanceMethods, |
---|
| methods)); | | methods)); |
---|
| | | |
---|
| const ObjCInterfaceDecl *OID = ID->getClassInterface(); | | const ObjCInterfaceDecl *OID = ID->getClassInterface(); |
---|
| assert(OID && "CGObjCNonFragileABIMac::BuildClassRoTInitializer"); | | assert(OID && "CGObjCNonFragileABIMac::BuildClassRoTInitializer"); |
---|
| - values.add(EmitProtocolList("_OBJC_CLASS_PROTOCOLS_$_" | | + values.add(EmitProtocolList("_OBJC_CLASS_PROTOCOLS_$_" + |
---|
| - + OID->getObjCRuntimeNameAsString(), | | + OID->getObjCRuntimeNameAsString(), |
---|
| OID->all_referenced_protocol_begin(), | | OID->all_referenced_protocol_begin(), |
---|
| OID->all_referenced_protocol_end())); | | OID->all_referenced_protocol_end())); |
---|
| | | |
---|
| if (flags & NonFragileABI_Class_Meta) { | | if (flags & NonFragileABI_Class_Meta) { |
---|
| values.addNullPointer(ObjCTypes.IvarListnfABIPtrTy); | | values.addNullPointer(ObjCTypes.IvarListnfABIPtrTy); |
---|
| values.add(GetIvarLayoutName(nullptr, ObjCTypes)); | | values.add(GetIvarLayoutName(nullptr, ObjCTypes)); |
---|
| - values.add(EmitPropertyList( | | + values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + |
---|
| - "_OBJC_$_CLASS_PROP_LIST_" + ID->getObjCRuntimeNameAsString(), | | + ID->getObjCRuntimeNameAsString(), |
---|
| - ID, ID->getClassInterface(), ObjCTypes, true)); | | + ID, ID->getClassInterface(), ObjCTypes, true)); |
---|
| } else { | | } else { |
---|
| values.add(EmitIvarList(ID)); | | values.add(EmitIvarList(ID)); |
---|
| values.add(BuildWeakIvarLayout(ID, beginInstance, endInstance, hasMRCWeak)); | | values.add(BuildWeakIvarLayout(ID, beginInstance, endInstance, hasMRCWeak)); |
---|
| - values.add(EmitPropertyList( | | + values.add(EmitPropertyList("_OBJC_$_PROP_LIST_" + |
---|
| - "_OBJC_$_PROP_LIST_" + ID->getObjCRuntimeNameAsString(), | | + ID->getObjCRuntimeNameAsString(), |
---|
| - ID, ID->getClassInterface(), ObjCTypes, false)); | | + ID, ID->getClassInterface(), ObjCTypes, false)); |
---|
| } | | } |
---|
| | | |
---|
| llvm::SmallString<64> roLabel; | | llvm::SmallString<64> roLabel; |
---|
@@ -6371,13 +6290,10 @@ llvm::GlobalVariable * CGObjCNonFragileABIMac::BuildClassRoTInitializer( |
| /// struct class_ro_t *ro; | | /// struct class_ro_t *ro; |
---|
| /// } | | /// } |
---|
| /// | | /// |
---|
| -llvm::GlobalVariable * | | +llvm::GlobalVariable *CGObjCNonFragileABIMac::BuildClassObject( |
---|
| -CGObjCNonFragileABIMac::BuildClassObject(const ObjCInterfaceDecl *CI, | | + const ObjCInterfaceDecl *CI, bool isMetaclass, llvm::Constant *IsAGV, |
---|
| - bool isMetaclass, | | + llvm::Constant *SuperClassGV, llvm::Constant *ClassRoGV, |
---|
| - llvm::Constant *IsAGV, | | + bool HiddenVisibility) { |
---|
| - llvm::Constant *SuperClassGV, | | |
---|
| - llvm::Constant *ClassRoGV, | | |
---|
| - bool HiddenVisibility) { | | |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto values = builder.beginStruct(ObjCTypes.ClassnfABITy); | | auto values = builder.beginStruct(ObjCTypes.ClassnfABITy); |
---|
| values.add(IsAGV); | | values.add(IsAGV); |
---|
@@ -6390,8 +6306,8 @@ CGObjCNonFragileABIMac::BuildClassObject(const ObjCInterfaceDecl *CI, |
| values.add(ObjCEmptyVtableVar); | | values.add(ObjCEmptyVtableVar); |
---|
| values.add(ClassRoGV); | | values.add(ClassRoGV); |
---|
| | | |
---|
| - llvm::GlobalVariable *GV = | | + llvm::GlobalVariable *GV = cast<llvm::GlobalVariable>( |
---|
| - cast<llvm::GlobalVariable>(GetClassGlobal(CI, isMetaclass, ForDefinition)); | | + GetClassGlobal(CI, isMetaclass, ForDefinition)); |
---|
| values.finishAndSetAsInitializer(GV); | | values.finishAndSetAsInitializer(GV); |
---|
| | | |
---|
| if (CGM.getTriple().isOSBinFormatMachO()) | | if (CGM.getTriple().isOSBinFormatMachO()) |
---|
@@ -6414,7 +6330,7 @@ void CGObjCNonFragileABIMac::GetClassSizeInfo(const ObjCImplementationDecl *OID, |
| uint32_t &InstanceStart, | | uint32_t &InstanceStart, |
---|
| uint32_t &InstanceSize) { | | uint32_t &InstanceSize) { |
---|
| const ASTRecordLayout &RL = | | const ASTRecordLayout &RL = |
---|
| - CGM.getContext().getASTObjCImplementationLayout(OID); | | + CGM.getContext().getASTObjCImplementationLayout(OID); |
---|
| | | |
---|
| // InstanceSize is really instance end. | | // InstanceSize is really instance end. |
---|
| InstanceSize = RL.getDataSize().getQuantity(); | | InstanceSize = RL.getDataSize().getQuantity(); |
---|
@@ -6448,27 +6364,26 @@ static llvm::GlobalValue::DLLStorageClassTypes getStorage(CodeGenModule &CGM, |
| | | |
---|
| void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { | | void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { |
---|
| if (!ObjCEmptyCacheVar) { | | if (!ObjCEmptyCacheVar) { |
---|
| - ObjCEmptyCacheVar = | | + ObjCEmptyCacheVar = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.CacheTy, false, | | + CGM.getModule(), ObjCTypes.CacheTy, false, |
---|
| - llvm::GlobalValue::ExternalLinkage, nullptr, | | + llvm::GlobalValue::ExternalLinkage, nullptr, "_objc_empty_cache"); |
---|
| - "_objc_empty_cache"); | | |
---|
| if (CGM.getTriple().isOSBinFormatCOFF()) | | if (CGM.getTriple().isOSBinFormatCOFF()) |
---|
| - ObjCEmptyCacheVar->setDLLStorageClass(getStorage(CGM, "_objc_empty_cache")); | | + ObjCEmptyCacheVar->setDLLStorageClass( |
---|
| | | + getStorage(CGM, "_objc_empty_cache")); |
---|
| | | |
---|
| // Only OS X with deployment version <10.9 use the empty vtable symbol | | // Only OS X with deployment version <10.9 use the empty vtable symbol |
---|
| const llvm::Triple &Triple = CGM.getTarget().getTriple(); | | const llvm::Triple &Triple = CGM.getTarget().getTriple(); |
---|
| if (Triple.isMacOSX() && Triple.isMacOSXVersionLT(10, 9)) | | if (Triple.isMacOSX() && Triple.isMacOSXVersionLT(10, 9)) |
---|
| - ObjCEmptyVtableVar = | | + ObjCEmptyVtableVar = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ImpnfABITy, false, | | + CGM.getModule(), ObjCTypes.ImpnfABITy, false, |
---|
| - llvm::GlobalValue::ExternalLinkage, nullptr, | | + llvm::GlobalValue::ExternalLinkage, nullptr, "_objc_empty_vtable"); |
---|
| - "_objc_empty_vtable"); | | |
---|
| else | | else |
---|
| ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy); | | ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy); |
---|
| } | | } |
---|
| | | |
---|
| // FIXME: Is this correct (that meta class size is never computed)? | | // FIXME: Is this correct (that meta class size is never computed)? |
---|
| uint32_t InstanceStart = | | uint32_t InstanceStart = |
---|
| - CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassnfABITy); | | + CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ClassnfABITy); |
---|
| uint32_t InstanceSize = InstanceStart; | | uint32_t InstanceSize = InstanceStart; |
---|
| uint32_t flags = NonFragileABI_Class_Meta; | | uint32_t flags = NonFragileABI_Class_Meta; |
---|
| | | |
---|
@@ -6512,9 +6427,8 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| llvm::GlobalVariable *CLASS_RO_GV = | | llvm::GlobalVariable *CLASS_RO_GV = |
---|
| BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); | | BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); |
---|
| | | |
---|
| - llvm::GlobalVariable *MetaTClass = | | + llvm::GlobalVariable *MetaTClass = BuildClassObject( |
---|
| - BuildClassObject(CI, /*metaclass*/ true, | | + CI, /*metaclass*/ true, IsAGV, SuperClassGV, CLASS_RO_GV, classIsHidden); |
---|
| - IsAGV, SuperClassGV, CLASS_RO_GV, classIsHidden); | | |
---|
| CGM.setGVProperties(MetaTClass, CI); | | CGM.setGVProperties(MetaTClass, CI); |
---|
| DefinedMetaClasses.push_back(MetaTClass); | | DefinedMetaClasses.push_back(MetaTClass); |
---|
| | | |
---|
@@ -6553,8 +6467,8 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); | | BuildClassRoTInitializer(flags, InstanceStart, InstanceSize, ID); |
---|
| | | |
---|
| llvm::GlobalVariable *ClassMD = | | llvm::GlobalVariable *ClassMD = |
---|
| - BuildClassObject(CI, /*metaclass*/ false, | | + BuildClassObject(CI, /*metaclass*/ false, MetaTClass, SuperClassGV, |
---|
| - MetaTClass, SuperClassGV, CLASS_RO_GV, classIsHidden); | | + CLASS_RO_GV, classIsHidden); |
---|
| CGM.setGVProperties(ClassMD, CI); | | CGM.setGVProperties(ClassMD, CI); |
---|
| DefinedClasses.push_back(ClassMD); | | DefinedClasses.push_back(ClassMD); |
---|
| ImplementedClasses.push_back(CI); | | ImplementedClasses.push_back(CI); |
---|
@@ -6565,7 +6479,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| | | |
---|
| // Force the definition of the EHType if necessary. | | // Force the definition of the EHType if necessary. |
---|
| if (flags & NonFragileABI_Class_Exception) | | if (flags & NonFragileABI_Class_Exception) |
---|
| - (void) GetInterfaceEHType(CI, ForDefinition); | | + (void)GetInterfaceEHType(CI, ForDefinition); |
---|
| // Make sure method definition entries are all clear for next implementation. | | // Make sure method definition entries are all clear for next implementation. |
---|
| MethodDefinitions.clear(); | | MethodDefinitions.clear(); |
---|
| } | | } |
---|
@@ -6578,8 +6492,9 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) { |
| /// It generates a weak reference to l_OBJC_PROTOCOL_REFERENCE_$_Proto1 | | /// It generates a weak reference to l_OBJC_PROTOCOL_REFERENCE_$_Proto1 |
---|
| /// which will hold address of the protocol meta-data. | | /// which will hold address of the protocol meta-data. |
---|
| /// | | /// |
---|
| -llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF, | | +llvm::Value * |
---|
| - const ObjCProtocolDecl *PD) { | | +CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF, |
---|
| | | + const ObjCProtocolDecl *PD) { |
---|
| | | |
---|
| // This routine is called for @protocol only. So, we must build definition | | // This routine is called for @protocol only. So, we must build definition |
---|
| // of protocol's meta-data (not a reference to it!) | | // of protocol's meta-data (not a reference to it!) |
---|
@@ -6598,8 +6513,8 @@ llvm::Value *CGObjCNonFragileABIMac::GenerateProtocolRef(CodeGenFunction &CGF, |
| PTGV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, | | PTGV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(), false, |
---|
| llvm::GlobalValue::WeakAnyLinkage, Init, | | llvm::GlobalValue::WeakAnyLinkage, Init, |
---|
| ProtocolName); | | ProtocolName); |
---|
| - PTGV->setSection(GetSectionName("__objc_protorefs", | | + PTGV->setSection( |
---|
| - "coalesced,no_dead_strip")); | | + GetSectionName("__objc_protorefs", "coalesced,no_dead_strip")); |
---|
| PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); | | PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); |
---|
| PTGV->setAlignment(Align.getAsAlign()); | | PTGV->setAlignment(Align.getAsAlign()); |
---|
| if (!CGM.getTriple().isOSBinFormatMachO()) | | if (!CGM.getTriple().isOSBinFormatMachO()) |
---|
@@ -6749,9 +6664,8 @@ void CGObjCNonFragileABIMac::emitMethodConstant(ConstantArrayBuilder &builder, |
| /// struct _objc_method method_list[method_count]; | | /// struct _objc_method method_list[method_count]; |
---|
| /// } | | /// } |
---|
| /// | | /// |
---|
| -llvm::Constant * | | +llvm::Constant *CGObjCNonFragileABIMac::emitMethodList( |
---|
| -CGObjCNonFragileABIMac::emitMethodList(Twine name, MethodListType kind, | | + Twine name, MethodListType kind, ArrayRef<const ObjCMethodDecl *> methods) { |
---|
| - ArrayRef<const ObjCMethodDecl *> methods) { | | |
---|
| // Return null for empty list. | | // Return null for empty list. |
---|
| if (methods.empty()) | | if (methods.empty()) |
---|
| return llvm::Constant::getNullValue(ObjCTypes.MethodListnfABIPtrTy); | | return llvm::Constant::getNullValue(ObjCTypes.MethodListnfABIPtrTy); |
---|
@@ -6824,10 +6738,9 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, |
| Name += Ivar->getName(); | | Name += Ivar->getName(); |
---|
| llvm::GlobalVariable *IvarOffsetGV = CGM.getModule().getGlobalVariable(Name); | | llvm::GlobalVariable *IvarOffsetGV = CGM.getModule().getGlobalVariable(Name); |
---|
| if (!IvarOffsetGV) { | | if (!IvarOffsetGV) { |
---|
| - IvarOffsetGV = | | + IvarOffsetGV = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.IvarOffsetVarTy, | | + CGM.getModule(), ObjCTypes.IvarOffsetVarTy, false, |
---|
| - false, llvm::GlobalValue::ExternalLinkage, | | + llvm::GlobalValue::ExternalLinkage, nullptr, Name.str()); |
---|
| - nullptr, Name.str()); | | |
---|
| if (CGM.getTriple().isOSBinFormatCOFF()) { | | if (CGM.getTriple().isOSBinFormatCOFF()) { |
---|
| bool IsPrivateOrPackage = | | bool IsPrivateOrPackage = |
---|
| Ivar->getAccessControl() == ObjCIvarDecl::Private || | | Ivar->getAccessControl() == ObjCIvarDecl::Private || |
---|
@@ -6836,11 +6749,11 @@ CGObjCNonFragileABIMac::ObjCIvarOffsetVariable(const ObjCInterfaceDecl *ID, |
| const ObjCInterfaceDecl *ContainingID = Ivar->getContainingInterface(); | | const ObjCInterfaceDecl *ContainingID = Ivar->getContainingInterface(); |
---|
| | | |
---|
| if (ContainingID->hasAttr<DLLImportAttr>()) | | if (ContainingID->hasAttr<DLLImportAttr>()) |
---|
| - IvarOffsetGV | | + IvarOffsetGV->setDLLStorageClass( |
---|
| - ->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass); | | + llvm::GlobalValue::DLLImportStorageClass); |
---|
| else if (ContainingID->hasAttr<DLLExportAttr>() && !IsPrivateOrPackage) | | else if (ContainingID->hasAttr<DLLExportAttr>() && !IsPrivateOrPackage) |
---|
| - IvarOffsetGV | | + IvarOffsetGV->setDLLStorageClass( |
---|
| - ->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass); | | + llvm::GlobalValue::DLLExportStorageClass); |
---|
| } | | } |
---|
| } | | } |
---|
| return IvarOffsetGV; | | return IvarOffsetGV; |
---|
@@ -6895,8 +6808,8 @@ CGObjCNonFragileABIMac::EmitIvarOffsetVar(const ObjCInterfaceDecl *ID, |
| /// } | | /// } |
---|
| /// | | /// |
---|
| | | |
---|
| -llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( | | +llvm::Constant * |
---|
| - const ObjCImplementationDecl *ID) { | | +CGObjCNonFragileABIMac::EmitIvarList(const ObjCImplementationDecl *ID) { |
---|
| | | |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto ivarList = builder.beginStruct(); | | auto ivarList = builder.beginStruct(); |
---|
@@ -6910,8 +6823,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( |
| | | |
---|
| // FIXME. Consolidate this with similar code in GenerateClass. | | // FIXME. Consolidate this with similar code in GenerateClass. |
---|
| | | |
---|
| - for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin(); | | + for (const ObjCIvarDecl *IVD = OID->all_declared_ivar_begin(); IVD; |
---|
| - IVD; IVD = IVD->getNextIvar()) { | | + IVD = IVD->getNextIvar()) { |
---|
| // Ignore unnamed bit-fields. | | // Ignore unnamed bit-fields. |
---|
| if (!IVD->getDeclName()) | | if (!IVD->getDeclName()) |
---|
| continue; | | continue; |
---|
@@ -6921,11 +6834,11 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( |
| ComputeIvarBaseOffset(CGM, ID, IVD))); | | ComputeIvarBaseOffset(CGM, ID, IVD))); |
---|
| ivar.add(GetMethodVarName(IVD->getIdentifier())); | | ivar.add(GetMethodVarName(IVD->getIdentifier())); |
---|
| ivar.add(GetMethodVarType(IVD)); | | ivar.add(GetMethodVarType(IVD)); |
---|
| - llvm::Type *FieldTy = | | + llvm::Type *FieldTy = CGM.getTypes().ConvertTypeForMem(IVD->getType()); |
---|
| - CGM.getTypes().ConvertTypeForMem(IVD->getType()); | | |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(FieldTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(FieldTy); |
---|
| - unsigned Align = CGM.getContext().getPreferredTypeAlign( | | + unsigned Align = |
---|
| - IVD->getType().getTypePtr()) >> 3; | | + CGM.getContext().getPreferredTypeAlign(IVD->getType().getTypePtr()) >> |
---|
| | | + 3; |
---|
| Align = llvm::Log2_32(Align); | | Align = llvm::Log2_32(Align); |
---|
| ivar.addInt(ObjCTypes.IntTy, Align); | | ivar.addInt(ObjCTypes.IntTy, Align); |
---|
| // NOTE. Size of a bitfield does not match gcc's, because of the | | // NOTE. Size of a bitfield does not match gcc's, because of the |
---|
@@ -6954,8 +6867,8 @@ llvm::Constant *CGObjCNonFragileABIMac::EmitIvarList( |
| return GV; | | return GV; |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef( | | +llvm::Constant * |
---|
| - const ObjCProtocolDecl *PD) { | | +CGObjCNonFragileABIMac::GetOrEmitProtocolRef(const ObjCProtocolDecl *PD) { |
---|
| llvm::GlobalVariable *&Entry = Protocols[PD->getIdentifier()]; | | llvm::GlobalVariable *&Entry = Protocols[PD->getIdentifier()]; |
---|
| | | |
---|
| assert(!PD->isNonRuntimeProtocol() && | | assert(!PD->isNonRuntimeProtocol() && |
---|
@@ -6965,8 +6878,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef( |
| // reference or not. At module finalization we add the empty | | // reference or not. At module finalization we add the empty |
---|
| // contents for protocols which were referenced but never defined. | | // contents for protocols which were referenced but never defined. |
---|
| llvm::SmallString<64> Protocol; | | llvm::SmallString<64> Protocol; |
---|
| - llvm::raw_svector_ostream(Protocol) << "_OBJC_PROTOCOL_$_" | | + llvm::raw_svector_ostream(Protocol) |
---|
| - << PD->getObjCRuntimeNameAsString(); | | + << "_OBJC_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString(); |
---|
| | | |
---|
| Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, | | Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABITy, |
---|
| false, llvm::GlobalValue::ExternalLinkage, | | false, llvm::GlobalValue::ExternalLinkage, |
---|
@@ -6998,8 +6911,8 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocolRef( |
| /// @endcode | | /// @endcode |
---|
| /// | | /// |
---|
| | | |
---|
| -llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( | | +llvm::Constant * |
---|
| - const ObjCProtocolDecl *PD) { | | +CGObjCNonFragileABIMac::GetOrEmitProtocol(const ObjCProtocolDecl *PD) { |
---|
| llvm::GlobalVariable *Entry = Protocols[PD->getIdentifier()]; | | llvm::GlobalVariable *Entry = Protocols[PD->getIdentifier()]; |
---|
| | | |
---|
| // Early exit if a defining object has already been generated. | | // Early exit if a defining object has already been generated. |
---|
@@ -7019,36 +6932,34 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( |
| // isa is NULL | | // isa is NULL |
---|
| values.addNullPointer(ObjCTypes.ObjectPtrTy); | | values.addNullPointer(ObjCTypes.ObjectPtrTy); |
---|
| values.add(GetClassName(PD->getObjCRuntimeNameAsString())); | | values.add(GetClassName(PD->getObjCRuntimeNameAsString())); |
---|
| - values.add(EmitProtocolList("_OBJC_$_PROTOCOL_REFS_" | | + values.add(EmitProtocolList("_OBJC_$_PROTOCOL_REFS_" + |
---|
| - + PD->getObjCRuntimeNameAsString(), | | + PD->getObjCRuntimeNameAsString(), |
---|
| - PD->protocol_begin(), | | + PD->protocol_begin(), PD->protocol_end())); |
---|
| - PD->protocol_end())); | | + values.add(methodLists.emitMethodList( |
---|
| - values.add(methodLists.emitMethodList(this, PD, | | + this, PD, ProtocolMethodLists::RequiredInstanceMethods)); |
---|
| - ProtocolMethodLists::RequiredInstanceMethods)); | | + values.add(methodLists.emitMethodList( |
---|
| - values.add(methodLists.emitMethodList(this, PD, | | + this, PD, ProtocolMethodLists::RequiredClassMethods)); |
---|
| - ProtocolMethodLists::RequiredClassMethods)); | | + values.add(methodLists.emitMethodList( |
---|
| - values.add(methodLists.emitMethodList(this, PD, | | + this, PD, ProtocolMethodLists::OptionalInstanceMethods)); |
---|
| - ProtocolMethodLists::OptionalInstanceMethods)); | | + values.add(methodLists.emitMethodList( |
---|
| - values.add(methodLists.emitMethodList(this, PD, | | + this, PD, ProtocolMethodLists::OptionalClassMethods)); |
---|
| - ProtocolMethodLists::OptionalClassMethods)); | | + values.add( |
---|
| - values.add(EmitPropertyList( | | + EmitPropertyList("_OBJC_$_PROP_LIST_" + PD->getObjCRuntimeNameAsString(), |
---|
| - "_OBJC_$_PROP_LIST_" + PD->getObjCRuntimeNameAsString(), | | + nullptr, PD, ObjCTypes, false)); |
---|
| - nullptr, PD, ObjCTypes, false)); | | |
---|
| uint32_t Size = | | uint32_t Size = |
---|
| - CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolnfABITy); | | + CGM.getDataLayout().getTypeAllocSize(ObjCTypes.ProtocolnfABITy); |
---|
| values.addInt(ObjCTypes.IntTy, Size); | | values.addInt(ObjCTypes.IntTy, Size); |
---|
| values.addInt(ObjCTypes.IntTy, 0); | | values.addInt(ObjCTypes.IntTy, 0); |
---|
| - values.add(EmitProtocolMethodTypes("_OBJC_$_PROTOCOL_METHOD_TYPES_" | | + values.add(EmitProtocolMethodTypes( |
---|
| - + PD->getObjCRuntimeNameAsString(), | | + "_OBJC_$_PROTOCOL_METHOD_TYPES_" + PD->getObjCRuntimeNameAsString(), |
---|
| - methodLists.emitExtendedTypesArray(this), | | + methodLists.emitExtendedTypesArray(this), ObjCTypes)); |
---|
| - ObjCTypes)); | | |
---|
| | | |
---|
| // const char *demangledName; | | // const char *demangledName; |
---|
| values.addNullPointer(ObjCTypes.Int8PtrTy); | | values.addNullPointer(ObjCTypes.Int8PtrTy); |
---|
| | | |
---|
| - values.add(EmitPropertyList( | | + values.add(EmitPropertyList("_OBJC_$_CLASS_PROP_LIST_" + |
---|
| - "_OBJC_$_CLASS_PROP_LIST_" + PD->getObjCRuntimeNameAsString(), | | + PD->getObjCRuntimeNameAsString(), |
---|
| - nullptr, PD, ObjCTypes, true)); | | + nullptr, PD, ObjCTypes, true)); |
---|
| | | |
---|
| if (Entry) { | | if (Entry) { |
---|
| // Already created, fix the linkage and update the initializer. | | // Already created, fix the linkage and update the initializer. |
---|
@@ -7057,7 +6968,7 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( |
| } else { | | } else { |
---|
| llvm::SmallString<64> symbolName; | | llvm::SmallString<64> symbolName; |
---|
| llvm::raw_svector_ostream(symbolName) | | llvm::raw_svector_ostream(symbolName) |
---|
| - << "_OBJC_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString(); | | + << "_OBJC_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString(); |
---|
| | | |
---|
| Entry = values.finishAndCreateGlobal(symbolName, CGM.getPointerAlign(), | | Entry = values.finishAndCreateGlobal(symbolName, CGM.getPointerAlign(), |
---|
| /*constant*/ false, | | /*constant*/ false, |
---|
@@ -7073,19 +6984,18 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( |
| // Use this protocol meta-data to build protocol list table in section | | // Use this protocol meta-data to build protocol list table in section |
---|
| // __DATA, __objc_protolist | | // __DATA, __objc_protolist |
---|
| llvm::SmallString<64> ProtocolRef; | | llvm::SmallString<64> ProtocolRef; |
---|
| - llvm::raw_svector_ostream(ProtocolRef) << "_OBJC_LABEL_PROTOCOL_$_" | | + llvm::raw_svector_ostream(ProtocolRef) |
---|
| - << PD->getObjCRuntimeNameAsString(); | | + << "_OBJC_LABEL_PROTOCOL_$_" << PD->getObjCRuntimeNameAsString(); |
---|
| | | |
---|
| - llvm::GlobalVariable *PTGV = | | + llvm::GlobalVariable *PTGV = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.ProtocolnfABIPtrTy, | | + CGM.getModule(), ObjCTypes.ProtocolnfABIPtrTy, false, |
---|
| - false, llvm::GlobalValue::WeakAnyLinkage, Entry, | | + llvm::GlobalValue::WeakAnyLinkage, Entry, ProtocolRef); |
---|
| - ProtocolRef); | | |
---|
| if (!CGM.getTriple().isOSBinFormatMachO()) | | if (!CGM.getTriple().isOSBinFormatMachO()) |
---|
| PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolRef)); | | PTGV->setComdat(CGM.getModule().getOrInsertComdat(ProtocolRef)); |
---|
| PTGV->setAlignment( | | PTGV->setAlignment( |
---|
| CGM.getDataLayout().getABITypeAlign(ObjCTypes.ProtocolnfABIPtrTy)); | | CGM.getDataLayout().getABITypeAlign(ObjCTypes.ProtocolnfABIPtrTy)); |
---|
| - PTGV->setSection(GetSectionName("__objc_protolist", | | + PTGV->setSection( |
---|
| - "coalesced,no_dead_strip")); | | + GetSectionName("__objc_protolist", "coalesced,no_dead_strip")); |
---|
| PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); | | PTGV->setVisibility(llvm::GlobalValue::HiddenVisibility); |
---|
| CGM.addUsedGlobal(PTGV); | | CGM.addUsedGlobal(PTGV); |
---|
| return Entry; | | return Entry; |
---|
@@ -7099,10 +7009,9 @@ llvm::Constant *CGObjCNonFragileABIMac::GetOrEmitProtocol( |
| /// } | | /// } |
---|
| /// @endcode | | /// @endcode |
---|
| /// | | /// |
---|
| -llvm::Constant * | | +llvm::Constant *CGObjCNonFragileABIMac::EmitProtocolList( |
---|
| -CGObjCNonFragileABIMac::EmitProtocolList(Twine Name, | | + Twine Name, ObjCProtocolDecl::protocol_iterator begin, |
---|
| - ObjCProtocolDecl::protocol_iterator begin, | | + ObjCProtocolDecl::protocol_iterator end) { |
---|
| - ObjCProtocolDecl::protocol_iterator end) { | | |
---|
| // Just return null for empty protocol lists | | // Just return null for empty protocol lists |
---|
| auto Protocols = GetRuntimeProtocolList(begin, end); | | auto Protocols = GetRuntimeProtocolList(begin, end); |
---|
| if (Protocols.empty()) | | if (Protocols.empty()) |
---|
@@ -7123,7 +7032,7 @@ CGObjCNonFragileABIMac::EmitProtocolList(Twine Name, |
| SmallString<256> TmpName; | | SmallString<256> TmpName; |
---|
| Name.toVector(TmpName); | | Name.toVector(TmpName); |
---|
| llvm::GlobalVariable *GV = | | llvm::GlobalVariable *GV = |
---|
| - CGM.getModule().getGlobalVariable(TmpName.str(), true); | | + CGM.getModule().getGlobalVariable(TmpName.str(), true); |
---|
| if (GV) | | if (GV) |
---|
| return GV; | | return GV; |
---|
| | | |
---|
@@ -7153,11 +7062,8 @@ CGObjCNonFragileABIMac::EmitProtocolList(Twine Name, |
| /// @encode | | /// @encode |
---|
| /// | | /// |
---|
| LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar( | | LValue CGObjCNonFragileABIMac::EmitObjCValueForIvar( |
---|
| - CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, QualType ObjectTy, llvm::Value *BaseValue, |
---|
| - QualType ObjectTy, | | + const ObjCIvarDecl *Ivar, unsigned CVRQualifiers) { |
---|
| - llvm::Value *BaseValue, | | |
---|
| - const ObjCIvarDecl *Ivar, | | |
---|
| - unsigned CVRQualifiers) { | | |
---|
| ObjCInterfaceDecl *ID = ObjectTy->castAs<ObjCObjectType>()->getInterface(); | | ObjCInterfaceDecl *ID = ObjectTy->castAs<ObjCObjectType>()->getInterface(); |
---|
| llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar); | | llvm::Value *Offset = EmitIvarOffset(CGF, ID, Ivar); |
---|
| return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers, | | return EmitValueForIvarAtOffset(CGF, ID, BaseValue, Ivar, CVRQualifiers, |
---|
@@ -7175,9 +7081,8 @@ CGObjCNonFragileABIMac::EmitIvarOffset(CodeGen::CodeGenFunction &CGF, |
| ComputeIvarBaseOffset(CGM, Interface->getImplementation(), Ivar)); | | ComputeIvarBaseOffset(CGM, Interface->getImplementation(), Ivar)); |
---|
| } else { | | } else { |
---|
| llvm::GlobalVariable *GV = ObjCIvarOffsetVariable(Interface, Ivar); | | llvm::GlobalVariable *GV = ObjCIvarOffsetVariable(Interface, Ivar); |
---|
| - IvarOffsetValue = | | + IvarOffsetValue = CGF.Builder.CreateAlignedLoad(GV->getValueType(), GV, |
---|
| - CGF.Builder.CreateAlignedLoad(GV->getValueType(), GV, | | + CGF.getSizeAlign(), "ivar"); |
---|
| - CGF.getSizeAlign(), "ivar"); | | |
---|
| if (IsIvarOffsetKnownIdempotent(CGF, Ivar)) | | if (IsIvarOffsetKnownIdempotent(CGF, Ivar)) |
---|
| cast<llvm::LoadInst>(IvarOffsetValue) | | cast<llvm::LoadInst>(IvarOffsetValue) |
---|
| ->setMetadata(llvm::LLVMContext::MD_invariant_load, | | ->setMetadata(llvm::LLVMContext::MD_invariant_load, |
---|
@@ -7216,16 +7121,10 @@ static void appendSelectorForMessageRefTable(std::string &buffer, |
| /// appropriate vtable slot, and if not, it substitues a stub function | | /// appropriate vtable slot, and if not, it substitues a stub function |
---|
| /// which tail-calls objc_msgSend. Both stubs adjust the selector | | /// which tail-calls objc_msgSend. Both stubs adjust the selector |
---|
| /// argument to correctly point to the selector. | | /// argument to correctly point to the selector. |
---|
| -RValue | | +RValue CGObjCNonFragileABIMac::EmitVTableMessageSend( |
---|
| -CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, | | + CodeGenFunction &CGF, ReturnValueSlot returnSlot, QualType resultType, |
---|
| - ReturnValueSlot returnSlot, | | + Selector selector, llvm::Value *arg0, QualType arg0Type, bool isSuper, |
---|
| - QualType resultType, | | + const CallArgList &formalArgs, const ObjCMethodDecl *method) { |
---|
| - Selector selector, | | |
---|
| - llvm::Value *arg0, | | |
---|
| - QualType arg0Type, | | |
---|
| - bool isSuper, | | |
---|
| - const CallArgList &formalArgs, | | |
---|
| - const ObjCMethodDecl *method) { | | |
---|
| // Compute the actual arguments. | | // Compute the actual arguments. |
---|
| CallArgList args; | | CallArgList args; |
---|
| | | |
---|
@@ -7281,18 +7180,17 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, |
| // would have used colons. | | // would have used colons. |
---|
| appendSelectorForMessageRefTable(messageRefName, selector); | | appendSelectorForMessageRefTable(messageRefName, selector); |
---|
| | | |
---|
| - llvm::GlobalVariable *messageRef | | + llvm::GlobalVariable *messageRef = |
---|
| - = CGM.getModule().getGlobalVariable(messageRefName); | | + CGM.getModule().getGlobalVariable(messageRefName); |
---|
| if (!messageRef) { | | if (!messageRef) { |
---|
| // Build the message ref structure. | | // Build the message ref structure. |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto values = builder.beginStruct(); | | auto values = builder.beginStruct(); |
---|
| values.add(cast<llvm::Constant>(fn.getCallee())); | | values.add(cast<llvm::Constant>(fn.getCallee())); |
---|
| values.add(GetMethodVarName(selector)); | | values.add(GetMethodVarName(selector)); |
---|
| - messageRef = values.finishAndCreateGlobal(messageRefName, | | + messageRef = values.finishAndCreateGlobal( |
---|
| - CharUnits::fromQuantity(16), | | + messageRefName, CharUnits::fromQuantity(16), |
---|
| - /*constant*/ false, | | + /*constant*/ false, llvm::GlobalValue::WeakAnyLinkage); |
---|
| - llvm::GlobalValue::WeakAnyLinkage); | | |
---|
| messageRef->setVisibility(llvm::GlobalValue::HiddenVisibility); | | messageRef->setVisibility(llvm::GlobalValue::HiddenVisibility); |
---|
| messageRef->setSection(GetSectionName("__objc_msgrefs", "coalesced")); | | messageRef->setSection(GetSectionName("__objc_msgrefs", "coalesced")); |
---|
| } | | } |
---|
@@ -7309,8 +7207,8 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, |
| } | | } |
---|
| | | |
---|
| Address mref = | | Address mref = |
---|
| - Address(CGF.Builder.CreateBitCast(messageRef, ObjCTypes.MessageRefPtrTy), | | + Address(CGF.Builder.CreateBitCast(messageRef, ObjCTypes.MessageRefPtrTy), |
---|
| - ObjCTypes.MessageRefTy, CGF.getPointerAlign()); | | + ObjCTypes.MessageRefTy, CGF.getPointerAlign()); |
---|
| | | |
---|
| // Update the message ref argument. | | // Update the message ref argument. |
---|
| args[1].setRValue(RValue::get(mref, CGF)); | | args[1].setRValue(RValue::get(mref, CGF)); |
---|
@@ -7328,22 +7226,17 @@ CGObjCNonFragileABIMac::EmitVTableMessageSend(CodeGenFunction &CGF, |
| } | | } |
---|
| | | |
---|
| /// Generate code for a message send expression in the nonfragile abi. | | /// Generate code for a message send expression in the nonfragile abi. |
---|
| -CodeGen::RValue | | +CodeGen::RValue CGObjCNonFragileABIMac::GenerateMessageSend( |
---|
| -CGObjCNonFragileABIMac::GenerateMessageSend(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, |
---|
| - ReturnValueSlot Return, | | + Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs, |
---|
| - QualType ResultType, | | + const ObjCInterfaceDecl *Class, const ObjCMethodDecl *Method) { |
---|
| - Selector Sel, | | |
---|
| - llvm::Value *Receiver, | | |
---|
| - const CallArgList &CallArgs, | | |
---|
| - const ObjCInterfaceDecl *Class, | | |
---|
| - const ObjCMethodDecl *Method) { | | |
---|
| return isVTableDispatchedSelector(Sel) | | return isVTableDispatchedSelector(Sel) |
---|
| - ? EmitVTableMessageSend(CGF, Return, ResultType, Sel, | | + ? EmitVTableMessageSend(CGF, Return, ResultType, Sel, Receiver, |
---|
| - Receiver, CGF.getContext().getObjCIdType(), | | + CGF.getContext().getObjCIdType(), false, |
---|
| - false, CallArgs, Method) | | + CallArgs, Method) |
---|
| - : EmitMessageSend(CGF, Return, ResultType, Sel, | | + : EmitMessageSend(CGF, Return, ResultType, Sel, Receiver, |
---|
| - Receiver, CGF.getContext().getObjCIdType(), | | + CGF.getContext().getObjCIdType(), false, |
---|
| - false, CallArgs, Method, Class, ObjCTypes); | | + CallArgs, Method, Class, ObjCTypes); |
---|
| } | | } |
---|
| | | |
---|
| llvm::Constant * | | llvm::Constant * |
---|
@@ -7351,13 +7244,12 @@ CGObjCNonFragileABIMac::GetClassGlobal(const ObjCInterfaceDecl *ID, |
| bool metaclass, | | bool metaclass, |
---|
| ForDefinition_t isForDefinition) { | | ForDefinition_t isForDefinition) { |
---|
| auto prefix = | | auto prefix = |
---|
| - (metaclass ? getMetaclassSymbolPrefix() : getClassSymbolPrefix()); | | + (metaclass ? getMetaclassSymbolPrefix() : getClassSymbolPrefix()); |
---|
| return GetClassGlobal((prefix + ID->getObjCRuntimeNameAsString()).str(), | | return GetClassGlobal((prefix + ID->getObjCRuntimeNameAsString()).str(), |
---|
| - isForDefinition, | | + isForDefinition, ID->isWeakImported(), |
---|
| - ID->isWeakImported(), | | + !isForDefinition && |
---|
| - !isForDefinition | | + CGM.getTriple().isOSBinFormatCOFF() && |
---|
| - && CGM.getTriple().isOSBinFormatCOFF() | | + ID->hasAttr<DLLImportAttr>()); |
---|
| - && ID->hasAttr<DLLImportAttr>()); | | |
---|
| } | | } |
---|
| | | |
---|
| llvm::Constant * | | llvm::Constant * |
---|
@@ -7390,8 +7282,8 @@ CGObjCNonFragileABIMac::GetClassGlobal(StringRef Name, |
| | | |
---|
| llvm::Constant * | | llvm::Constant * |
---|
| CGObjCNonFragileABIMac::GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID) { | | CGObjCNonFragileABIMac::GetClassGlobalForClassRef(const ObjCInterfaceDecl *ID) { |
---|
| - llvm::Constant *ClassGV = GetClassGlobal(ID, /*metaclass*/ false, | | + llvm::Constant *ClassGV = |
---|
| - NotForDefinition); | | + GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition); |
---|
| | | |
---|
| if (!ID->hasAttr<ObjCClassStubAttr>()) | | if (!ID->hasAttr<ObjCClassStubAttr>()) |
---|
| return ClassGV; | | return ClassGV; |
---|
@@ -7411,18 +7303,16 @@ CGObjCNonFragileABIMac::EmitLoadOfClassRef(CodeGenFunction &CGF, |
| if (ID && ID->hasAttr<ObjCClassStubAttr>()) { | | if (ID && ID->hasAttr<ObjCClassStubAttr>()) { |
---|
| // Classrefs pointing at Objective-C stub classes must be loaded by calling | | // Classrefs pointing at Objective-C stub classes must be loaded by calling |
---|
| // a special runtime function. | | // a special runtime function. |
---|
| - return CGF.EmitRuntimeCall( | | + return CGF.EmitRuntimeCall(ObjCTypes.getLoadClassrefFn(), Entry, |
---|
| - ObjCTypes.getLoadClassrefFn(), Entry, "load_classref_result"); | | + "load_classref_result"); |
---|
| } | | } |
---|
| | | |
---|
| CharUnits Align = CGF.getPointerAlign(); | | CharUnits Align = CGF.getPointerAlign(); |
---|
| return CGF.Builder.CreateAlignedLoad(Entry->getValueType(), Entry, Align); | | return CGF.Builder.CreateAlignedLoad(Entry->getValueType(), Entry, Align); |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Value * | | +llvm::Value *CGObjCNonFragileABIMac::EmitClassRefFromId( |
---|
| -CGObjCNonFragileABIMac::EmitClassRefFromId(CodeGenFunction &CGF, | | + CodeGenFunction &CGF, IdentifierInfo *II, const ObjCInterfaceDecl *ID) { |
---|
| - IdentifierInfo *II, | | |
---|
| - const ObjCInterfaceDecl *ID) { | | |
---|
| llvm::GlobalVariable *&Entry = ClassReferences[II]; | | llvm::GlobalVariable *&Entry = ClassReferences[II]; |
---|
| | | |
---|
| if (!Entry) { | | if (!Entry) { |
---|
@@ -7462,8 +7352,8 @@ llvm::Value *CGObjCNonFragileABIMac::EmitClassRef(CodeGenFunction &CGF, |
| return EmitClassRefFromId(CGF, ID->getIdentifier(), ID); | | return EmitClassRefFromId(CGF, ID->getIdentifier(), ID); |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Value *CGObjCNonFragileABIMac::EmitNSAutoreleasePoolClassRef( | | +llvm::Value * |
---|
| - CodeGenFunction &CGF) { | | +CGObjCNonFragileABIMac::EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF) { |
---|
| IdentifierInfo *II = &CGM.getContext().Idents.get("NSAutoreleasePool"); | | IdentifierInfo *II = &CGM.getContext().Idents.get("NSAutoreleasePool"); |
---|
| return EmitClassRefFromId(CGF, II, nullptr); | | return EmitClassRefFromId(CGF, II, nullptr); |
---|
| } | | } |
---|
@@ -7491,11 +7381,10 @@ CGObjCNonFragileABIMac::EmitSuperClassRef(CodeGenFunction &CGF, |
| /// EmitMetaClassRef - Return a Value * of the address of _class_t | | /// EmitMetaClassRef - Return a Value * of the address of _class_t |
---|
| /// meta-data | | /// meta-data |
---|
| /// | | /// |
---|
| -llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef(CodeGenFunction &CGF, | | +llvm::Value *CGObjCNonFragileABIMac::EmitMetaClassRef( |
---|
| - const ObjCInterfaceDecl *ID, | | + CodeGenFunction &CGF, const ObjCInterfaceDecl *ID, bool Weak) { |
---|
| - bool Weak) { | | |
---|
| CharUnits Align = CGF.getPointerAlign(); | | CharUnits Align = CGF.getPointerAlign(); |
---|
| - llvm::GlobalVariable * &Entry = MetaClassReferences[ID->getIdentifier()]; | | + llvm::GlobalVariable *&Entry = MetaClassReferences[ID->getIdentifier()]; |
---|
| if (!Entry) { | | if (!Entry) { |
---|
| auto MetaClassGV = GetClassGlobal(ID, /*metaclass*/ true, NotForDefinition); | | auto MetaClassGV = GetClassGlobal(ID, /*metaclass*/ true, NotForDefinition); |
---|
| std::string SectionName = | | std::string SectionName = |
---|
@@ -7528,17 +7417,11 @@ llvm::Value *CGObjCNonFragileABIMac::GetClass(CodeGenFunction &CGF, |
| /// Generates a message send where the super is the receiver. This is | | /// Generates a message send where the super is the receiver. This is |
---|
| /// a message send to self with special delivery semantics indicating | | /// a message send to self with special delivery semantics indicating |
---|
| /// which class's method should be called. | | /// which class's method should be called. |
---|
| -CodeGen::RValue | | +CodeGen::RValue CGObjCNonFragileABIMac::GenerateMessageSendSuper( |
---|
| -CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, |
---|
| - ReturnValueSlot Return, | | + Selector Sel, const ObjCInterfaceDecl *Class, bool isCategoryImpl, |
---|
| - QualType ResultType, | | + llvm::Value *Receiver, bool IsClassMessage, |
---|
| - Selector Sel, | | + const CodeGen::CallArgList &CallArgs, const ObjCMethodDecl *Method) { |
---|
| - const ObjCInterfaceDecl *Class, | | |
---|
| - bool isCategoryImpl, | | |
---|
| - llvm::Value *Receiver, | | |
---|
| - bool IsClassMessage, | | |
---|
| - const CodeGen::CallArgList &CallArgs, | | |
---|
| - const ObjCMethodDecl *Method) { | | |
---|
| // ... | | // ... |
---|
| // Create and init a super structure; this is a (receiver, class) | | // Create and init a super structure; this is a (receiver, class) |
---|
| // pair we will pass to objc_msgSendSuper. | | // pair we will pass to objc_msgSendSuper. |
---|
@@ -7546,38 +7429,38 @@ CGObjCNonFragileABIMac::GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, |
| ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super"); | | ObjCTypes.SuperTy, CGF.getPointerAlign(), "objc_super"); |
---|
| | | |
---|
| llvm::Value *ReceiverAsObject = | | llvm::Value *ReceiverAsObject = |
---|
| - CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy); | | + CGF.Builder.CreateBitCast(Receiver, ObjCTypes.ObjectPtrTy); |
---|
| CGF.Builder.CreateStore(ReceiverAsObject, | | CGF.Builder.CreateStore(ReceiverAsObject, |
---|
| CGF.Builder.CreateStructGEP(ObjCSuper, 0)); | | CGF.Builder.CreateStructGEP(ObjCSuper, 0)); |
---|
| | | |
---|
| // If this is a class message the metaclass is passed as the target. | | // If this is a class message the metaclass is passed as the target. |
---|
| llvm::Value *Target; | | llvm::Value *Target; |
---|
| if (IsClassMessage) | | if (IsClassMessage) |
---|
| - Target = EmitMetaClassRef(CGF, Class, Class->isWeakImported()); | | + Target = EmitMetaClassRef(CGF, Class, Class->isWeakImported()); |
---|
| else | | else |
---|
| Target = EmitSuperClassRef(CGF, Class); | | Target = EmitSuperClassRef(CGF, Class); |
---|
| | | |
---|
| // FIXME: We shouldn't need to do this cast, rectify the ASTContext and | | // FIXME: We shouldn't need to do this cast, rectify the ASTContext and |
---|
| // ObjCTypes types. | | // ObjCTypes types. |
---|
| llvm::Type *ClassTy = | | llvm::Type *ClassTy = |
---|
| - CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType()); | | + CGM.getTypes().ConvertType(CGF.getContext().getObjCClassType()); |
---|
| Target = CGF.Builder.CreateBitCast(Target, ClassTy); | | Target = CGF.Builder.CreateBitCast(Target, ClassTy); |
---|
| CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1)); | | CGF.Builder.CreateStore(Target, CGF.Builder.CreateStructGEP(ObjCSuper, 1)); |
---|
| | | |
---|
| return (isVTableDispatchedSelector(Sel)) | | return (isVTableDispatchedSelector(Sel)) |
---|
| - ? EmitVTableMessageSend(CGF, Return, ResultType, Sel, | | + ? EmitVTableMessageSend( |
---|
| - ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy, | | + CGF, Return, ResultType, Sel, ObjCSuper.getPointer(), |
---|
| - true, CallArgs, Method) | | + ObjCTypes.SuperPtrCTy, true, CallArgs, Method) |
---|
| - : EmitMessageSend(CGF, Return, ResultType, Sel, | | + : EmitMessageSend(CGF, Return, ResultType, Sel, |
---|
| - ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy, | | + ObjCSuper.getPointer(), ObjCTypes.SuperPtrCTy, |
---|
| - true, CallArgs, Method, Class, ObjCTypes); | | + true, CallArgs, Method, Class, ObjCTypes); |
---|
| } | | } |
---|
| | | |
---|
| llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CodeGenFunction &CGF, | | llvm::Value *CGObjCNonFragileABIMac::EmitSelector(CodeGenFunction &CGF, |
---|
| Selector Sel) { | | Selector Sel) { |
---|
| Address Addr = EmitSelectorAddr(Sel); | | Address Addr = EmitSelectorAddr(Sel); |
---|
| | | |
---|
| - llvm::LoadInst* LI = CGF.Builder.CreateLoad(Addr); | | + llvm::LoadInst *LI = CGF.Builder.CreateLoad(Addr); |
---|
| LI->setMetadata(llvm::LLVMContext::MD_invariant_load, | | LI->setMetadata(llvm::LLVMContext::MD_invariant_load, |
---|
| llvm::MDNode::get(VMContext, {})); | | llvm::MDNode::get(VMContext, {})); |
---|
| return LI; | | return LI; |
---|
@@ -7606,15 +7489,14 @@ ConstantAddress CGObjCNonFragileABIMac::EmitSelectorAddr(Selector Sel) { |
| /// objc_assign_ivar (id src, id *dst, ptrdiff_t) | | /// objc_assign_ivar (id src, id *dst, ptrdiff_t) |
---|
| /// | | /// |
---|
| void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, | | void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, |
---|
| - llvm::Value *src, | | + llvm::Value *src, Address dst, |
---|
| - Address dst, | | |
---|
| llvm::Value *ivarOffset) { | | llvm::Value *ivarOffset) { |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
| src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) | | src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) |
---|
| - : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); | | + : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); |
---|
| src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); | | src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); |
---|
| } | | } |
---|
| src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); | | src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); |
---|
@@ -7628,22 +7510,21 @@ void CGObjCNonFragileABIMac::EmitObjCIvarAssign(CodeGen::CodeGenFunction &CGF, |
| /// objc_assign_strongCast (id src, id *dst) | | /// objc_assign_strongCast (id src, id *dst) |
---|
| /// | | /// |
---|
| void CGObjCNonFragileABIMac::EmitObjCStrongCastAssign( | | void CGObjCNonFragileABIMac::EmitObjCStrongCastAssign( |
---|
| - CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, llvm::Value *src, Address dst) { |
---|
| - llvm::Value *src, Address dst) { | | + llvm::Type *SrcTy = src->getType(); |
---|
| - llvm::Type * SrcTy = src->getType(); | | |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
| src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) | | src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) |
---|
| - : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); | | + : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); |
---|
| src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); | | src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); |
---|
| } | | } |
---|
| src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); | | src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); |
---|
| llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), | | llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), |
---|
| ObjCTypes.PtrObjectPtrTy); | | ObjCTypes.PtrObjectPtrTy); |
---|
| llvm::Value *args[] = {src, dstVal}; | | llvm::Value *args[] = {src, dstVal}; |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignStrongCastFn(), args, |
---|
| - args, "weakassign"); | | + "weakassign"); |
---|
| } | | } |
---|
| | | |
---|
| void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable( | | void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable( |
---|
@@ -7657,15 +7538,14 @@ void CGObjCNonFragileABIMac::EmitGCMemmoveCollectable( |
| /// EmitObjCWeakRead - Code gen for loading value of a __weak | | /// EmitObjCWeakRead - Code gen for loading value of a __weak |
---|
| /// object: objc_read_weak (id *src) | | /// object: objc_read_weak (id *src) |
---|
| /// | | /// |
---|
| -llvm::Value * CGObjCNonFragileABIMac::EmitObjCWeakRead( | | +llvm::Value * |
---|
| - CodeGen::CodeGenFunction &CGF, | | +CGObjCNonFragileABIMac::EmitObjCWeakRead(CodeGen::CodeGenFunction &CGF, |
---|
| - Address AddrWeakObj) { | | + Address AddrWeakObj) { |
---|
| llvm::Type *DestTy = AddrWeakObj.getElementType(); | | llvm::Type *DestTy = AddrWeakObj.getElementType(); |
---|
| llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast( | | llvm::Value *AddrWeakObjVal = CGF.Builder.CreateBitCast( |
---|
| AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy); | | AddrWeakObj.emitRawPointer(CGF), ObjCTypes.PtrObjectPtrTy); |
---|
| - llvm::Value *read_weak = | | + llvm::Value *read_weak = CGF.EmitNounwindRuntimeCall( |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcReadWeakFn(), | | + ObjCTypes.getGcReadWeakFn(), AddrWeakObjVal, "weakread"); |
---|
| - AddrWeakObjVal, "weakread"); | | |
---|
| read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy); | | read_weak = CGF.Builder.CreateBitCast(read_weak, DestTy); |
---|
| return read_weak; | | return read_weak; |
---|
| } | | } |
---|
@@ -7675,34 +7555,34 @@ llvm::Value * CGObjCNonFragileABIMac::EmitObjCWeakRead( |
| /// | | /// |
---|
| void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, | | void CGObjCNonFragileABIMac::EmitObjCWeakAssign(CodeGen::CodeGenFunction &CGF, |
---|
| llvm::Value *src, Address dst) { | | llvm::Value *src, Address dst) { |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
| src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) | | src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) |
---|
| - : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); | | + : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); |
---|
| src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); | | src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); |
---|
| } | | } |
---|
| src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); | | src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); |
---|
| llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), | | llvm::Value *dstVal = CGF.Builder.CreateBitCast(dst.emitRawPointer(CGF), |
---|
| ObjCTypes.PtrObjectPtrTy); | | ObjCTypes.PtrObjectPtrTy); |
---|
| llvm::Value *args[] = {src, dstVal}; | | llvm::Value *args[] = {src, dstVal}; |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignWeakFn(), args, |
---|
| - args, "weakassign"); | | + "weakassign"); |
---|
| } | | } |
---|
| | | |
---|
| /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. | | /// EmitObjCGlobalAssign - Code gen for assigning to a __strong object. |
---|
| /// objc_assign_global (id src, id *dst) | | /// objc_assign_global (id src, id *dst) |
---|
| /// | | /// |
---|
| void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, | | void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, |
---|
| - llvm::Value *src, Address dst, | | + llvm::Value *src, Address dst, |
---|
| - bool threadlocal) { | | + bool threadlocal) { |
---|
| - llvm::Type * SrcTy = src->getType(); | | + llvm::Type *SrcTy = src->getType(); |
---|
| if (!isa<llvm::PointerType>(SrcTy)) { | | if (!isa<llvm::PointerType>(SrcTy)) { |
---|
| unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); | | unsigned Size = CGM.getDataLayout().getTypeAllocSize(SrcTy); |
---|
| assert(Size <= 8 && "does not support size > 8"); | | assert(Size <= 8 && "does not support size > 8"); |
---|
| src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) | | src = (Size == 4 ? CGF.Builder.CreateBitCast(src, ObjCTypes.IntTy) |
---|
| - : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); | | + : CGF.Builder.CreateBitCast(src, ObjCTypes.LongTy)); |
---|
| src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); | | src = CGF.Builder.CreateIntToPtr(src, ObjCTypes.Int8PtrTy); |
---|
| } | | } |
---|
| src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); | | src = CGF.Builder.CreateBitCast(src, ObjCTypes.ObjectPtrTy); |
---|
@@ -7710,30 +7590,27 @@ void CGObjCNonFragileABIMac::EmitObjCGlobalAssign(CodeGen::CodeGenFunction &CGF, |
| ObjCTypes.PtrObjectPtrTy); | | ObjCTypes.PtrObjectPtrTy); |
---|
| llvm::Value *args[] = {src, dstVal}; | | llvm::Value *args[] = {src, dstVal}; |
---|
| if (!threadlocal) | | if (!threadlocal) |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignGlobalFn(), args, |
---|
| - args, "globalassign"); | | + "globalassign"); |
---|
| else | | else |
---|
| - CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), | | + CGF.EmitNounwindRuntimeCall(ObjCTypes.getGcAssignThreadLocalFn(), args, |
---|
| - args, "threadlocalassign"); | | + "threadlocalassign"); |
---|
| } | | } |
---|
| | | |
---|
| -void | | +void CGObjCNonFragileABIMac::EmitSynchronizedStmt( |
---|
| -CGObjCNonFragileABIMac::EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, | | + CodeGen::CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S) { |
---|
| - const ObjCAtSynchronizedStmt &S) { | | |
---|
| EmitAtSynchronizedStmt(CGF, S, ObjCTypes.getSyncEnterFn(), | | EmitAtSynchronizedStmt(CGF, S, ObjCTypes.getSyncEnterFn(), |
---|
| ObjCTypes.getSyncExitFn()); | | ObjCTypes.getSyncExitFn()); |
---|
| } | | } |
---|
| | | |
---|
| -llvm::Constant * | | +llvm::Constant *CGObjCNonFragileABIMac::GetEHType(QualType T) { |
---|
| -CGObjCNonFragileABIMac::GetEHType(QualType T) { | | |
---|
| // There's a particular fixed type info for 'id'. | | // There's a particular fixed type info for 'id'. |
---|
| if (T->isObjCIdType() || T->isObjCQualifiedIdType()) { | | if (T->isObjCIdType() || T->isObjCQualifiedIdType()) { |
---|
| auto *IDEHType = CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id"); | | auto *IDEHType = CGM.getModule().getGlobalVariable("OBJC_EHTYPE_id"); |
---|
| if (!IDEHType) { | | if (!IDEHType) { |
---|
| - IDEHType = | | + IDEHType = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, false, | | + CGM.getModule(), ObjCTypes.EHTypeTy, false, |
---|
| - llvm::GlobalValue::ExternalLinkage, nullptr, | | + llvm::GlobalValue::ExternalLinkage, nullptr, "OBJC_EHTYPE_id"); |
---|
| - "OBJC_EHTYPE_id"); | | |
---|
| if (CGM.getTriple().isOSBinFormatCOFF()) | | if (CGM.getTriple().isOSBinFormatCOFF()) |
---|
| IDEHType->setDLLStorageClass(getStorage(CGM, "OBJC_EHTYPE_id")); | | IDEHType->setDLLStorageClass(getStorage(CGM, "OBJC_EHTYPE_id")); |
---|
| } | | } |
---|
@@ -7781,7 +7658,7 @@ void CGObjCNonFragileABIMac::EmitThrowStmt(CodeGen::CodeGenFunction &CGF, |
| llvm::Constant * | | llvm::Constant * |
---|
| CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, | | CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, |
---|
| ForDefinition_t IsForDefinition) { | | ForDefinition_t IsForDefinition) { |
---|
| - llvm::GlobalVariable * &Entry = EHTypeReferences[ID->getIdentifier()]; | | + llvm::GlobalVariable *&Entry = EHTypeReferences[ID->getIdentifier()]; |
---|
| StringRef ClassName = ID->getObjCRuntimeNameAsString(); | | StringRef ClassName = ID->getObjCRuntimeNameAsString(); |
---|
| | | |
---|
| // If we don't need a definition, return the entry if found or check | | // If we don't need a definition, return the entry if found or check |
---|
@@ -7794,9 +7671,9 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, |
| // attribute, emit an external reference. | | // attribute, emit an external reference. |
---|
| if (hasObjCExceptionAttribute(CGM.getContext(), ID)) { | | if (hasObjCExceptionAttribute(CGM.getContext(), ID)) { |
---|
| std::string EHTypeName = ("OBJC_EHTYPE_$_" + ClassName).str(); | | std::string EHTypeName = ("OBJC_EHTYPE_$_" + ClassName).str(); |
---|
| - Entry = new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.EHTypeTy, | | + Entry = new llvm::GlobalVariable( |
---|
| - false, llvm::GlobalValue::ExternalLinkage, | | + CGM.getModule(), ObjCTypes.EHTypeTy, false, |
---|
| - nullptr, EHTypeName); | | + llvm::GlobalValue::ExternalLinkage, nullptr, EHTypeName); |
---|
| CGM.setGVProperties(Entry, ID); | | CGM.setGVProperties(Entry, ID); |
---|
| return Entry; | | return Entry; |
---|
| } | | } |
---|
@@ -7808,10 +7685,9 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, |
| std::string VTableName = "objc_ehtype_vtable"; | | std::string VTableName = "objc_ehtype_vtable"; |
---|
| auto *VTableGV = CGM.getModule().getGlobalVariable(VTableName); | | auto *VTableGV = CGM.getModule().getGlobalVariable(VTableName); |
---|
| if (!VTableGV) { | | if (!VTableGV) { |
---|
| - VTableGV = | | + VTableGV = new llvm::GlobalVariable( |
---|
| - new llvm::GlobalVariable(CGM.getModule(), ObjCTypes.Int8PtrTy, false, | | + CGM.getModule(), ObjCTypes.Int8PtrTy, false, |
---|
| - llvm::GlobalValue::ExternalLinkage, nullptr, | | + llvm::GlobalValue::ExternalLinkage, nullptr, VTableName); |
---|
| - VTableName); | | |
---|
| if (CGM.getTriple().isOSBinFormatCOFF()) | | if (CGM.getTriple().isOSBinFormatCOFF()) |
---|
| VTableGV->setDLLStorageClass(getStorage(CGM, VTableName)); | | VTableGV->setDLLStorageClass(getStorage(CGM, VTableName)); |
---|
| } | | } |
---|
@@ -7819,9 +7695,8 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, |
| llvm::Value *VTableIdx = llvm::ConstantInt::get(CGM.Int32Ty, 2); | | llvm::Value *VTableIdx = llvm::ConstantInt::get(CGM.Int32Ty, 2); |
---|
| ConstantInitBuilder builder(CGM); | | ConstantInitBuilder builder(CGM); |
---|
| auto values = builder.beginStruct(ObjCTypes.EHTypeTy); | | auto values = builder.beginStruct(ObjCTypes.EHTypeTy); |
---|
| - values.add( | | + values.add(llvm::ConstantExpr::getInBoundsGetElementPtr( |
---|
| - llvm::ConstantExpr::getInBoundsGetElementPtr(VTableGV->getValueType(), | | + VTableGV->getValueType(), VTableGV, VTableIdx)); |
---|
| - VTableGV, VTableIdx)); | | |
---|
| values.add(GetClassName(ClassName)); | | values.add(GetClassName(ClassName)); |
---|
| values.add(GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition)); | | values.add(GetClassGlobal(ID, /*metaclass*/ false, NotForDefinition)); |
---|
| | | |
---|
@@ -7834,8 +7709,7 @@ CGObjCNonFragileABIMac::GetInterfaceEHType(const ObjCInterfaceDecl *ID, |
| } else { | | } else { |
---|
| Entry = values.finishAndCreateGlobal("OBJC_EHTYPE_$_" + ClassName, | | Entry = values.finishAndCreateGlobal("OBJC_EHTYPE_$_" + ClassName, |
---|
| CGM.getPointerAlign(), | | CGM.getPointerAlign(), |
---|
| - /*constant*/ false, | | + /*constant*/ false, L); |
---|
| - L); | | |
---|
| if (hasObjCExceptionAttribute(CGM.getContext(), ID)) | | if (hasObjCExceptionAttribute(CGM.getContext(), ID)) |
---|
| CGM.setGVProperties(Entry, ID); | | CGM.setGVProperties(Entry, ID); |
---|
| } | | } |
---|
@@ -7858,7 +7732,7 @@ CodeGen::CGObjCRuntime * |
| CodeGen::CreateMacObjCRuntime(CodeGen::CodeGenModule &CGM) { | | CodeGen::CreateMacObjCRuntime(CodeGen::CodeGenModule &CGM) { |
---|
| switch (CGM.getLangOpts().ObjCRuntime.getKind()) { | | switch (CGM.getLangOpts().ObjCRuntime.getKind()) { |
---|
| case ObjCRuntime::FragileMacOSX: | | case ObjCRuntime::FragileMacOSX: |
---|
| - return new CGObjCMac(CGM); | | + return new CGObjCMac(CGM); |
---|
| | | |
---|
| case ObjCRuntime::MacOSX: | | case ObjCRuntime::MacOSX: |
---|
| case ObjCRuntime::iOS: | | case ObjCRuntime::iOS: |
---|