reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    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
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
; RUN: not llvm-as < %s -o /dev/null 2>&1 | FileCheck %s

declare void @llvm.test.immarg.intrinsic.i32(i32 immarg)
declare void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> immarg)
declare void @llvm.test.immarg.intrinsic.f32(float immarg)
declare void @llvm.test.immarg.intrinsic.v2f32(<2 x float> immarg)
declare void @llvm.test.immarg.intrinsic.2ai32([2 x i32] immarg)

@gv = global i32 undef, align 4

define void @call_llvm.test.immarg.intrinsic.i32(i32 %arg) {
; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: i32 undef
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.i32(i32 undef)
  call void @llvm.test.immarg.intrinsic.i32(i32 undef)

; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: i32 %arg
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.i32(i32 %arg)
  call void @llvm.test.immarg.intrinsic.i32(i32 %arg)

  ; CHECK: immarg operand has non-immediate parameter
  ; CHECK-NEXT: i32 ptrtoint (i32* @gv to i32)
  ; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.i32(i32 ptrtoint (i32* @gv to i32))
  call void @llvm.test.immarg.intrinsic.i32(i32 ptrtoint (i32* @gv to i32))
  ret void
}

define void @call_llvm.test.immarg.intrinsic.f32() {
; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: float undef
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.f32(float undef)
  call void @llvm.test.immarg.intrinsic.f32(float undef)
  ret void
}

define void @call_llvm.test.immarg.intrinsic.v2i32() {
; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: <2 x i32> zeroinitializer
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> zeroinitializer)
  call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> zeroinitializer)

; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: <2 x i32> <i32 1, i32 2>
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> <i32 1, i32 2>)
  call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> <i32 1, i32 2>)

; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: <2 x i32> undef
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> undef)
  call void @llvm.test.immarg.intrinsic.v2i32(<2 x i32> undef)
  ret void
}

define void @call_llvm.test.immarg.intrinsic.v2f32() {
; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: <2 x float> zeroinitializer
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> zeroinitializer)
  call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> zeroinitializer)

; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: <2 x float> <float 1.000000e+00, float 2.000000e+00>
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> <float 1.000000e+00, float 2.000000e+00>)
  call void @llvm.test.immarg.intrinsic.v2f32(<2 x float> <float 1.0, float 2.0>)
  ret void
}

define void @call_llvm.test.immarg.intrinsic.2ai32() {
; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: [2 x i32] zeroinitializer
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] zeroinitializer)
  call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] zeroinitializer)

; CHECK: immarg operand has non-immediate parameter
; CHECK-NEXT: [2 x i32] [i32 1, i32 2]
; CHECK-NEXT: call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] [i32 1, i32 2])
  call void @llvm.test.immarg.intrinsic.2ai32([2 x i32] [i32 1, i32 2])
  ret void
}

; CHECK: immarg attribute only applies to intrinsics
; CHECK-NEXT: void (i32)* @not_an_intrinsic
declare void @not_an_intrinsic(i32 immarg)

declare void @llvm.test.intrinsic(i32)
declare void @func(i32)

define void @only_on_callsite() {
; CHECK: immarg attribute only applies to intrinsics
; CHECK-NEXT: call void @func(i32 immarg 0)
; CHECK-NEXT: immarg may not apply only to call sites
; CHECK-NEXT: i32 0
; CHECK-NEXT: call void @func(i32 immarg 0)
  call void @func(i32 immarg 0)

; CHECK: immarg may not apply only to call sites
; CHECK-NEXT: i32 0
; CHECK-NEXT: call void @llvm.test.intrinsic(i32 immarg 0)
  call void @llvm.test.intrinsic(i32 immarg 0)
  ret void
}

; CHECK: immarg attribute only applies to intrinsics
; CHECK: void (i32)* @on_function_definition
define void @on_function_definition(i32 immarg %arg) {
  ret void
}