mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-21 18:22:53 +01:00
[OpenMP] Change __kmpc_free_shared
to include the paired allocation size
This patch changes `__kmpc_free_shared` to take an additional argument corresponding to the associated allocation's size. This makes it easier to implement the allocator in the runtime. Reviewed By: jdoerfert Differential Revision: https://reviews.llvm.org/D106496
This commit is contained in:
parent
549c960a94
commit
472a223072
@ -332,7 +332,7 @@ TLI_DEFINE_STRING_INTERNAL("__isoc99_sscanf")
|
||||
/// void __kmpc_alloc_shared(size_t nbyte);
|
||||
TLI_DEFINE_ENUM_INTERNAL(__kmpc_alloc_shared)
|
||||
TLI_DEFINE_STRING_INTERNAL("__kmpc_alloc_shared")
|
||||
/// void __kmpc_free_shared(void *ptr);
|
||||
/// void __kmpc_free_shared(void *ptr, size_t nbyte);
|
||||
TLI_DEFINE_ENUM_INTERNAL(__kmpc_free_shared)
|
||||
TLI_DEFINE_STRING_INTERNAL("__kmpc_free_shared")
|
||||
/// double __log10_finite(double x);
|
||||
|
@ -430,7 +430,7 @@ __OMP_RTL(__kmpc_nvptx_teams_reduce_nowait_v2, false, Int32, IdentPtr, Int32,
|
||||
__OMP_RTL(__kmpc_shuffle_int64, false, Int64, Int64, Int16, Int16)
|
||||
|
||||
__OMP_RTL(__kmpc_alloc_shared, false, VoidPtr, SizeTy)
|
||||
__OMP_RTL(__kmpc_free_shared, false, Void, VoidPtr)
|
||||
__OMP_RTL(__kmpc_free_shared, false, Void, VoidPtr, SizeTy)
|
||||
__OMP_RTL(__kmpc_begin_sharing_variables, false, Void, VoidPtrPtrPtr, SizeTy)
|
||||
__OMP_RTL(__kmpc_end_sharing_variables, false, Void, )
|
||||
__OMP_RTL(__kmpc_get_shared_variables, false, Void, VoidPtrPtrPtr)
|
||||
|
@ -434,7 +434,6 @@ const CallInst *llvm::extractCallocCall(const Value *I,
|
||||
bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
|
||||
unsigned ExpectedNumParams;
|
||||
if (TLIFn == LibFunc_free ||
|
||||
TLIFn == LibFunc___kmpc_free_shared || // OpenMP Offloading RTL free
|
||||
TLIFn == LibFunc_ZdlPv || // operator delete(void*)
|
||||
TLIFn == LibFunc_ZdaPv || // operator delete[](void*)
|
||||
TLIFn == LibFunc_msvc_delete_ptr32 || // operator delete(void*)
|
||||
@ -457,7 +456,8 @@ bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr32_int || // delete[](void*, uint)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr64_longlong || // delete[](void*, ulonglong)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr32_nothrow || // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr64_nothrow) // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc_msvc_delete_array_ptr64_nothrow || // delete[](void*, nothrow)
|
||||
TLIFn == LibFunc___kmpc_free_shared) // OpenMP Offloading RTL free
|
||||
ExpectedNumParams = 2;
|
||||
else if (TLIFn == LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t || // delete(void*, align_val_t, nothrow)
|
||||
TLIFn == LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t || // delete[](void*, align_val_t, nothrow)
|
||||
|
@ -1048,8 +1048,10 @@ bool TargetLibraryInfoImpl::isValidProtoForLibFunc(const FunctionType &FTy,
|
||||
case LibFunc_mktime:
|
||||
case LibFunc_times:
|
||||
case LibFunc_vec_free:
|
||||
case LibFunc___kmpc_free_shared:
|
||||
return (NumParams != 0 && FTy.getParamType(0)->isPointerTy());
|
||||
case LibFunc___kmpc_free_shared:
|
||||
return (NumParams == 2 && FTy.getParamType(0)->isPointerTy() &&
|
||||
IsSizeTTy(FTy.getParamType(1)));
|
||||
|
||||
case LibFunc_fopen:
|
||||
return (NumParams == 2 && FTy.getReturnType()->isPointerTy() &&
|
||||
|
@ -24,6 +24,7 @@ define void @kernel() {
|
||||
; CHECK-NEXT: call void @bar() #[[ATTR0]]
|
||||
; CHECK-NEXT: call void @__kmpc_target_deinit(%struct.ident_t* nonnull null, i1 false, i1 true)
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
entry:
|
||||
%0 = call i32 @__kmpc_target_init(%struct.ident_t* nonnull null, i1 false, i1 true, i1 true)
|
||||
call void @foo()
|
||||
@ -42,7 +43,7 @@ define internal void @foo() {
|
||||
entry:
|
||||
%0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !12
|
||||
call void @use(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %0, i64 4)
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -52,13 +53,13 @@ define internal void @bar() {
|
||||
; CHECK-NEXT: entry:
|
||||
; CHECK-NEXT: [[TMP0:%.*]] = call i8* @__kmpc_alloc_shared(i64 noundef 4) #[[ATTR0]], !dbg [[DBG8:![0-9]+]]
|
||||
; CHECK-NEXT: call void @share(i8* nofree writeonly [[TMP0]]) #[[ATTR3:[0-9]+]]
|
||||
; CHECK-NEXT: call void @__kmpc_free_shared(i8* [[TMP0]]) #[[ATTR0]]
|
||||
; CHECK-NEXT: call void @__kmpc_free_shared(i8* [[TMP0]], i64 noundef 4) #[[ATTR0]]
|
||||
; CHECK-NEXT: ret void
|
||||
;
|
||||
entry:
|
||||
%0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !13
|
||||
call void @share(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %0, i64 4)
|
||||
ret void
|
||||
}
|
||||
|
||||
@ -94,15 +95,15 @@ define void @unused() {
|
||||
entry:
|
||||
%0 = call i8* @__kmpc_alloc_shared(i64 4), !dbg !14
|
||||
call void @use(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %0, i64 4)
|
||||
ret void
|
||||
}
|
||||
|
||||
; CHECK: declare i8* @__kmpc_alloc_shared(i64)
|
||||
declare i8* @__kmpc_alloc_shared(i64)
|
||||
|
||||
; CHECK: declare void @__kmpc_free_shared(i8* nocapture)
|
||||
declare void @__kmpc_free_shared(i8*)
|
||||
; CHECK: declare void @__kmpc_free_shared(i8* nocapture, i64)
|
||||
declare void @__kmpc_free_shared(i8*, i64)
|
||||
|
||||
!llvm.dbg.cu = !{!0}
|
||||
!llvm.module.flags = !{!3, !4, !6, !7}
|
||||
|
@ -25,7 +25,7 @@ entry:
|
||||
%x_on_stack = bitcast i8* %x to i32*
|
||||
%0 = bitcast i32* %x_on_stack to i8*
|
||||
call void @use(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %x)
|
||||
call void @__kmpc_free_shared(i8* %x, i64 4)
|
||||
call void @__kmpc_target_deinit(%struct.ident_t* @1, i1 false, i1 true)
|
||||
ret void
|
||||
}
|
||||
@ -50,7 +50,7 @@ master:
|
||||
%x_on_stack = bitcast i8* %x to [4 x i32]*
|
||||
%0 = bitcast [4 x i32]* %x_on_stack to i8*
|
||||
call void @use(i8* %0)
|
||||
call void @__kmpc_free_shared(i8* %x)
|
||||
call void @__kmpc_free_shared(i8* %x, i64 16)
|
||||
br label %exit
|
||||
exit:
|
||||
ret void
|
||||
@ -67,7 +67,7 @@ master:
|
||||
%y_on_stack = bitcast i8* %y to [4 x i32]*
|
||||
%1 = bitcast [4 x i32]* %y_on_stack to i8*
|
||||
call void @use(i8* %1)
|
||||
call void @__kmpc_free_shared(i8* %y)
|
||||
call void @__kmpc_free_shared(i8* %y, i64 4)
|
||||
br label %exit
|
||||
exit:
|
||||
ret void
|
||||
@ -79,11 +79,11 @@ entry:
|
||||
%0 = icmp eq i32 %call, -1
|
||||
br i1 %0, label %master, label %exit
|
||||
master:
|
||||
%y = call i8* @__kmpc_alloc_shared(i64 6), !dbg !12
|
||||
%y = call i8* @__kmpc_alloc_shared(i64 24), !dbg !12
|
||||
%y_on_stack = bitcast i8* %y to [6 x i32]*
|
||||
%1 = bitcast [6 x i32]* %y_on_stack to i8*
|
||||
call void @use(i8* %1)
|
||||
call void @__kmpc_free_shared(i8* %y)
|
||||
call void @__kmpc_free_shared(i8* %y, i64 24)
|
||||
br label %exit
|
||||
exit:
|
||||
ret void
|
||||
@ -98,7 +98,7 @@ entry:
|
||||
|
||||
declare i8* @__kmpc_alloc_shared(i64)
|
||||
|
||||
declare void @__kmpc_free_shared(i8*)
|
||||
declare void @__kmpc_free_shared(i8*, i64)
|
||||
|
||||
declare i32 @llvm.nvvm.read.ptx.sreg.tid.x()
|
||||
|
||||
|
@ -589,7 +589,7 @@ TEST_F(TargetLibraryInfoTest, ValidProto) {
|
||||
|
||||
// These functions are OpenMP Offloading allocation / free routines
|
||||
"declare i8* @__kmpc_alloc_shared(i64)\n"
|
||||
"declare void @__kmpc_free_shared(i8*)\n"
|
||||
"declare void @__kmpc_free_shared(i8*, i64)\n"
|
||||
);
|
||||
|
||||
for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
|
||||
|
Loading…
Reference in New Issue
Block a user