[llvm] 1a58c3d - Avoid capping heap to stack optimization for __kmpc_alloc_shared allocations.
Doru Bercea via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 21 06:28:03 PDT 2023
Author: Doru Bercea
Date: 2023-04-21T09:27:53-04:00
New Revision: 1a58c3d601b4c982afeb714c3a6c4be4d787cbf1
URL: https://github.com/llvm/llvm-project/commit/1a58c3d601b4c982afeb714c3a6c4be4d787cbf1
DIFF: https://github.com/llvm/llvm-project/commit/1a58c3d601b4c982afeb714c3a6c4be4d787cbf1.diff
LOG: Avoid capping heap to stack optimization for __kmpc_alloc_shared allocations.
Review: https://reviews.llvm.org/D148849
Added:
Modified:
llvm/lib/Transforms/IPO/AttributorAttributes.cpp
llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
index 7e1adfeece432..6eda254244fdb 100644
--- a/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ b/llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7180,7 +7180,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
}
std::optional<APInt> Size = getSize(A, *this, AI);
- if (MaxHeapToStackSize != -1) {
+ if (AI.LibraryFunctionId != LibFunc___kmpc_alloc_shared &&
+ MaxHeapToStackSize != -1) {
if (!Size || Size->ugt(MaxHeapToStackSize)) {
LLVM_DEBUG({
if (!Size)
diff --git a/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll b/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
index 0a3d5b678c53a..df144b28cc529 100644
--- a/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
+++ b/llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
@@ -741,6 +741,21 @@ bb:
ret void
}
+define void @convert_large_kmpc_alloc_shared() {
+; CHECK-LABEL: define {{[^@]+}}@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 nocapture nofree [[MALLOC_CAST]]) #[[ATTR7]]
+; CHECK-NEXT: ret void
+;
+bb:
+ %i = tail call noalias ptr @__kmpc_alloc_shared(i64 256)
+ tail call void @usei8(ptr nocapture nofree %i) nosync nounwind willreturn
+ tail call void @__kmpc_free_shared(ptr %i, i64 256)
+ ret void
+}
+
;.
; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind willreturn }
More information about the llvm-commits
mailing list