Fix the predicate which checks for non-sensical formulae which have
[oota-llvm.git] / test / Other / lint.ll
1 ; RUN: opt -lint -disable-output < %s |& FileCheck %s
2 target datalayout = "e-p:64:64:64"
3
4 declare fastcc void @bar()
5
6 @CG = constant i32 7
7
8 define i32 @foo() noreturn {
9 ; CHECK: Caller and callee calling convention differ
10   call void @bar()
11 ; CHECK: Null pointer dereference
12   store i32 0, i32* null
13 ; CHECK: Null pointer dereference
14   %t = load i32* null
15 ; CHECK: Undef pointer dereference
16   store i32 0, i32* undef
17 ; CHECK: Undef pointer dereference
18   %u = load i32* undef
19 ; CHECK: Memory reference address is misaligned
20   %x = inttoptr i32 1 to i32*
21   load i32* %x, align 4
22 ; CHECK: Division by zero
23   %sd = sdiv i32 2, 0
24 ; CHECK: Division by zero
25   %ud = udiv i32 2, 0
26 ; CHECK: Division by zero
27   %sr = srem i32 2, 0
28 ; CHECK: Division by zero
29   %ur = urem i32 2, 0
30 ; CHECK: extractelement index out of range
31   %ee = extractelement <4 x i32> zeroinitializer, i32 4
32 ; CHECK: insertelement index out of range
33   %ie = insertelement <4 x i32> zeroinitializer, i32 0, i32 4
34 ; CHECK: Shift count out of range
35   %r = lshr i32 0, 32
36 ; CHECK: Shift count out of range
37   %q = ashr i32 0, 32
38 ; CHECK: Shift count out of range
39   %l = shl i32 0, 32
40 ; CHECK: xor(undef, undef)
41   %xx = xor i32 undef, undef
42 ; CHECK: sub(undef, undef)
43   %xs = sub i32 undef, undef
44
45 ; CHECK: Write to read-only memory
46   store i32 8, i32* @CG
47 ; CHECK: Write to text section
48   store i32 8, i32* bitcast (i32()* @foo to i32*)
49 ; CHECK: Load from block address
50   %lb = load i32* bitcast (i8* blockaddress(@foo, %next) to i32*)
51 ; CHECK: Call to block address
52   call void()* bitcast (i8* blockaddress(@foo, %next) to void()*)()
53
54   br label %next
55
56 next:
57 ; CHECK: Static alloca outside of entry block
58   %a = alloca i32
59 ; CHECK: Return statement in function with noreturn attribute
60   ret i32 0
61
62 foo:
63   %z = add i32 0, 0
64 ; CHECK: unreachable immediately preceded by instruction without side effects
65   unreachable
66 }
67
68 ; CHECK: Unnamed function with non-local linkage
69 define void @0() nounwind {
70   ret void
71 }
72
73 ; CHECK: va_start called in a non-varargs function
74 declare void @llvm.va_start(i8*)
75 define void @not_vararg(i8* %p) nounwind {
76   call void @llvm.va_start(i8* %p)
77   ret void
78 }
79
80 define void @use_indbr() {
81   indirectbr i8* bitcast (i32()* @foo to i8*), [label %block]
82 block:
83   unreachable
84 }