1; RUN: llc < %s | FileCheck %s
2target triple = "armv6kz-unknown-unknown-gnueabihf"
3
4; Make sure this doesn't crash, and we actually emit a tail call.
5; Unfortunately, this test is sort of fragile... the original issue only
6; shows up if scheduling happens in a very specific order. But including
7; it anyway just to demonstrate the issue.
8; CHECK: pop {r4, lr}
9
10@e = external local_unnamed_addr constant [0 x i32 (i32, i32)*], align 4
11
12; Function Attrs: nounwind sspstrong
13define i32 @AVI_ChunkRead_p_chk(i32 %g) nounwind sspstrong "target-cpu"="arm1176jzf-s" {
14entry:
15  %b = alloca i8, align 1
16  %tobool = icmp eq i32 %g, 0
17  br i1 %tobool, label %if.end, label %if.then
18
19if.then:                                          ; preds = %entry
20  %add = add nsw i32 %g, 1
21  %arrayidx = getelementptr inbounds [0 x i32 (i32, i32)*], [0 x i32 (i32, i32)*]* @e, i32 0, i32 %add
22  %0 = load i32 (i32, i32)*, i32 (i32, i32)** %arrayidx, align 4
23  %call = tail call i32 %0(i32 0, i32 0) #3
24  br label %return
25
26if.end:                                           ; preds = %entry
27  call void @c(i8* nonnull %b)
28  br label %return
29
30return:                                           ; preds = %if.end, %if.then
31  %retval.0 = phi i32 [ %call, %if.then ], [ 0, %if.end ]
32  ret i32 %retval.0
33}
34
35declare void @c(i8*)
36