[PATCH] D148849: [OpenMP-OPT] Remove limit for heap to stack conversions of __kmpc_alloc_shared allocations

Gheorghe-Teodor Bercea via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 20 15:45:55 PDT 2023


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)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148849.515516.patch
Type: text/x-patch
Size: 1547 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230420/080b893a/attachment-0001.bin>


More information about the cfe-commits mailing list