Generate compact unwind encoding from CFI directives.
[oota-llvm.git] / test / CodeGen / X86 / no-compact-unwind.ll
1 ; RUN: llc < %s -mtriple x86_64-apple-macosx10.8.0 -filetype=obj -o - \
2 ; RUN:  | llvm-objdump -triple x86_64-apple-macosx10.8.0 -s - \
3 ; RUN:  | FileCheck %s
4
5 %"struct.dyld::MappedRanges" = type { [400 x %struct.anon], %"struct.dyld::MappedRanges"* }
6 %struct.anon = type { %class.ImageLoader*, i64, i64 }
7 %class.ImageLoader = type { i32 (...)**, i8*, i8*, i32, i64, i64, i32, i32, %"struct.ImageLoader::recursive_lock"*, i16, i16, [4 x i8] }
8 %"struct.ImageLoader::recursive_lock" = type { i32, i32 }
9
10 @G1 = external hidden global %"struct.dyld::MappedRanges", align 8
11
12 declare void @OSMemoryBarrier() optsize
13
14 ; This compact unwind encoding indicates that we could not generate correct
15 ; compact unwind encodings for this function. This then defaults to using the
16 ; DWARF EH frame.
17 ;
18 ; CHECK:      Contents of section __compact_unwind:
19 ; CHECK-NEXT: 0048 00000000 00000000 42000000 00000004
20 ; CHECK-NEXT: 0058 00000000 00000000 00000000 00000000
21 ;
22
23 define void @func(%class.ImageLoader* %image) optsize ssp uwtable {
24 entry:
25   br label %for.cond1.preheader
26
27 for.cond1.preheader:                              ; preds = %for.inc10, %entry
28   %p.019 = phi %"struct.dyld::MappedRanges"* [ @G1, %entry ], [ %1, %for.inc10 ]
29   br label %for.body3
30
31 for.body3:                                        ; preds = %for.inc, %for.cond1.preheader
32   %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.inc ]
33   %image4 = getelementptr inbounds %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 0, i64 %indvars.iv, i32 0
34   %0 = load %class.ImageLoader** %image4, align 8
35   %cmp5 = icmp eq %class.ImageLoader* %0, %image
36   br i1 %cmp5, label %if.then, label %for.inc
37
38 if.then:                                          ; preds = %for.body3
39   tail call void @OSMemoryBarrier() optsize
40   store %class.ImageLoader* null, %class.ImageLoader** %image4, align 8
41   br label %for.inc
42
43 for.inc:                                          ; preds = %if.then, %for.body3
44   %indvars.iv.next = add i64 %indvars.iv, 1
45   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
46   %exitcond = icmp eq i32 %lftr.wideiv, 400
47   br i1 %exitcond, label %for.inc10, label %for.body3
48
49 for.inc10:                                        ; preds = %for.inc
50   %next = getelementptr inbounds %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 1
51   %1 = load %"struct.dyld::MappedRanges"** %next, align 8
52   %cmp = icmp eq %"struct.dyld::MappedRanges"* %1, null
53   br i1 %cmp, label %for.end11, label %for.cond1.preheader
54
55 for.end11:                                        ; preds = %for.inc10
56   ret void
57 }