[clang] [CodeGen] Replace PointerType::getUnqual(Type) with opaque pointer version (NFC) (PR #128711)

Mats Jun Larsen via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 25 05:47:21 PST 2025


https://github.com/junlarsen updated https://github.com/llvm/llvm-project/pull/128711

>From 22a07820dee329ed68ea2a2cd3b619f980047de9 Mon Sep 17 00:00:00 2001
From: Mats Jun Larsen <mats at jun.codes>
Date: Tue, 25 Feb 2025 14:09:39 +0100
Subject: [PATCH] [CodeGen] Replace PointerType::getUnqual(Type) with opaque 
 pointer version (NFC)

Follow-up to #123569
---
 clang/lib/CodeGen/ABIInfoImpl.cpp     | 2 +-
 clang/lib/CodeGen/CGOpenMPRuntime.cpp | 8 +-------
 clang/lib/CodeGen/CGOpenMPRuntime.h   | 4 ----
 clang/lib/CodeGen/ItaniumCXXABI.cpp   | 2 +-
 4 files changed, 3 insertions(+), 13 deletions(-)

diff --git a/clang/lib/CodeGen/ABIInfoImpl.cpp b/clang/lib/CodeGen/ABIInfoImpl.cpp
index 68887cd7916c7..0a612d3461dc2 100644
--- a/clang/lib/CodeGen/ABIInfoImpl.cpp
+++ b/clang/lib/CodeGen/ABIInfoImpl.cpp
@@ -430,7 +430,7 @@ Address CodeGen::EmitVAArgInstr(CodeGenFunction &CGF, Address VAListAddr,
     CharUnits TyAlignForABI = TyInfo.Align;
 
     llvm::Type *ElementTy = CGF.ConvertTypeForMem(Ty);
-    llvm::Type *BaseTy = llvm::PointerType::getUnqual(ElementTy);
+    llvm::Type *BaseTy = llvm::PointerType::getUnqual(CGF.getLLVMContext());
     llvm::Value *Addr =
         CGF.Builder.CreateVAArg(VAListAddr.emitRawPointer(CGF), BaseTy);
     return Address(Addr, ElementTy, TyAlignForABI);
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index c2289985e9519..7ff0d14b564fe 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -1476,13 +1476,7 @@ llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
 }
 
 llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() {
-  if (!Kmpc_MicroTy) {
-    // Build void (*kmpc_micro)(kmp_int32 *global_tid, kmp_int32 *bound_tid,...)
-    llvm::Type *MicroParams[] = {llvm::PointerType::getUnqual(CGM.Int32Ty),
-                                 llvm::PointerType::getUnqual(CGM.Int32Ty)};
-    Kmpc_MicroTy = llvm::FunctionType::get(CGM.VoidTy, MicroParams, true);
-  }
-  return llvm::PointerType::getUnqual(Kmpc_MicroTy);
+  return llvm::PointerType::getUnqual(CGM.getLLVMContext());
 }
 
 static llvm::OffloadEntriesInfoManager::OMPTargetDeviceClauseKind
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h
index 3791bb7159235..03a80d2bbc686 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -386,10 +386,6 @@ class CGOpenMPRuntime {
   /// Map for SourceLocation and OpenMP runtime library debug locations.
   typedef llvm::DenseMap<SourceLocation, llvm::Value *> OpenMPDebugLocMapTy;
   OpenMPDebugLocMapTy OpenMPDebugLocMap;
-  /// The type for a microtask which gets passed to __kmpc_fork_call().
-  /// Original representation is:
-  /// typedef void (kmpc_micro)(kmp_int32 global_tid, kmp_int32 bound_tid,...);
-  llvm::FunctionType *Kmpc_MicroTy = nullptr;
   /// Stores debug location and ThreadID for the function.
   struct DebugLocThreadIdTy {
     llvm::Value *DebugLoc;
diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp
index bcd171724c41d..03c46a37717ab 100644
--- a/clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -953,7 +953,7 @@ ItaniumCXXABI::EmitMemberPointerConversion(CodeGenFunction &CGF,
       Builder.CreateCondBr(IsVirtualOffset, MergeBB, ResignBB);
 
       CGF.EmitBlock(ResignBB);
-      llvm::Type *PtrTy = llvm::PointerType::getUnqual(CGM.Int8Ty);
+      llvm::Type *PtrTy = llvm::PointerType::getUnqual(CGM.getLLVMContext());
       MemFnPtr = Builder.CreateIntToPtr(MemFnPtr, PtrTy);
       MemFnPtr =
           CGF.emitPointerAuthResign(MemFnPtr, SrcType, CurAuthInfo, NewAuthInfo,



More information about the cfe-commits mailing list