Add a testcase to make sure we generate the proper compact unwind section for a funct...
[oota-llvm.git] / test / CodeGen / X86 / no-compact-unwind.ll
1 ; RUN: llc < %s -mtriple x86_64-apple-macosx10.8.0 -disable-cfi | FileCheck %s
2
3 %"struct.dyld::MappedRanges" = type { [400 x %struct.anon], %"struct.dyld::MappedRanges"* }
4 %struct.anon = type { %class.ImageLoader*, i64, i64 }
5 %class.ImageLoader = type { i32 (...)**, i8*, i8*, i32, i64, i64, i32, i32, %"struct.ImageLoader::recursive_lock"*, i16, i16, [4 x i8] }
6 %"struct.ImageLoader::recursive_lock" = type { i32, i32 }
7
8 @_ZN4dyldL18sMappedRangesStartE = external hidden global %"struct.dyld::MappedRanges", align 8
9
10 declare void @OSMemoryBarrier() optsize
11
12 ; This compact unwind encoding indicates that we could not generate correct
13 ; compact unwind encodings for this function. This then defaults to using the
14 ; DWARF EH frame.
15 ;
16 ; CHECK: .section __LD,__compact_unwind,regular,debug
17 ; CHECK: .quad __ZN4dyld19removedMappedRangesEP11ImageLoader
18 ; CHECK: .long 67108864                ## Compact Unwind Encoding: 0x4000000
19 ; CHECK: .quad 0                       ## Personality Function
20 ; CHECK: .quad 0                       ## LSDA
21 ;
22 define void @_ZN4dyld19removedMappedRangesEP11ImageLoader(%class.ImageLoader* %image) optsize ssp uwtable {
23 entry:
24   br label %for.cond1.preheader
25
26 for.cond1.preheader:                              ; preds = %for.inc10, %entry
27   %p.019 = phi %"struct.dyld::MappedRanges"* [ @_ZN4dyldL18sMappedRangesStartE, %entry ], [ %1, %for.inc10 ]
28   br label %for.body3
29
30 for.body3:                                        ; preds = %for.inc, %for.cond1.preheader
31   %indvars.iv = phi i64 [ 0, %for.cond1.preheader ], [ %indvars.iv.next, %for.inc ]
32   %image4 = getelementptr inbounds %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 0, i64 %indvars.iv, i32 0
33   %0 = load %class.ImageLoader** %image4, align 8, !tbaa !0
34   %cmp5 = icmp eq %class.ImageLoader* %0, %image
35   br i1 %cmp5, label %if.then, label %for.inc
36
37 if.then:                                          ; preds = %for.body3
38   tail call void @OSMemoryBarrier() optsize
39   store %class.ImageLoader* null, %class.ImageLoader** %image4, align 8, !tbaa !0
40   br label %for.inc
41
42 for.inc:                                          ; preds = %if.then, %for.body3
43   %indvars.iv.next = add i64 %indvars.iv, 1
44   %lftr.wideiv = trunc i64 %indvars.iv.next to i32
45   %exitcond = icmp eq i32 %lftr.wideiv, 400
46   br i1 %exitcond, label %for.inc10, label %for.body3
47
48 for.inc10:                                        ; preds = %for.inc
49   %next = getelementptr inbounds %"struct.dyld::MappedRanges"* %p.019, i64 0, i32 1
50   %1 = load %"struct.dyld::MappedRanges"** %next, align 8, !tbaa !0
51   %cmp = icmp eq %"struct.dyld::MappedRanges"* %1, null
52   br i1 %cmp, label %for.end11, label %for.cond1.preheader
53
54 for.end11:                                        ; preds = %for.inc10
55   ret void
56 }
57
58 !0 = metadata !{metadata !"any pointer", metadata !1}
59 !1 = metadata !{metadata !"omnipotent char", metadata !2}
60 !2 = metadata !{metadata !"Simple C/C++ TBAA"}