-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[llvm] Deprecate Type::getPointerTo() #113331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Replace remaining uses of `llvm::Type::getPointerTo()` and deprecate it. It's no longer needed with opaque pointers in LLVM. It may rather confuse new contributors that LLVM has typed pointers.
@llvm/pr-subscribers-llvm-ir @llvm/pr-subscribers-clang Author: Youngsuk Kim (JOE1994) ChangesReplace remaining uses of It's no longer needed with opaque pointers in LLVM. It may rather confuse new contributors that LLVM has typed pointers. Full diff: https://github.com/llvm/llvm-project/pull/113331.diff 3 Files Affected:
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index 30f3911a8b03c2..5f1ea351481479 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -365,7 +365,7 @@ class ObjCCommonTypesHelper {
/// GcReadWeakFn -- LLVM objc_read_weak (id *src) function.
llvm::FunctionCallee getGcReadWeakFn() {
// id objc_read_weak (id *)
- llvm::Type *args[] = { ObjectPtrTy->getPointerTo() };
+ llvm::Type *args[] = {CGM.UnqualPtrTy};
llvm::FunctionType *FTy =
llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_read_weak");
@@ -374,7 +374,7 @@ class ObjCCommonTypesHelper {
/// GcAssignWeakFn -- LLVM objc_assign_weak function.
llvm::FunctionCallee getGcAssignWeakFn() {
// id objc_assign_weak (id, id *)
- llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
+ llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
llvm::FunctionType *FTy =
llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_weak");
@@ -383,7 +383,7 @@ class ObjCCommonTypesHelper {
/// GcAssignGlobalFn -- LLVM objc_assign_global function.
llvm::FunctionCallee getGcAssignGlobalFn() {
// id objc_assign_global(id, id *)
- llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
+ llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
llvm::FunctionType *FTy =
llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_global");
@@ -392,7 +392,7 @@ class ObjCCommonTypesHelper {
/// GcAssignThreadLocalFn -- LLVM objc_assign_threadlocal function.
llvm::FunctionCallee getGcAssignThreadLocalFn() {
// id objc_assign_threadlocal(id src, id * dest)
- llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
+ llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
llvm::FunctionType *FTy =
llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_threadlocal");
@@ -401,8 +401,7 @@ class ObjCCommonTypesHelper {
/// GcAssignIvarFn -- LLVM objc_assign_ivar function.
llvm::FunctionCallee getGcAssignIvarFn() {
// id objc_assign_ivar(id, id *, ptrdiff_t)
- llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo(),
- CGM.PtrDiffTy };
+ llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy, CGM.PtrDiffTy};
llvm::FunctionType *FTy =
llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_ivar");
@@ -419,7 +418,7 @@ class ObjCCommonTypesHelper {
/// GcAssignStrongCastFn -- LLVM objc_assign_strongCast function.
llvm::FunctionCallee getGcAssignStrongCastFn() {
// id objc_assign_strongCast(id, id *)
- llvm::Type *args[] = { ObjectPtrTy, ObjectPtrTy->getPointerTo() };
+ llvm::Type *args[] = {ObjectPtrTy, CGM.UnqualPtrTy};
llvm::FunctionType *FTy =
llvm::FunctionType::get(ObjectPtrTy, args, false);
return CGM.CreateRuntimeFunction(FTy, "objc_assign_strongCast");
@@ -554,7 +553,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
/// ExceptionTryEnterFn - LLVM objc_exception_try_enter function.
llvm::FunctionCallee getExceptionTryEnterFn() {
- llvm::Type *params[] = { ExceptionDataTy->getPointerTo() };
+ llvm::Type *params[] = {CGM.UnqualPtrTy};
return CGM.CreateRuntimeFunction(
llvm::FunctionType::get(CGM.VoidTy, params, false),
"objc_exception_try_enter");
@@ -562,7 +561,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
/// ExceptionTryExitFn - LLVM objc_exception_try_exit function.
llvm::FunctionCallee getExceptionTryExitFn() {
- llvm::Type *params[] = { ExceptionDataTy->getPointerTo() };
+ llvm::Type *params[] = {CGM.UnqualPtrTy};
return CGM.CreateRuntimeFunction(
llvm::FunctionType::get(CGM.VoidTy, params, false),
"objc_exception_try_exit");
@@ -570,7 +569,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
/// ExceptionExtractFn - LLVM objc_exception_extract function.
llvm::FunctionCallee getExceptionExtractFn() {
- llvm::Type *params[] = { ExceptionDataTy->getPointerTo() };
+ llvm::Type *params[] = {CGM.UnqualPtrTy};
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(ObjectPtrTy,
params, false),
"objc_exception_extract");
@@ -587,7 +586,7 @@ class ObjCTypesHelper : public ObjCCommonTypesHelper {
/// SetJmpFn - LLVM _setjmp function.
llvm::FunctionCallee getSetJmpFn() {
// This is specifically the prototype for x86.
- llvm::Type *params[] = { CGM.Int32Ty->getPointerTo() };
+ llvm::Type *params[] = {CGM.UnqualPtrTy};
return CGM.CreateRuntimeFunction(
llvm::FunctionType::get(CGM.Int32Ty, params, false), "_setjmp",
llvm::AttributeList::get(CGM.getLLVMContext(),
@@ -6055,9 +6054,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
Int8PtrTy, PropertyListPtrTy);
// ImpnfABITy - LLVM for id (*)(id, SEL, ...)
- llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };
- ImpnfABITy = llvm::FunctionType::get(ObjectPtrTy, params, false)
- ->getPointerTo();
+ ImpnfABITy = CGM.UnqualPtrTy;
// struct _class_t {
// struct _class_t *isa;
@@ -6472,8 +6469,7 @@ void CGObjCNonFragileABIMac::GenerateClass(const ObjCImplementationDecl *ID) {
llvm::GlobalValue::ExternalLinkage, nullptr,
"_objc_empty_vtable");
else
- ObjCEmptyVtableVar =
- llvm::ConstantPointerNull::get(ObjCTypes.ImpnfABITy->getPointerTo());
+ ObjCEmptyVtableVar = llvm::ConstantPointerNull::get(CGM.UnqualPtrTy);
}
// FIXME: Is this correct (that meta class size is never computed)?
diff --git a/llvm/include/llvm/IR/Type.h b/llvm/include/llvm/IR/Type.h
index 2f53197df19998..4c9becf80686fb 100644
--- a/llvm/include/llvm/IR/Type.h
+++ b/llvm/include/llvm/IR/Type.h
@@ -471,8 +471,9 @@ class Type {
static Type *getWasm_FuncrefTy(LLVMContext &C);
/// Return a pointer to the current type. This is equivalent to
- /// PointerType::get(Foo, AddrSpace).
+ /// PointerType::get(Ctx, AddrSpace).
/// TODO: Remove this after opaque pointer transition is complete.
+ [[deprecated("Use PointerType::get instead")]]
PointerType *getPointerTo(unsigned AddrSpace = 0) const;
private:
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index e1a732f4b01921..7dbbf73679584f 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -245,7 +245,7 @@ static void RemoveFunctionReferences(Module *M, const char *Name) {
auto *NewValElemTy = OldUsedVal->getType()->getElementType();
auto *NewValTy = ArrayType::get(NewValElemTy, Used.size());
auto *NewUsedVal = ConstantArray::get(NewValTy, Used);
- UsedVar->mutateType(NewUsedVal->getType()->getPointerTo());
+ UsedVar->mutateType(PointerType::getUnqual(M->getContext()));
UsedVar->setInitializer(NewUsedVal);
}
|
llvm/include/llvm/IR/Type.h
Outdated
/// TODO: Remove this after opaque pointer transition is complete. | ||
[[deprecated("Use PointerType::get instead")]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use LLVM_DEPRECATED
in llvm/Support/Compiler.h?
as per feedback from zwuis
gentle ping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
clang/lib/CodeGen/CGObjCMac.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please land the remaining removals separately.
This has been merged to main in a separate PR.
Includes updates to reflect these LLVM changes: * llvm/llvm-project#112517 * llvm/llvm-project#113331 --------- Co-authored-by: Josh L <[email protected]>
…er (#16273) llvm/llvm-project#113331 deprecates usage of getPointerTo, llvm::PointerType::get is recommended instead. This updates AddressSanitizer to use the recommended function in place of the deprecated one. Signed-off-by: Demchuk, Tennyson <[email protected]>
Replace remaining uses of
llvm::Type::getPointerTo()
and deprecate it.It's no longer needed with opaque pointers in LLVM. It may rather confuse new contributors that LLVM has typed pointers.