43 lines · plain
1; RUN: opt -passes=function-attrs -S < %s | FileCheck %s2 3; This checks for a previously existing iterator wraparound bug in4; FunctionAttrs, and in the process covers corner cases with varargs.5 6declare void @llvm.va_start(ptr)7declare void @llvm.va_end(ptr)8 9define void @va_func(ptr readonly %b, ...) readonly nounwind willreturn {10; CHECK-LABEL: define void @va_func(ptr readonly captures(none) %b, ...)11 entry:12 %valist = alloca i813 call void @llvm.va_start(ptr %valist)14 call void @llvm.va_end(ptr %valist)15 %x = call i32 @caller(ptr %b)16 ret void17}18 19define i32 @caller(ptr %x) {20; CHECK-LABEL: define noundef i32 @caller(ptr readonly captures(address) %x)21 entry:22 call void(ptr,...) @va_func(ptr null, i32 0, i32 0, i32 0, ptr %x)23 ret i32 4224}25 26define void @va_func2(ptr readonly %b, ...) {27; CHECK-LABEL: define void @va_func2(ptr readonly captures(address) %b, ...)28 entry:29 %valist = alloca i830 call void @llvm.va_start(ptr %valist)31 call void @llvm.va_end(ptr %valist)32 %x = call i32 @caller(ptr %b)33 ret void34}35 36define i32 @caller2(ptr %x, ptr %y) {37; CHECK-LABEL: define noundef i32 @caller2(ptr readonly captures(address) %x, ptr %y)38 entry:39 call void(ptr,...) @va_func2(ptr %x, i32 0, i32 0, i32 0, ptr %y)40 ret i32 4241}42 43