1; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s 2 3declare void @llvm.test.immarg.intrinsic.i32(i32 immarg) 4declare void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> immarg) 5declare void @llvm.test.immarg.intrinsic.f32(float immarg) 6declare void @llvm.test.immarg.intrinsic.v2f32(<2 x float> immarg) 7declare void @llvm.test.immarg.intrinsic.2ai32([2 x i32] immarg) 8 9@gv = global i32 undef, align 4 10 11define void @call_llvm.test.immarg.intrinsic.i32(i32 %arg) { 12; CHECK: immarg operand has non-immediate parameter 13; CHECK-NEXT: i32 undef 14; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.i32(i32 undef) 15 call void @llvm.test.immarg.intrinsic.i32(i32 undef) 16 17; CHECK: immarg operand has non-immediate parameter 18; CHECK-NEXT: i32 %arg 19; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.i32(i32 %arg) 20 call void @llvm.test.immarg.intrinsic.i32(i32 %arg) 21 22 ; CHECK: immarg operand has non-immediate parameter 23 ; CHECK-NEXT: i32 ptrtoint (i32* @gv to i32) 24 ; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.i32(i32 ptrtoint (i32* @gv to i32)) 25 call void @llvm.test.immarg.intrinsic.i32(i32 ptrtoint (i32* @gv to i32)) 26 ret void 27} 28 29define void @call_llvm.test.immarg.intrinsic.f32() { 30; CHECK: immarg operand has non-immediate parameter 31; CHECK-NEXT: float undef 32; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.f32(float undef) 33 call void @llvm.test.immarg.intrinsic.f32(float undef) 34 ret void 35} 36 37define void @call_llvm.test.immarg.intrinsic.v2i32() { 38; CHECK: immarg operand has non-immediate parameter 39; CHECK-NEXT: <2 x i32> zeroinitializer 40; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> zeroinitializer) 41 call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> zeroinitializer) 42 43; CHECK: immarg operand has non-immediate parameter 44; CHECK-NEXT: <2 x i32> <i32 1, i32 2> 45; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> <i32 1, i32 2>) 46 call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> <i32 1, i32 2>) 47 48; CHECK: immarg operand has non-immediate parameter 49; CHECK-NEXT: <2 x i32> undef 50; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> undef) 51 call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> undef) 52 ret void 53} 54 55define void @call_llvm.test.immarg.intrinsic.v2f32() { 56; CHECK: immarg operand has non-immediate parameter 57; CHECK-NEXT: <2 x float> zeroinitializer 58; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> zeroinitializer) 59 call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> zeroinitializer) 60 61; CHECK: immarg operand has non-immediate parameter 62; CHECK-NEXT: <2 x float> <float 1.000000e+00, float 2.000000e+00> 63; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> <float 1.000000e+00, float 2.000000e+00>) 64 call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> <float 1.0, float 2.0>) 65 ret void 66} 67 68define void @call_llvm.test.immarg.intrinsic.2ai32() { 69; CHECK: immarg operand has non-immediate parameter 70; CHECK-NEXT: [2 x i32] zeroinitializer 71; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] zeroinitializer) 72 call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] zeroinitializer) 73 74; CHECK: immarg operand has non-immediate parameter 75; CHECK-NEXT: [2 x i32] [i32 1, i32 2] 76; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] [i32 1, i32 2]) 77 call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] [i32 1, i32 2]) 78 ret void 79} 80 81; CHECK: immarg attribute only applies to intrinsics 82; CHECK-NEXT: void (i32)* @not_an_intrinsic 83declare void @not_an_intrinsic(i32 immarg) 84 85declare void @llvm.test.intrinsic(i32) 86declare void @func(i32) 87 88define void @only_on_callsite() { 89; CHECK: immarg attribute only applies to intrinsics 90; CHECK-NEXT: call void @func(i32 immarg 0) 91; CHECK-NEXT: immarg may not apply only to call sites 92; CHECK-NEXT: i32 0 93; CHECK-NEXT: call void @func(i32 immarg 0) 94 call void @func(i32 immarg 0) 95 96; CHECK: immarg may not apply only to call sites 97; CHECK-NEXT: i32 0 98; CHECK-NEXT: call void @llvm.test.intrinsic(i32 immarg 0) 99 call void @llvm.test.intrinsic(i32 immarg 0) 100 ret void 101} 102 103; CHECK: immarg attribute only applies to intrinsics 104; CHECK: void (i32)* @on_function_definition 105define void @on_function_definition(i32 immarg %arg) { 106 ret void 107} 108