[llvm] d8962b4 - [llvm-c] Deprecate LLVMBuildPtrDiff()
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 25 03:49:37 PST 2022
Author: Nikita Popov
Date: 2022-01-25T12:47:50+01:00
New Revision: d8962b4139a58ba6955cd4e15dc432c674a013c0
URL: https://github.com/llvm/llvm-project/commit/d8962b4139a58ba6955cd4e15dc432c674a013c0
DIFF: https://github.com/llvm/llvm-project/commit/d8962b4139a58ba6955cd4e15dc432c674a013c0.diff
LOG: [llvm-c] Deprecate LLVMBuildPtrDiff()
In favor of LLVMBuildPtrDiff2(), which accepts an explicit element
type and is compatible with opaque pointers.
Added:
Modified:
llvm/include/llvm-c/Core.h
llvm/lib/IR/Core.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm-c/Core.h b/llvm/include/llvm-c/Core.h
index ae2bcb8444b4b..ca3ca24487a51 100644
--- a/llvm/include/llvm-c/Core.h
+++ b/llvm/include/llvm-c/Core.h
@@ -4020,8 +4020,13 @@ LLVMValueRef LLVMBuildIsNull(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef, LLVMValueRef Val,
const char *Name);
-LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
- LLVMValueRef RHS, const char *Name);
+LLVM_ATTRIBUTE_C_DEPRECATED(
+ LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef, LLVMValueRef LHS,
+ LLVMValueRef RHS, const char *Name),
+ "Use LLVMBuildPtrDiff2 instead to support opaque pointers");
+LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef, LLVMTypeRef ElemTy,
+ LLVMValueRef LHS, LLVMValueRef RHS,
+ const char *Name);
LLVMValueRef LLVMBuildFence(LLVMBuilderRef B, LLVMAtomicOrdering ordering,
LLVMBool singleThread, const char *Name);
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B, LLVMAtomicRMWBinOp op,
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 988d2affd9654..43df15e4d9328 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -4020,10 +4020,17 @@ LLVMValueRef LLVMBuildIsNotNull(LLVMBuilderRef B, LLVMValueRef Val,
LLVMValueRef LLVMBuildPtrDiff(LLVMBuilderRef B, LLVMValueRef LHS,
LLVMValueRef RHS, const char *Name) {
Value *L = unwrap(LHS);
- Type *ElemTy = L->getType()->getPointerElementType();
+ Type *ElemTy = L->getType()->getNonOpaquePointerElementType();
return wrap(unwrap(B)->CreatePtrDiff(ElemTy, L, unwrap(RHS), Name));
}
+LLVMValueRef LLVMBuildPtrDiff2(LLVMBuilderRef B, LLVMTypeRef ElemTy,
+ LLVMValueRef LHS, LLVMValueRef RHS,
+ const char *Name) {
+ return wrap(unwrap(B)->CreatePtrDiff(unwrap(ElemTy), unwrap(LHS),
+ unwrap(RHS), Name));
+}
+
LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,LLVMAtomicRMWBinOp op,
LLVMValueRef PTR, LLVMValueRef Val,
LLVMAtomicOrdering ordering,
More information about the llvm-commits
mailing list