[llvm] [OpenMP] Move alloc / free shared from TLI to alloc tags (PR #190365)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 3 10:21:17 PDT 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Joseph Huber (jhuber6)
<details>
<summary>Changes</summary>
Summary:
Allocation kinds were added after these were introduced. We only needed
the TLI to identify these in the attributor so we can now just use
attributes. Update the usage in OpenMP and drop the TLI interface.
Fixes: https://github.com/llvm/llvm-project/issues/190072
---
Patch is 48.48 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/190365.diff
14 Files Affected:
- (modified) llvm/include/llvm/Analysis/TargetLibraryInfo.td (-7)
- (modified) llvm/include/llvm/Frontend/OpenMP/OMPKinds.def (+13-2)
- (modified) llvm/lib/Analysis/MemoryBuiltins.cpp (-5)
- (modified) llvm/lib/Analysis/TargetLibraryInfo.cpp (+1-10)
- (modified) llvm/lib/Transforms/IPO/AttributorAttributes.cpp (+18-20)
- (modified) llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll (+19-17)
- (modified) llvm/test/Transforms/OpenMP/add_attributes.ll (+6-6)
- (modified) llvm/test/Transforms/OpenMP/nested_parallelism.ll (+6-6)
- (modified) llvm/test/Transforms/OpenMP/remove_globalization.ll (+15-13)
- (modified) llvm/test/Transforms/OpenMP/replace_globalization.ll (+13-15)
- (modified) llvm/test/Transforms/OpenMP/spmdization.ll (+12-12)
- (modified) llvm/test/Transforms/OpenMP/spmdization_guarding.ll (+4-4)
- (modified) llvm/test/Transforms/OpenMP/spmdization_indirect.ll (+6-6)
- (modified) llvm/unittests/Analysis/TargetLibraryInfoTest.cpp (+1-5)
``````````diff
diff --git a/llvm/include/llvm/Analysis/TargetLibraryInfo.td b/llvm/include/llvm/Analysis/TargetLibraryInfo.td
index 10b43ad2466fc..6b17e70b87f55 100644
--- a/llvm/include/llvm/Analysis/TargetLibraryInfo.td
+++ b/llvm/include/llvm/Analysis/TargetLibraryInfo.td
@@ -404,13 +404,6 @@ def dunder_isoc99_scanf : TargetLibCall<"__isoc99_scanf", Int, [Ptr, Ellip]>;
def dunder_isoc99_sscanf
: TargetLibCall<"__isoc99_sscanf", Int, [Ptr, Ptr, Ellip]>;
-/// void* __kmpc_alloc_shared(size_t nbyte);
-def __kmpc_alloc_shared : TargetLibCall<"__kmpc_alloc_shared", Ptr, [SizeT]>;
-
-/// void __kmpc_free_shared(void *ptr, size_t nbyte);
-def __kmpc_free_shared
- : TargetLibCall<"__kmpc_free_shared", Void, [Ptr, SizeT]>;
-
/// double __log10_finite(double x);
def log10_finite : TargetLibCall<"__log10_finite", Dbl, [Dbl]>;
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
index 5fe7ee8997243..2f2ea397a572d 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -524,6 +524,8 @@ __OMP_RTL(__last, false, Void, )
#define EnumAttr(Kind) Attribute::get(Ctx, Attribute::AttrKind::Kind)
#define EnumAttrInt(Kind, N) Attribute::get(Ctx, Attribute::AttrKind::Kind, N)
#define AllocSizeAttr(N, M) Attribute::getWithAllocSizeArgs(Ctx, N, M)
+#define AllocKindAttr(Kind) Attribute::getWithAllocKind(Ctx, Kind)
+#define AllocFamilyAttr(Name) Attribute::get(Ctx, "alloc-family", Name)
#define MemoryAttr(ME) Attribute::getWithMemoryEffects(Ctx, ME)
#define NoCaptureAttr Attribute::getWithCaptureInfo(Ctx, CaptureInfo::none())
#define AttributeSet(...) \
@@ -989,9 +991,16 @@ __OMP_RTL_ATTRS(__kmpc_doacross_fini, BarrierAttrs, AttributeSet(),
__OMP_RTL_ATTRS(__kmpc_alloc_shared,
AttributeSet(EnumAttr(NoUnwind), EnumAttr(NoSync),
- AllocSizeAttr(0, std::nullopt)),
+ AllocSizeAttr(0, std::nullopt),
+ AllocKindAttr(AllocFnKind::Alloc |
+ AllocFnKind::Uninitialized),
+ AllocFamilyAttr("__kmpc_alloc_shared")),
ReturnPtrAttrs, ParamAttrs(SizeTyExt))
-__OMP_RTL_ATTRS(__kmpc_free_shared, DeviceAllocAttrs, AttributeSet(),
+__OMP_RTL_ATTRS(__kmpc_free_shared,
+ AttributeSet(EnumAttr(NoUnwind), EnumAttr(NoSync),
+ AllocKindAttr(AllocFnKind::Free),
+ AllocFamilyAttr("__kmpc_alloc_shared")),
+ AttributeSet(),
ParamAttrs(AttributeSet(NoCaptureAttr,
EnumAttr(AllocatedPointer)),
SizeTyExt))
@@ -1110,6 +1119,8 @@ __OMP_RTL_ATTRS(__kmpc_is_spmd_exec_mode, AttributeSet(), SExt, ParamAttrs())
#undef EnumAttrInt
#undef ParamAttrs
#undef AllocSizeAttr
+#undef AllocKindAttr
+#undef AllocFamilyAttr
///}
diff --git a/llvm/lib/Analysis/MemoryBuiltins.cpp b/llvm/lib/Analysis/MemoryBuiltins.cpp
index c7f89de9f8b11..0be03eb7af558 100644
--- a/llvm/lib/Analysis/MemoryBuiltins.cpp
+++ b/llvm/lib/Analysis/MemoryBuiltins.cpp
@@ -74,7 +74,6 @@ enum class MallocFamily {
MSVCNew, // new(unsigned int)
MSVCArrayNew, // new[](unsigned int)
VecMalloc,
- KmpcAllocShared,
};
StringRef mangledNameForMallocFamily(const MallocFamily &Family) {
@@ -95,8 +94,6 @@ StringRef mangledNameForMallocFamily(const MallocFamily &Family) {
return "??_U at YAPAXI@Z";
case MallocFamily::VecMalloc:
return "vec_malloc";
- case MallocFamily::KmpcAllocShared:
- return "__kmpc_alloc_shared";
}
llvm_unreachable("missing an alloc family");
}
@@ -152,7 +149,6 @@ static const std::pair<LibFunc, AllocFnsTy> AllocationFnData[] = {
{LibFunc_dunder_strdup, {StrDupLike, 1, -1, -1, -1, MallocFamily::Malloc}},
{LibFunc_strndup, {StrDupLike, 2, 1, -1, -1, MallocFamily::Malloc}},
{LibFunc_dunder_strndup, {StrDupLike, 2, 1, -1, -1, MallocFamily::Malloc}},
- {LibFunc___kmpc_alloc_shared, {MallocLike, 1, 0, -1, -1, MallocFamily::KmpcAllocShared}},
};
// clang-format on
@@ -478,7 +474,6 @@ static const std::pair<LibFunc, FreeFnsTy> FreeFnData[] = {
{LibFunc_msvc_delete_array_ptr64_longlong, {2, MallocFamily::MSVCArrayNew}}, // delete[](void*, ulonglong)
{LibFunc_msvc_delete_array_ptr32_nothrow, {2, MallocFamily::MSVCArrayNew}}, // delete[](void*, nothrow)
{LibFunc_msvc_delete_array_ptr64_nothrow, {2, MallocFamily::MSVCArrayNew}}, // delete[](void*, nothrow)
- {LibFunc___kmpc_free_shared, {2, MallocFamily::KmpcAllocShared}}, // OpenMP Offloading RTL free
{LibFunc_ZdlPvSt11align_val_tRKSt9nothrow_t, {3, MallocFamily::CPPNewAligned}}, // delete(void*, align_val_t, nothrow)
{LibFunc_ZdaPvSt11align_val_tRKSt9nothrow_t, {3, MallocFamily::CPPNewArrayAligned}}, // delete[](void*, align_val_t, nothrow)
{LibFunc_ZdlPvjSt11align_val_t, {3, MallocFamily::CPPNewAligned}}, // delete(void*, unsigned int, align_val_t)
diff --git a/llvm/lib/Analysis/TargetLibraryInfo.cpp b/llvm/lib/Analysis/TargetLibraryInfo.cpp
index d0555d68606b4..6b8f861392254 100644
--- a/llvm/lib/Analysis/TargetLibraryInfo.cpp
+++ b/llvm/lib/Analysis/TargetLibraryInfo.cpp
@@ -142,12 +142,9 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setUnavailable(LibFunc_fputs_unlocked);
TLI.setUnavailable(LibFunc_fgets_unlocked);
- // There is really no runtime library on AMDGPU, apart from
- // __kmpc_alloc/free_shared.
+ // There is really no runtime library on AMDGPU.
if (T.isAMDGPU()) {
TLI.disableAllFunctions();
- TLI.setAvailable(llvm::LibFunc___kmpc_alloc_shared);
- TLI.setAvailable(llvm::LibFunc___kmpc_free_shared);
return;
}
@@ -785,8 +782,6 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
// Miscellaneous other functions not provided.
TLI.setUnavailable(LibFunc_atomic_load);
TLI.setUnavailable(LibFunc_atomic_store);
- TLI.setUnavailable(LibFunc___kmpc_alloc_shared);
- TLI.setUnavailable(LibFunc___kmpc_free_shared);
TLI.setUnavailable(LibFunc_dunder_strndup);
TLI.setUnavailable(LibFunc_bcmp);
TLI.setUnavailable(LibFunc_bcopy);
@@ -834,8 +829,6 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
TLI.setAvailable(LibFunc_putc_unlocked);
TLI.setAvailable(LibFunc_putchar_unlocked);
- TLI.setUnavailable(LibFunc___kmpc_alloc_shared);
- TLI.setUnavailable(LibFunc___kmpc_free_shared);
TLI.setUnavailable(LibFunc_dunder_strndup);
TLI.setUnavailable(LibFunc_memccpy_chk);
TLI.setUnavailable(LibFunc_strlen_chk);
@@ -875,8 +868,6 @@ static void initializeLibCalls(TargetLibraryInfoImpl &TLI, const Triple &T,
// 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);
}
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 95c0531c2183b..4282fe7623630 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -6689,12 +6689,17 @@ struct AAValueSimplifyCallSiteArgument : AAValueSimplifyFloating {
namespace {
struct AAHeapToStackFunction final : public AAHeapToStack {
+ static bool isGlobalizedLocal(const CallBase &CB) {
+ Attribute A = CB.getFnAttr("alloc-family");
+ return A.isValid() && A.getValueAsString() == "__kmpc_alloc_shared";
+ }
+
struct AllocationInfo {
/// The call that allocates the memory.
CallBase *const CB;
- /// The library function id for the allocation.
- LibFunc LibraryFunctionId = NotLibFunc;
+ /// Whether this allocation is an OpenMP globalized local variable.
+ bool IsGlobalizedLocal = false;
/// The status wrt. a rewrite.
enum {
@@ -6763,8 +6768,7 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
if (nullptr != getInitialValueOfAllocation(CB, TLI, I8Ty)) {
AllocationInfo *AI = new (A.Allocator) AllocationInfo{CB};
AllocationInfos[CB] = AI;
- if (TLI)
- TLI->getLibFunc(*CB, AI->LibraryFunctionId);
+ AI->IsGlobalizedLocal = isGlobalizedLocal(*CB);
}
}
return true;
@@ -6858,13 +6862,11 @@ struct AAHeapToStackFunction final : public AAHeapToStack {
<< "\n");
auto Remark = [&](OptimizationRemark OR) {
- LibFunc IsAllocShared;
- if (TLI->getLibFunc(*AI.CB, IsAllocShared))
- if (IsAllocShared == LibFunc___kmpc_alloc_shared)
- return OR << "Moving globalized variable to the stack.";
+ if (AI.IsGlobalizedLocal)
+ return OR << "Moving globalized variable to the stack.";
return OR << "Moving memory allocation from the heap to the stack.";
};
- if (AI.LibraryFunctionId == LibFunc___kmpc_alloc_shared)
+ if (AI.IsGlobalizedLocal)
A.emitRemark<OptimizationRemark>(AI.CB, "OMP110", Remark);
else
A.emitRemark<OptimizationRemark>(AI.CB, "HeapToStack", Remark);
@@ -7111,8 +7113,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
return false;
}
- // __kmpc_alloc_shared and __kmpc_alloc_free are by construction matched.
- if (AI.LibraryFunctionId != LibFunc___kmpc_alloc_shared) {
+ // __kmpc_alloc_shared and __kmpc_free_shared are by construction matched.
+ if (!AI.IsGlobalizedLocal) {
Instruction *CtxI = isa<InvokeInst>(AI.CB) ? AI.CB : AI.CB->getNextNode();
if (!Explorer || !Explorer->findInContextOf(UniqueFree, CtxI)) {
LLVM_DEBUG(dbgs() << "[H2S] unique free call might not be executed "
@@ -7162,8 +7164,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
A, this, CBIRP, DepClassTy::OPTIONAL, IsKnownNoFree);
if (!IsAssumedNoCapture ||
- (AI.LibraryFunctionId != LibFunc___kmpc_alloc_shared &&
- !IsAssumedNoFree)) {
+ (!AI.IsGlobalizedLocal && !IsAssumedNoFree)) {
AI.HasPotentiallyFreeingUnknownUses |= !IsAssumedNoFree;
// Emit a missed remark if this is missed OpenMP globalization.
@@ -7174,8 +7175,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
"parameter as `__attribute__((noescape))` to override.";
};
- if (ValidUsesOnly &&
- AI.LibraryFunctionId == LibFunc___kmpc_alloc_shared)
+ if (ValidUsesOnly && AI.IsGlobalizedLocal)
A.emitRemark<OptimizationRemarkMissed>(CB, "OMP113", Remark);
LLVM_DEBUG(dbgs() << "[H2S] Bad user: " << *UserI << "\n");
@@ -7236,8 +7236,7 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
}
std::optional<APInt> Size = getSize(A, *this, AI);
- if (AI.LibraryFunctionId != LibFunc___kmpc_alloc_shared &&
- MaxHeapToStackSize != -1) {
+ if (!AI.IsGlobalizedLocal && MaxHeapToStackSize != -1) {
if (!Size || Size->ugt(MaxHeapToStackSize)) {
LLVM_DEBUG({
if (!Size)
@@ -7271,9 +7270,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
// Check if we still think we can move it into the entry block. If the
// alloca comes from a converted __kmpc_alloc_shared then we can usually
- // ignore the potential compilations associated with loops.
- bool IsGlobalizedLocal =
- AI.LibraryFunctionId == LibFunc___kmpc_alloc_shared;
+ // ignore the potential complications associated with loops.
+ bool IsGlobalizedLocal = AI.IsGlobalizedLocal;
if (AI.MoveAllocaIntoEntry &&
(!Size.has_value() ||
(!IsGlobalizedLocal && IsInLoop(*AI.CB->getParent()))))
diff --git a/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll b/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
index 9a6e0680bb44d..a83eeee397f1f 100644
--- a/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
+++ b/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
@@ -305,7 +305,7 @@ define void @test9() {
; CHECK-NEXT: [[I:%.*]] = tail call noalias ptr @malloc(i64 noundef 4)
; CHECK-NEXT: tail call void @no_sync_func(ptr nofree captures(none) [[I]])
; CHECK-NEXT: store i32 10, ptr [[I]], align 4
-; CHECK-NEXT: tail call void @foo_nounw(ptr nofree nonnull align 4 dereferenceable(4) [[I]]) #[[ATTR6:[0-9]+]]
+; CHECK-NEXT: tail call void @foo_nounw(ptr nofree nonnull align 4 dereferenceable(4) [[I]]) #[[ATTR8:[0-9]+]]
; CHECK-NEXT: tail call void @free(ptr nonnull align 4 captures(none) dereferenceable(4) [[I]])
; CHECK-NEXT: ret void
;
@@ -346,7 +346,7 @@ define void @test11() {
; CHECK-LABEL: define {{[^@]+}}@test11() {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = tail call noalias ptr @malloc(i64 noundef 4)
-; CHECK-NEXT: tail call void @sync_will_return(ptr [[I]]) #[[ATTR6]]
+; CHECK-NEXT: tail call void @sync_will_return(ptr [[I]]) #[[ATTR8]]
; CHECK-NEXT: tail call void @free(ptr captures(none) [[I]])
; CHECK-NEXT: ret void
;
@@ -600,7 +600,7 @@ define void @test16c(i8 %v, ptr %P) {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = tail call noalias ptr @malloc(i64 noundef 4)
; CHECK-NEXT: store ptr [[I]], ptr [[P]], align 8
-; CHECK-NEXT: tail call void @no_sync_func(ptr nofree captures(none) [[I]]) #[[ATTR6]]
+; CHECK-NEXT: tail call void @no_sync_func(ptr nofree captures(none) [[I]]) #[[ATTR8]]
; CHECK-NEXT: tail call void @free(ptr captures(none) [[I]])
; CHECK-NEXT: ret void
;
@@ -626,15 +626,15 @@ bb:
ret void
}
-declare ptr @__kmpc_alloc_shared(i64)
-declare void @__kmpc_free_shared(ptr nocapture, i64)
+declare ptr @__kmpc_alloc_shared(i64) allockind("alloc,uninitialized") allocsize(0) "alloc-family"="__kmpc_alloc_shared"
+declare void @__kmpc_free_shared(ptr allocptr nocapture, i64) allockind("free") "alloc-family"="__kmpc_alloc_shared"
define void @test17() {
; CHECK-LABEL: define {{[^@]+}}@test17() {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I_H2S:%.*]] = alloca i8, i64 4, align 1, addrspace(5)
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast ptr addrspace(5) [[I_H2S]] to ptr
-; CHECK-NEXT: tail call void @usei8(ptr noalias nofree captures(none) [[MALLOC_CAST]]) #[[ATTR7:[0-9]+]]
+; CHECK-NEXT: tail call void @usei8(ptr noalias nofree captures(none) [[MALLOC_CAST]]) #[[ATTR9:[0-9]+]]
; CHECK-NEXT: ret void
;
bb:
@@ -648,7 +648,7 @@ define void @test17b() {
; CHECK-LABEL: define {{[^@]+}}@test17b() {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = tail call noalias ptr @__kmpc_alloc_shared(i64 noundef 4)
-; CHECK-NEXT: tail call void @usei8(ptr nofree [[I]]) #[[ATTR7]]
+; CHECK-NEXT: tail call void @usei8(ptr nofree [[I]]) #[[ATTR9]]
; CHECK-NEXT: tail call void @__kmpc_free_shared(ptr captures(none) [[I]], i64 noundef 4)
; CHECK-NEXT: ret void
;
@@ -666,7 +666,7 @@ define void @move_alloca() {
; CHECK-NEXT: br label [[NOT_ENTRY:%.*]]
; CHECK: not_entry:
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast ptr addrspace(5) [[I_H2S]] to ptr
-; CHECK-NEXT: tail call void @usei8(ptr noalias nofree captures(none) [[MALLOC_CAST]]) #[[ATTR7]]
+; CHECK-NEXT: tail call void @usei8(ptr noalias nofree captures(none) [[MALLOC_CAST]]) #[[ATTR9]]
; CHECK-NEXT: ret void
;
entry:
@@ -683,11 +683,11 @@ not_entry:
define void @test16e(i8 %v) norecurse {
; CHECK: Function Attrs: norecurse
; CHECK-LABEL: define {{[^@]+}}@test16e
-; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR5:[0-9]+]] {
+; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR7:[0-9]+]] {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I:%.*]] = tail call noalias ptr @__kmpc_alloc_shared(i64 noundef 4)
; CHECK-NEXT: store ptr [[I]], ptr @G, align 8
-; CHECK-NEXT: call void @usei8(ptr nofree captures(none) [[I]]) #[[ATTR8:[0-9]+]]
+; CHECK-NEXT: call void @usei8(ptr nofree captures(none) [[I]]) #[[ATTR10:[0-9]+]]
; CHECK-NEXT: tail call void @__kmpc_free_shared(ptr noalias captures(none) [[I]], i64 noundef 4)
; CHECK-NEXT: ret void
;
@@ -704,12 +704,12 @@ bb:
define void @test16f(i8 %v) norecurse {
; CHECK: Function Attrs: norecurse
; CHECK-LABEL: define {{[^@]+}}@test16f
-; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR5]] {
+; CHECK-SAME: (i8 [[V:%.*]]) #[[ATTR7]] {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I_H2S:%.*]] = alloca i8, i64 4, align 1, addrspace(5)
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast ptr addrspace(5) [[I_H2S]] to ptr
; CHECK-NEXT: store ptr [[MALLOC_CAST]], ptr @Gtl, align 8
-; CHECK-NEXT: call void @usei8(ptr nofree captures(none) [[MALLOC_CAST]]) #[[ATTR8]]
+; CHECK-NEXT: call void @usei8(ptr nofree captures(none) [[MALLOC_CAST]]) #[[ATTR10]]
; CHECK-NEXT: ret void
;
bb:
@@ -726,7 +726,7 @@ define void @convert_large_kmpc_alloc_shared() {
; CHECK-NEXT: bb:
; CHECK-NEXT: [[I_H2S:%.*]] = alloca i8, i64 256, align 1, addrspace(5)
; CHECK-NEXT: [[MALLOC_CAST:%.*]] = addrspacecast ptr addrspace(5) [[I_H2S]] to ptr
-; CHECK-NEXT: tail call void @usei8(ptr noalias nofree captures(none) [[MALLOC_CAST]]) #[[ATTR7]]
+; CHECK-NEXT: tail call void @usei8(ptr noalias nofree captures(none) [[MALLOC_CAST]]) #[[ATTR9]]
; CHECK-NEXT: ret void
;
bb:
@@ -743,10 +743,12 @@ bb:
; CHECK: attributes #[[ATTR2:[0-9]+]] = { nofree nounwind }
; CHECK: attributes #[[ATTR3]] = { noreturn }
; CHECK: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
-; CHECK: attributes #[[ATTR5]] = { norecurse }
-; CHECK: attributes #[[ATTR6]] = { nounwind }
-; CHECK: attributes #[[ATTR7]] = { nosync nounwind willreturn }
-; CHECK: attributes #[[ATTR8]] = { nocallback nosync nounwind willreturn }
+; CHECK: attributes #[[ATTR5:[0-9]+]] = { allockind("alloc,uninitialized") allocsize(0) "alloc-family"="__kmpc_alloc_shared" }
+; CHECK: attributes #[[ATTR6:[0-9]+]] = { allockind("free") "alloc-family"="__kmpc_alloc_shared" }
+; CHECK: attributes #[[ATTR7]] = { norecurse }
+; CHECK: attributes #[[ATTR8]] = { nounwind }
+; CHECK: attributes #[[ATTR9]] = { nosync nounwind willreturn }
+; CHECK: attributes #[[ATTR10]] = { nocallback nosync nounwind willreturn }
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CGSCC: {{.*}}
diff --git a/llvm/test/Transforms/OpenMP/add_attributes.ll b/llvm/test/Transforms/OpenMP/add_attributes.ll
index 2e8f84ca86b25..e5259b7e91411 100644
--- a/llvm/test/Transforms/OpenMP/add_attributes.ll
+++ b/llvm/test/Transforms/OpenMP/add_attributes.ll
@@ -1293,7 +1293,7 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr,
; CHECK: ; Function Attrs: nounwind
; CHECK-NEXT: declare noalias ptr @__kmpc_aligned_alloc(i32, i64, i64, ptr)
-; CHECK: ; Function Attrs: nosync nounwind allocsize(0)
+; CHECK: ; Function Attrs: nosync nounwind allockind("alloc,uninitialized") allocsize(0)
; CHECK-NEXT: declare noalias ptr @__kmpc_alloc_shared(i64)
; CHECK: ; Function Attrs: convergent nounwind
@@ -1329,7 +1329,7 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr,
; CHECK-NOT: Function Attrs
; CHECK: declare void @__kmpc_fork_call_if(ptr, i32, ptr, i32, ptr)
-; CHECK: ; Function Attrs: nosync nounwind
+; CHECK: ; Function Attrs: nosync nounwind allockind("free")
; CHECK-NEXT: declare void @__kmpc_free_shared(ptr allocptr captures(none), i64)
; CHECK: ; Function Attrs: nounwind
@@ -1935,7 +1935,7 @@ declare i32 @__tgt_target_kernel_nowait(ptr, i64, i32, i32, ptr, ptr, i32, ptr,
; OPTIMISTIC: ; Function Attrs: nofree nosync nounwind willreturn
; OPTIMISTIC-NEXT: declare noalias ptr @__kmpc_aligned_alloc(i32, i64, i64, ptr)
-; OPTIMISTIC: ; Function Attrs: nosync nounwind allocsize(0)
+; OPTIMISTIC: ; Function Attrs: nosync nounwind allockind("alloc,uninitialized") allocsize(0)
; OPTIMISTIC-NEXT: declare noalias ptr @__kmpc_alloc_shared(i64)
; OPTIMISTIC: ; Function Attrs: conv...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/190365
More information about the llvm-commits
mailing list