Skip to content

Commit be20ee6

Browse files
committed
[ArgPromotion] Add test for volatile and atomic loads (NFC)
Argument promotion does handle these correctly (by not promoting them), but there were no tests to ensure this.
1 parent c099ca4 commit be20ee6

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2+
; RUN: opt -S -argpromotion < %s | FileCheck %s
3+
4+
; Make sure volatile and atomic loads are not promoted.
5+
6+
define internal i32 @callee_volatile(i32* %p) {
7+
; CHECK-LABEL: @callee_volatile(
8+
; CHECK-NEXT: [[V:%.*]] = load volatile i32, i32* [[P:%.*]], align 4
9+
; CHECK-NEXT: ret i32 [[V]]
10+
;
11+
%v = load volatile i32, i32* %p
12+
ret i32 %v
13+
}
14+
15+
define void @caller_volatile(i32* %p) {
16+
; CHECK-LABEL: @caller_volatile(
17+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @callee_volatile(i32* [[P:%.*]])
18+
; CHECK-NEXT: ret void
19+
;
20+
call i32 @callee_volatile(i32* %p)
21+
ret void
22+
}
23+
24+
define internal i32 @callee_atomic(i32* %p) {
25+
; CHECK-LABEL: @callee_atomic(
26+
; CHECK-NEXT: [[V:%.*]] = load atomic i32, i32* [[P:%.*]] seq_cst, align 4
27+
; CHECK-NEXT: ret i32 [[V]]
28+
;
29+
%v = load atomic i32, i32* %p seq_cst, align 4
30+
ret i32 %v
31+
}
32+
33+
define void @caller_atomic(i32* %p) {
34+
; CHECK-LABEL: @caller_atomic(
35+
; CHECK-NEXT: [[TMP1:%.*]] = call i32 @callee_atomic(i32* [[P:%.*]])
36+
; CHECK-NEXT: ret void
37+
;
38+
call i32 @callee_atomic(i32* %p)
39+
ret void
40+
}

0 commit comments

Comments
 (0)