Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 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
38 changes: 38 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,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 = !{}
Expand Down
Loading