Skip to content

Commit 1a5f906

Browse files
committed
[PhaseOrdering] Add test for #95152 (NFC)
This depends on multiple passes agreeing on the semantics of writeonly, so add a PhaseOrdering test for it.
1 parent 638d968 commit 1a5f906

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -S -passes='default<O3>' < %s | FileCheck %s
3+
4+
; Make sure that interaction of "writable" with various passes does not
5+
; result in the elimination of the store prior to @j().
6+
; FIXME: This is a miscompile.
7+
8+
declare void @use(i64)
9+
10+
define void @j(ptr %p) optnone noinline {
11+
; CHECK-LABEL: define void @j(
12+
; CHECK-SAME: ptr [[P:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
13+
; CHECK-NEXT: [[I:%.*]] = load i64, ptr [[P]], align 4
14+
; CHECK-NEXT: call void @use(i64 [[I]])
15+
; CHECK-NEXT: ret void
16+
;
17+
%i = load i64, ptr %p
18+
call void @use(i64 %i)
19+
ret void
20+
}
21+
22+
define void @h(ptr %p) {
23+
; CHECK-LABEL: define void @h(
24+
; CHECK-SAME: ptr [[P:%.*]]) local_unnamed_addr {
25+
; CHECK-NEXT: store i64 3, ptr [[P]], align 4
26+
; CHECK-NEXT: tail call void @j(ptr nonnull [[P]])
27+
; CHECK-NEXT: ret void
28+
;
29+
store i64 3, ptr %p
30+
call void @j(ptr %p)
31+
ret void
32+
}
33+
34+
define void @g(ptr dead_on_unwind noalias writable dereferenceable(8) align 8 %p) minsize {
35+
; CHECK-LABEL: define void @g(
36+
; CHECK-SAME: ptr dead_on_unwind noalias nocapture writable writeonly align 8 dereferenceable(8) [[P:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {
37+
; CHECK-NEXT: tail call void @h(ptr nonnull [[P]])
38+
; CHECK-NEXT: ret void
39+
;
40+
%a = alloca i64
41+
call void @h(ptr %a)
42+
call void @llvm.memcpy(ptr align 8 %p, ptr align 8 %a, i64 8, i1 false)
43+
ret void
44+
}
45+
46+
define void @f(ptr dead_on_unwind noalias %p) {
47+
; CHECK-LABEL: define void @f(
48+
; CHECK-SAME: ptr dead_on_unwind noalias [[P:%.*]]) local_unnamed_addr {
49+
; CHECK-NEXT: tail call void @j(ptr nonnull writeonly [[P]])
50+
; CHECK-NEXT: store i64 43, ptr [[P]], align 4
51+
; CHECK-NEXT: ret void
52+
;
53+
call void @g(ptr %p)
54+
store i64 43, ptr %p
55+
ret void
56+
}

0 commit comments

Comments
 (0)