[clang] [clang][CGObjCMac] Unionize identical llvm types (NFC) (PR #110422)

via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 29 05:02:12 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Youngsuk Kim (JOE1994)

<details>
<summary>Changes</summary>

Unionize llvm types which became identical since LLVM opted to use opaque pointers by default.

---
Full diff: https://github.com/llvm/llvm-project/pull/110422.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/CGObjCMac.cpp (+17-10) 


``````````diff
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 30f3911a8b03c2..ed2aab0dceb077 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -173,16 +173,18 @@ class ObjCCommonTypesHelper {
 
 public:
   llvm::IntegerType *ShortTy, *IntTy, *LongTy;
-  llvm::PointerType *Int8PtrTy, *Int8PtrPtrTy;
+
+  union {
+    llvm::PointerType *Int8PtrTy;
+    llvm::PointerType *Int8PtrPtrTy;
+  };
+
   llvm::PointerType *Int8PtrProgramASTy;
   llvm::Type *IvarOffsetVarTy;
 
   /// ObjectPtrTy - LLVM type for object handles (typeof(id))
   llvm::PointerType *ObjectPtrTy;
 
-  /// PtrObjectPtrTy - LLVM type for id *
-  llvm::PointerType *PtrObjectPtrTy;
-
   /// SelectorPtrTy - LLVM type for selector handles (typeof(SEL))
   llvm::PointerType *SelectorPtrTy;
 
@@ -212,8 +214,6 @@ class ObjCCommonTypesHelper {
 
   /// SuperTy - LLVM type for struct objc_super.
   llvm::StructType *SuperTy;
-  /// SuperPtrTy - LLVM type for struct objc_super *.
-  llvm::PointerType *SuperPtrTy;
 
   /// PropertyTy - LLVM type for struct objc_property (struct _prop_t
   /// in GCC parlance).
@@ -222,16 +222,23 @@ class ObjCCommonTypesHelper {
   /// PropertyListTy - LLVM type for struct objc_property_list
   /// (_prop_list_t in GCC parlance).
   llvm::StructType *PropertyListTy;
-  /// PropertyListPtrTy - LLVM type for struct objc_property_list*.
-  llvm::PointerType *PropertyListPtrTy;
 
   // MethodTy - LLVM type for struct objc_method.
   llvm::StructType *MethodTy;
 
   /// CacheTy - LLVM type for struct objc_cache.
   llvm::Type *CacheTy;
-  /// CachePtrTy - LLVM type for struct objc_cache *.
-  llvm::PointerType *CachePtrTy;
+
+  union {
+    /// PtrObjectPtrTy - LLVM type for id *
+    llvm::PointerType *PtrObjectPtrTy;
+    /// SuperPtrTy - LLVM type for struct objc_super *.
+    llvm::PointerType *SuperPtrTy;
+    /// PropertyListPtrTy - LLVM type for struct objc_property_list*.
+    llvm::PointerType *PropertyListPtrTy;
+    /// CachePtrTy - LLVM type for struct objc_cache *.
+    llvm::PointerType *CachePtrTy;
+  };
 
   llvm::FunctionCallee getGetPropertyFn() {
     CodeGen::CodeGenTypes &Types = CGM.getTypes();

``````````

</details>


https://github.com/llvm/llvm-project/pull/110422


More information about the cfe-commits mailing list