Skip to content

Commit 25e79b1

Browse files
[GVN] Introduce test for PR125258 (NFC)
1 parent d7784a6 commit 25e79b1

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
2+
; RUN: opt -passes=gvn -S < %s | FileCheck %s
3+
4+
; FIXME: This is a miscompilation.
5+
define noundef i32 @test_malloc_clobbering_errno() {
6+
; CHECK-LABEL: define noundef i32 @test_malloc_clobbering_errno() {
7+
; CHECK-NEXT: [[TMP1:%.*]] = alloca ptr, align 8
8+
; CHECK-NEXT: [[TMP2:%.*]] = call ptr @__errno_location()
9+
; CHECK-NEXT: store i32 0, ptr [[TMP2]], align 4
10+
; CHECK-NEXT: [[TMP3:%.*]] = call noalias ptr @malloc(i64 1844674407370955161)
11+
; CHECK-NEXT: store volatile ptr [[TMP3]], ptr [[TMP1]], align 8
12+
; CHECK-NEXT: ret i32 0
13+
;
14+
%1 = alloca ptr, align 8
15+
%2 = call ptr @__errno_location()
16+
store i32 0, ptr %2, align 4
17+
%3 = call noalias ptr @malloc(i64 1844674407370955161)
18+
store volatile ptr %3, ptr %1, align 8
19+
%4 = load i32, ptr %2, align 4
20+
ret i32 %4
21+
}
22+
23+
declare ptr @__errno_location() #1
24+
declare noalias ptr @malloc(i64) #2
25+
26+
attributes #1 = { mustprogress nofree nosync nounwind willreturn memory(none) }
27+
attributes #2 = { mustprogress nofree nounwind willreturn memory(inaccessiblemem: readwrite) }

0 commit comments

Comments
 (0)