[llvm-branch-commits] [llvm] ea97fc6 - [OpenMP][FIX] The `llvm.amdgcn.s.barrier` is actually not aligned

Tom Stellard via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Feb 15 10:43:19 PST 2022


Author: Johannes Doerfert
Date: 2022-02-15T10:42:40-08:00
New Revision: ea97fc6b564ec6a843337a550a2209b653cffceb

URL: https://github.com/llvm/llvm-project/commit/ea97fc6b564ec6a843337a550a2209b653cffceb
DIFF: https://github.com/llvm/llvm-project/commit/ea97fc6b564ec6a843337a550a2209b653cffceb.diff

LOG: [OpenMP][FIX] The `llvm.amdgcn.s.barrier` is actually not aligned

If we assume `llvm.amdgcn.s.barrier` is aligned we may remove it and
cause OpenMP GPU applications on the AMD GPU to be stuck or wrongly
synchronized.

Reported by Carlo Bertolli.

(cherry picked from commit ede248e614bb2c232b7b1815829eb3d5c1aab1e4)

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/OpenMPOpt.cpp
    llvm/test/Transforms/OpenMP/barrier_removal.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 2d765fb6ce6d0..520b6ebf9e74f 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1458,7 +1458,6 @@ struct OpenMPOpt {
             case Intrinsic::nvvm_barrier0_and:
             case Intrinsic::nvvm_barrier0_or:
             case Intrinsic::nvvm_barrier0_popc:
-            case Intrinsic::amdgcn_s_barrier:
               return true;
             default:
               break;

diff  --git a/llvm/test/Transforms/OpenMP/barrier_removal.ll b/llvm/test/Transforms/OpenMP/barrier_removal.ll
index 8c7cca8053e93..7de421f728f10 100644
--- a/llvm/test/Transforms/OpenMP/barrier_removal.ll
+++ b/llvm/test/Transforms/OpenMP/barrier_removal.ll
@@ -66,8 +66,9 @@ define void @pos_empty_6() {
   call i32 @llvm.nvvm.barrier0.popc(i32 0)
   ret void
 }
-define void @pos_empty_7() {
-; CHECK-LABEL: define {{[^@]+}}@pos_empty_7() {
+define void @neg_empty_7() {
+; CHECK-LABEL: define {{[^@]+}}@neg_empty_7() {
+; CHECK-NEXT:    call void @llvm.amdgcn.s.barrier()
 ; CHECK-NEXT:    ret void
 ;
   call void @llvm.amdgcn.s.barrier()
@@ -211,6 +212,7 @@ define void @neg_mem() {
 
 define void @pos_multiple() {
 ; CHECK-LABEL: define {{[^@]+}}@pos_multiple() {
+; CHECK-NEXT:    call void @llvm.amdgcn.s.barrier()
 ; CHECK-NEXT:    ret void
 ;
   call void @llvm.nvvm.barrier0()
@@ -233,7 +235,7 @@ define void @pos_multiple() {
 !3 = !{void ()* @pos_empty_4, !"kernel", i32 1}
 !4 = !{void ()* @pos_empty_5, !"kernel", i32 1}
 !5 = !{void ()* @pos_empty_6, !"kernel", i32 1}
-!6 = !{void ()* @pos_empty_7, !"kernel", i32 1}
+!6 = !{void ()* @neg_empty_7, !"kernel", i32 1}
 !7 = !{void ()* @pos_constant_loads, !"kernel", i32 1}
 !8 = !{void ()* @neg_loads, !"kernel", i32 1}
 !9 = !{void ()* @pos_priv_mem, !"kernel", i32 1}
@@ -254,7 +256,7 @@ define void @pos_multiple() {
 ; CHECK: [[META5:![0-9]+]] = !{void ()* @pos_empty_4, !"kernel", i32 1}
 ; CHECK: [[META6:![0-9]+]] = !{void ()* @pos_empty_5, !"kernel", i32 1}
 ; CHECK: [[META7:![0-9]+]] = !{void ()* @pos_empty_6, !"kernel", i32 1}
-; CHECK: [[META8:![0-9]+]] = !{void ()* @pos_empty_7, !"kernel", i32 1}
+; CHECK: [[META8:![0-9]+]] = !{void ()* @neg_empty_7, !"kernel", i32 1}
 ; CHECK: [[META9:![0-9]+]] = !{void ()* @pos_constant_loads, !"kernel", i32 1}
 ; CHECK: [[META10:![0-9]+]] = !{void ()* @neg_loads, !"kernel", i32 1}
 ; CHECK: [[META11:![0-9]+]] = !{void ()* @pos_priv_mem, !"kernel", i32 1}


        


More information about the llvm-branch-commits mailing list