[llvm] 8b08287 - [OpenMPOpt] Eliminate assumptions only "late"
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 23 16:12:27 PDT 2023
Author: Johannes Doerfert
Date: 2023-08-23T16:11:43-07:00
New Revision: 8b08287cb37e09c2001ad4db434c895b0795ae32
URL: https://github.com/llvm/llvm-project/commit/8b08287cb37e09c2001ad4db434c895b0795ae32
DIFF: https://github.com/llvm/llvm-project/commit/8b08287cb37e09c2001ad4db434c895b0795ae32.diff
LOG: [OpenMPOpt] Eliminate assumptions only "late"
When we remove barriers, we might need to remove llvm.assume
assumptions as well. However, doing this early, thus in the module pass,
will cause us to miss out on information we might need. There are few
situations we can eliminate barriers across functions, for now we simply
disable elimination of barriers that require assumptions to be removed
during the early module pass.
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 c19ce9000f9768..8c68470a184721 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -2672,6 +2672,8 @@ struct AAExecutionDomainFunction : public AAExecutionDomain {
if (!ED.IsReachedFromAlignedBarrierOnly ||
ED.EncounteredNonLocalSideEffect)
return;
+ if (!ED.EncounteredAssumes.empty() && !A.isModulePass())
+ return;
// We can remove this barrier, if it is one, or all aligned barriers
// reaching the kernel end. In the latter case we can transitively work
diff --git a/llvm/test/Transforms/OpenMP/barrier_removal.ll b/llvm/test/Transforms/OpenMP/barrier_removal.ll
index cb95b2c2876a11..e45f746cbf4395 100644
--- a/llvm/test/Transforms/OpenMP/barrier_removal.ll
+++ b/llvm/test/Transforms/OpenMP/barrier_removal.ll
@@ -26,19 +26,26 @@ declare void @llvm.assume(i1)
; CHECK: @[[G1:[a-zA-Z0-9_$"\\.-]+]] = global i32 42
; CHECK: @[[G2:[a-zA-Z0-9_$"\\.-]+]] = addrspace(1) global i32 0
;.
-define void @pos_empty_1() "kernel" {
-; CHECK-LABEL: define {{[^@]+}}@pos_empty_1
-; CHECK-SAME: () #[[ATTR4:[0-9]+]] {
-; CHECK-NEXT: ret void
+define void @pos_empty_1(i1 %c) "kernel" {
+; MODULE-LABEL: define {{[^@]+}}@pos_empty_1
+; MODULE-SAME: (i1 [[C:%.*]]) #[[ATTR4:[0-9]+]] {
+; MODULE-NEXT: ret void
;
- call void @llvm.assume(i1 true)
+; CGSCC-LABEL: define {{[^@]+}}@pos_empty_1
+; CGSCC-SAME: (i1 [[C:%.*]]) #[[ATTR4:[0-9]+]] {
+; CGSCC-NEXT: call void @llvm.assume(i1 [[C]])
+; CGSCC-NEXT: call void @unknown() #[[ATTR0:[0-9]+]]
+; CGSCC-NEXT: call void @llvm.assume(i1 [[C]])
+; CGSCC-NEXT: ret void
+;
+ call void @llvm.assume(i1 %c)
call void @unknown() "llvm.assume"="ompx_aligned_barrier"
- call void @llvm.assume(i1 true)
+ call void @llvm.assume(i1 %c)
ret void
}
define void @pos_empty_2() "kernel" {
; CHECK-LABEL: define {{[^@]+}}@pos_empty_2
-; CHECK-SAME: () #[[ATTR4]] {
+; CHECK-SAME: () #[[ATTR4:[0-9]+]] {
; CHECK-NEXT: ret void
;
call void @aligned_barrier()
More information about the llvm-commits
mailing list