Skip to content

[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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions llvm/lib/Transforms/Scalar/SROA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 35 additions & 0 deletions llvm/test/Transforms/SROA/invariant-group.ll
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,41 @@ define void @partial_promotion_of_alloca() {
ret void
}

define void @launder_in_loop() {
; CHECK-LABEL: @launder_in_loop(
; CHECK-NEXT: br label [[HEADER:%.*]]
; CHECK: header:
; CHECK-NEXT: br i1 true, label [[BODY:%.*]], label [[EXIT:%.*]]
; CHECK: body:
; CHECK-NEXT: [[STRUCT:%.*]] = call [[T:%.*]] @[[MAKE_T:[a-zA-Z0-9_$\"\\.-]*[a-zA-Z_$\"\\.-][a-zA-Z0-9_$\"\\.-]*]]()
; CHECK-NEXT: [[STRUCT_FCA_0_EXTRACT:%.*]] = extractvalue [[T]] [[STRUCT]], 0
; CHECK-NEXT: [[STRUCT_FCA_1_EXTRACT:%.*]] = extractvalue [[T]] [[STRUCT]], 1
; CHECK-NEXT: br label [[HEADER]]
; CHECK: exit:
; CHECK-NEXT: ret void
;
%struct_ptr = alloca %t, i64 1, align 4
br label %header

header:
br i1 true, label %body, label %exit

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

exit:
ret void
}

declare %t @make_t()

declare void @use(ptr)

!0 = !{}
Expand Down