Skip to content

Conversation

@JOE1994
Copy link
Member

@JOE1994 JOE1994 commented Sep 29, 2024

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

Unionize llvm types which became identical since LLVM opted to use opaque
pointers by default.
@JOE1994 JOE1994 requested review from AlexVlx, bjope and nikic September 29, 2024 12:01
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Sep 29, 2024
@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Youngsuk Kim (JOE1994)

Changes

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 --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();

Copy link
Contributor

@nikic nikic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should do this. If we think there is (documentation) value in different member names we can just leave things as is -- if not, we should merge into a single PtrTy.

@JOE1994 JOE1994 closed this Sep 29, 2024
@JOE1994 JOE1994 deleted the clang_nit branch September 29, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants