1; RUN: opt -function-attrs -S < %s | FileCheck %s 2; RUN: opt -passes=function-attrs -S < %s | FileCheck %s 3 4; This checks for an iterator wraparound bug in FunctionAttrs. The previous 5; "incorrect" behavior was inferring readonly for the %x argument in @caller. 6; Inferring readonly for %x *is* actually correct, since @va_func is marked 7; readonly, but FunctionAttrs was inferring readonly for the wrong reasons (and 8; we _need_ the readonly on @va_func to trigger the problematic code path). It 9; is possible that in the future FunctionAttrs becomes smart enough to infer 10; readonly for %x for the right reasons, and at that point this test will have 11; to be marked invalid. 12 13declare void @llvm.va_start(i8*) 14declare void @llvm.va_end(i8*) 15 16define void @va_func(i32* readonly %b, ...) readonly nounwind { 17; CHECK-LABEL: define void @va_func(i32* nocapture readonly %b, ...) 18 entry: 19 %valist = alloca i8 20 call void @llvm.va_start(i8* %valist) 21 call void @llvm.va_end(i8* %valist) 22 %x = call i32 @caller(i32* %b) 23 ret void 24} 25 26define i32 @caller(i32* %x) { 27; CHECK-LABEL: define i32 @caller(i32* nocapture %x) 28 entry: 29 call void(i32*,...) @va_func(i32* null, i32 0, i32 0, i32 0, i32* %x) 30 ret i32 42 31} 32