[PATCH] D102087: [OpenMP] Add new OpenMP globalization functions to library info
Joseph Huber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon May 10 14:04:44 PDT 2021
jhuber6 updated this revision to Diff 344199.
jhuber6 added a comment.
Adding `__kmpc_free_shared` as a valid `free` built-in function so it works properly with `AAHeapToStack`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102087/new/
https://reviews.llvm.org/D102087
Files:
llvm/include/llvm/Analysis/TargetLibraryInfo.def
llvm/lib/Analysis/MemoryBuiltins.cpp
llvm/lib/Analysis/TargetLibraryInfo.cpp
llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
Index: llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
===================================================================
--- llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
+++ llvm/unittests/Analysis/TargetLibraryInfoTest.cpp
@@ -586,6 +586,10 @@
"declare i8* @vec_malloc(i64)\n"
"declare i8* @vec_realloc(i8*, i64)\n"
"declare void @vec_free(i8*)\n"
+
+ // These functions are OpenMP Offloading allocation / free routines
+ "declare i8* @__kmpc_alloc_shared(i64)\n"
+ "declare void @__kmpc_free_shared(i8*)\n"
);
for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
Index: llvm/lib/Analysis/TargetLibraryInfo.cpp
===================================================================
--- llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -158,6 +158,8 @@
TLI.setUnavailable(LibFunc_memcpy);
TLI.setUnavailable(LibFunc_memset);
TLI.setUnavailable(LibFunc_memset_pattern16);
+ TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
+ TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
return;
}
@@ -601,6 +603,8 @@
// TLI.setAvailable(llvm::LibFunc_memcpy);
// TLI.setAvailable(llvm::LibFunc_memset);
+ TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
+ TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
} else {
TLI.setUnavailable(LibFunc_nvvm_reflect);
}
@@ -891,6 +895,7 @@
FTy.getParamType(2)->isPointerTy());
case LibFunc_system:
return (NumParams == 1 && FTy.getParamType(0)->isPointerTy());
+ case LibFunc___kmpc_alloc_shared:
case LibFunc_malloc:
case LibFunc_vec_malloc:
return (NumParams == 1 && FTy.getReturnType()->isPointerTy());
@@ -1027,6 +1032,7 @@
case LibFunc_mktime:
case LibFunc_times:
case LibFunc_vec_free:
+ case LibFunc___kmpc_free_shared:
return (NumParams != 0 && FTy.getParamType(0)->isPointerTy());
case LibFunc_fopen:
Index: llvm/lib/Analysis/MemoryBuiltins.cpp
===================================================================
--- llvm/lib/Analysis/MemoryBuiltins.cpp
+++ llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -110,7 +110,8 @@
{LibFunc_vec_realloc, {ReallocLike, 2, 1, -1}},
{LibFunc_reallocf, {ReallocLike, 2, 1, -1}},
{LibFunc_strdup, {StrDupLike, 1, -1, -1}},
- {LibFunc_strndup, {StrDupLike, 2, 1, -1}}
+ {LibFunc_strndup, {StrDupLike, 2, 1, -1}},
+ {LibFunc___kmpc_alloc_shared, {MallocLike, 1, 0, -1}}
// TODO: Handle "int posix_memalign(void **, size_t, size_t)"
};
@@ -434,6 +435,7 @@
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*)
Index: llvm/include/llvm/Analysis/TargetLibraryInfo.def
===================================================================
--- llvm/include/llvm/Analysis/TargetLibraryInfo.def
+++ llvm/include/llvm/Analysis/TargetLibraryInfo.def
@@ -329,6 +329,12 @@
/// int __isoc99_sscanf(const char *s, const char *format, ...)
TLI_DEFINE_ENUM_INTERNAL(dunder_isoc99_sscanf)
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);
+TLI_DEFINE_ENUM_INTERNAL(__kmpc_free_shared)
+TLI_DEFINE_STRING_INTERNAL("__kmpc_free_shared")
/// double __log10_finite(double x);
TLI_DEFINE_ENUM_INTERNAL(log10_finite)
TLI_DEFINE_STRING_INTERNAL("__log10_finite")
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102087.344199.patch
Type: text/x-patch
Size: 3842 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210510/8bc82782/attachment.bin>
More information about the llvm-commits
mailing list