@@ -278,9 +278,9 @@ class CGObjCGNU : public CGObjCRuntime {
278278 Fields.addInt (IntTy, count);
279279 // int size; (only in GNUstep v2 ABI.
280280 if (isRuntime (ObjCRuntime::GNUstep, 2 )) {
281- llvm::DataLayout td (& TheModule);
282- Fields.addInt (IntTy, td .getTypeSizeInBits (PropertyMetadataTy) /
283- CGM.getContext ().getCharWidth ());
281+ const llvm::DataLayout &DL = TheModule. getDataLayout ( );
282+ Fields.addInt (IntTy, DL .getTypeSizeInBits (PropertyMetadataTy) /
283+ CGM.getContext ().getCharWidth ());
284284 }
285285 // struct objc_property_list *next;
286286 Fields.add (NULLPtr);
@@ -1190,9 +1190,9 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
11901190 // int count;
11911191 MethodList.addInt (IntTy, Methods.size ());
11921192 // int size; // sizeof(struct objc_method_description)
1193- llvm::DataLayout td (& TheModule);
1194- MethodList.addInt (IntTy, td .getTypeSizeInBits (ObjCMethodDescTy) /
1195- CGM.getContext ().getCharWidth ());
1193+ const llvm::DataLayout &DL = TheModule. getDataLayout ( );
1194+ MethodList.addInt (IntTy, DL .getTypeSizeInBits (ObjCMethodDescTy) /
1195+ CGM.getContext ().getCharWidth ());
11961196 // struct objc_method_description[]
11971197 auto MethodArray = MethodList.beginArray (ObjCMethodDescTy);
11981198 for (auto *M : Methods) {
@@ -1828,7 +1828,7 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
18281828 int ivar_count = 0 ;
18291829 for (const ObjCIvarDecl *IVD = classDecl->all_declared_ivar_begin (); IVD;
18301830 IVD = IVD->getNextIvar ()) ivar_count++;
1831- llvm::DataLayout td (& TheModule);
1831+ const llvm::DataLayout &DL = TheModule. getDataLayout ( );
18321832 // struct objc_ivar_list *ivars;
18331833 ConstantInitBuilder b (CGM);
18341834 auto ivarListBuilder = b.beginStruct ();
@@ -1841,8 +1841,8 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
18411841 PtrToInt8Ty,
18421842 Int32Ty,
18431843 Int32Ty);
1844- ivarListBuilder.addInt (SizeTy, td .getTypeSizeInBits (ObjCIvarTy) /
1845- CGM.getContext ().getCharWidth ());
1844+ ivarListBuilder.addInt (SizeTy, DL .getTypeSizeInBits (ObjCIvarTy) /
1845+ CGM.getContext ().getCharWidth ());
18461846 // struct objc_ivar ivars[]
18471847 auto ivarArrayBuilder = ivarListBuilder.beginArray ();
18481848 for (const ObjCIvarDecl *IVD = classDecl->all_declared_ivar_begin (); IVD;
@@ -3019,9 +3019,9 @@ GenerateMethodList(StringRef ClassName,
30193019 bool isV2ABI = isRuntime (ObjCRuntime::GNUstep, 2 );
30203020 if (isV2ABI) {
30213021 // size_t size;
3022- llvm::DataLayout td (& TheModule);
3023- MethodList.addInt (SizeTy, td .getTypeSizeInBits (ObjCMethodTy) /
3024- CGM.getContext ().getCharWidth ());
3022+ const llvm::DataLayout &DL = TheModule. getDataLayout ( );
3023+ MethodList.addInt (SizeTy, DL .getTypeSizeInBits (ObjCMethodTy) /
3024+ CGM.getContext ().getCharWidth ());
30253025 ObjCMethodTy =
30263026 llvm::StructType::get (CGM.getLLVMContext (), {
30273027 IMPTy, // Method pointer
@@ -3161,10 +3161,9 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
31613161 Elements.addInt (LongTy, info);
31623162 // instance_size
31633163 if (isMeta) {
3164- llvm::DataLayout td (&TheModule);
3165- Elements.addInt (LongTy,
3166- td.getTypeSizeInBits (ClassTy) /
3167- CGM.getContext ().getCharWidth ());
3164+ const llvm::DataLayout &DL = TheModule.getDataLayout ();
3165+ Elements.addInt (LongTy, DL.getTypeSizeInBits (ClassTy) /
3166+ CGM.getContext ().getCharWidth ());
31683167 } else
31693168 Elements.add (InstanceSize);
31703169 // ivars
0 commit comments