doru1004 updated this revision to Diff 515516.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148849/new/

https://reviews.llvm.org/D148849

Files:
  llvm/lib/Transforms/IPO/AttributorAttributes.cpp
  llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll


Index: llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
===================================================================
--- llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
+++ llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
@@ -741,6 +741,21 @@
   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 }
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7180,7 +7180,8 @@
     }
 
     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)


Index: llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
===================================================================
--- llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
+++ llvm/test/Transforms/Attributor/heap_to_stack_gpu.ll
@@ -741,6 +741,21 @@
   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 }
Index: llvm/lib/Transforms/IPO/AttributorAttributes.cpp
===================================================================
--- llvm/lib/Transforms/IPO/AttributorAttributes.cpp
+++ llvm/lib/Transforms/IPO/AttributorAttributes.cpp
@@ -7180,7 +7180,8 @@
     }
 
     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)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to