-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[llvm][sroa] Fixed failing assertion caused by no handling for {launder,strip}.invariant.group
in AggLoadStoreRewriter
#151574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…group intrinsic in `AggLoadStoreRewriter`
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be notified. If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers. If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-llvm-transforms Author: Tommy MᶜMichen (tommymcm) ChangesAdded test for
This is fixed by adding handling to the Full diff: https://github.com/llvm/llvm-project/pull/151574.diff 2 Files Affected:
diff --git a/llvm/lib/Transforms/Scalar/SROA.cpp b/llvm/lib/Transforms/Scalar/SROA.cpp
index 23256cf2acbd2..821b41f0583f3 100644
--- a/llvm/lib/Transforms/Scalar/SROA.cpp
+++ b/llvm/lib/Transforms/Scalar/SROA.cpp
@@ -4261,6 +4261,12 @@ class AggLoadStoreRewriter : public InstVisitor<AggLoadStoreRewriter, bool> {
enqueueUsers(SI);
return false;
}
+
+ bool visitIntrinsicInst(IntrinsicInst &II) {
+ if (II.isLaunderOrStripInvariantGroup())
+ enqueueUsers(II);
+ return false;
+ }
};
} // end anonymous namespace
diff --git a/llvm/test/Transforms/SROA/invariant-group.ll b/llvm/test/Transforms/SROA/invariant-group.ll
index 1be6f6e2fc32b..4eac8fc1b48d6 100644
--- a/llvm/test/Transforms/SROA/invariant-group.ll
+++ b/llvm/test/Transforms/SROA/invariant-group.ll
@@ -155,6 +155,44 @@ define void @partial_promotion_of_alloca() {
ret void
}
+define void @launder_in_loop() {
+; CHECK-LABEL: @launder_in_loop(
+; CHECK-NEXT: br label %[[HEADER:.*]]
+;
+ %struct_ptr = alloca %t, i64 1, align 4
+ br label %header
+
+; CHECK: [[HEADER]]:
+; CHECK-NEXT: br i1 true, label %[[BODY:.*]], label %[[EXIT:.*]]
+;
+header:
+ br i1 true, label %body, label %exit
+
+; CHECK: [[BODY]]:
+; CHECK-NEXT: [[STRUCT:%.*]] = call %t @make_t()
+; CHECK-NEXT: [[FIRST:%.*]] = extractvalue %t [[STRUCT]], 0
+; CHECK-NEXT: [[SECOND:%.*]] = extractvalue %t [[STRUCT]], 1
+; CHECK-NEXT: br label %[[HEADER]]
+;
+body: ; preds = %6
+ %struct_ptr_fresh = call ptr @llvm.launder.invariant.group.p0(ptr %struct_ptr)
+ %struct = call %t @make_t()
+ store %t %struct, ptr %struct_ptr_fresh, align 4, !invariant.group !0
+ %first_ptr = getelementptr %t, ptr %struct_ptr_fresh, i32 0, i32 0
+ %first = load i32, ptr %first_ptr, align 4
+ %second_ptr = getelementptr %t, ptr %struct_ptr_fresh, i32 0, i32 1
+ %second = load i32, ptr %second_ptr, align 4
+ br label %header
+
+; CHECK: [[EXIT]]:
+; CHECK-NEXT: ret void
+;
+exit:
+ ret void
+}
+
+declare %t @make_t()
+
declare void @use(ptr)
!0 = !{}
|
Though TBH I think we should just revert invariant.group support in SROA, it's broken right now. |
That would also work for my purposes. |
Resolves #151574. > SROA pass does not perform aggregate load/store rewriting on a pointer whose source is a `launder.invariant.group`. > > This causes failed assertion in `AllocaSlices`. > > ``` > void (anonymous namespace)::AllocaSlices::SliceBuilder::visitStoreInst(StoreInst &): > Assertion `(!SI.isSimple() || ValOp->getType()->isSingleValueType()) && > "All simple FCA stores should have been pre-split"' failed. > ``` Disables support for `{launder,strip}.invariant.group` intrinsics in SROA. Updates SROA test for `invariant.group` support.
SROA pass does not perform aggregate load/store rewriting on a pointer whose source is a
launder.invariant.group
.This causes failed assertion in
AllocaSlices
.Added test for
launder.invariant.group
intrinsic inside of a loop, which causes a failing assertion on debug build:Fixed by adding handling to the
AggLoadStoreRewriter
for{launder,strip}.invariant.group
intrinsic.