forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathout-of-bounds-iterator-bug.ll
43 lines (36 loc) · 1.24 KB
/
out-of-bounds-iterator-bug.ll
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
; RUN: opt -function-attrs -S < %s | FileCheck %s
; RUN: opt -passes=function-attrs -S < %s | FileCheck %s
; This checks for a previously existing iterator wraparound bug in
; FunctionAttrs, and in the process covers corner cases with varargs.
declare void @llvm.va_start(i8*)
declare void @llvm.va_end(i8*)
define void @va_func(i32* readonly %b, ...) readonly nounwind {
; CHECK-LABEL: define void @va_func(i32* nocapture readonly %b, ...)
entry:
%valist = alloca i8
call void @llvm.va_start(i8* %valist)
call void @llvm.va_end(i8* %valist)
%x = call i32 @caller(i32* %b)
ret void
}
define i32 @caller(i32* %x) {
; CHECK-LABEL: define i32 @caller(i32* nocapture readonly %x)
entry:
call void(i32*,...) @va_func(i32* null, i32 0, i32 0, i32 0, i32* %x)
ret i32 42
}
define void @va_func2(i32* readonly %b, ...) {
; CHECK-LABEL: define void @va_func2(i32* nocapture readonly %b, ...)
entry:
%valist = alloca i8
call void @llvm.va_start(i8* %valist)
call void @llvm.va_end(i8* %valist)
%x = call i32 @caller(i32* %b)
ret void
}
define i32 @caller2(i32* %x, i32* %y) {
; CHECK-LABEL: define i32 @caller2(i32* nocapture readonly %x, i32* %y)
entry:
call void(i32*,...) @va_func2(i32* %x, i32 0, i32 0, i32 0, i32* %y)
ret i32 42
}