1 ; RUN: llvm-as < %s | llvm-dis > %t.orig
2 ; RUN: llvm-as < %s | llvm-c-test --echo > %t.echo
3 ; RUN: diff -w %t.orig %t.echo
5 source_filename = "/test/Bindings/echo.ll"
6 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
7 target triple = "x86_64-apple-macosx10.11.0"
9 module asm "classical GAS"
11 %S = type { i64, %S* }
14 @ext = external global i32*
15 @cst = constant %S { i64 1, %S* @cst }
16 @tl = thread_local global { i64, %S* } { i64 1, %S* @cst }
17 @arr = linkonce_odr global [5 x i8] [ i8 2, i8 3, i8 5, i8 7, i8 11 ]
18 @str = private unnamed_addr constant [13 x i8] c"hello world\0A\00"
19 @locStr = private local_unnamed_addr constant [13 x i8] c"hello world\0A\00"
20 @hidden = hidden global i32 7
21 @protected = protected global i32 23
22 @section = global i32 27, section ".custom"
23 @align = global i32 31, align 4
25 @aliased1 = alias i32, i32* @var
26 @aliased2 = internal alias i32, i32* @var
27 @aliased3 = external alias i32, i32* @var
28 @aliased4 = weak alias i32, i32* @var
29 @aliased5 = weak_odr alias i32, i32* @var
31 @ifunc = ifunc i32 (i32), i64 ()* @ifunc_resolver
33 define i64 @ifunc_resolver() {
38 define { i64, %S* } @unpackrepack(%S %s) {
39 %1 = extractvalue %S %s, 0
40 %2 = extractvalue %S %s, 1
41 %3 = insertvalue { i64, %S* } undef, %S* %2, 1
42 %4 = insertvalue { i64, %S* } %3, i64 %1, 0
48 ; TODO: label and metadata types
49 define void @types() {
57 %8 = alloca void (i1)*
59 %10 = alloca i328 addrspace(5)*
60 %11 = alloca <5 x i23*>
65 define i32 @iops(i32 %a, i32 %b) {
83 %1 = call i32 @iops(i32 23, i32 19)
87 define i32 @cond(i32 %a, i32 %b) {
92 %1 = icmp eq i32 %a, %b
93 br i1 %1, label %next0, label %unreachable
95 %2 = icmp ne i32 %a, %b
96 br i1 %2, label %next1, label %unreachable
98 %3 = icmp ugt i32 %a, %b
99 br i1 %3, label %next2, label %unreachable
101 %4 = icmp uge i32 %a, %b
102 br i1 %4, label %next3, label %unreachable
104 %5 = icmp ult i32 %a, %b
105 br i1 %5, label %next4, label %unreachable
107 %6 = icmp ule i32 %a, %b
108 br i1 %6, label %next5, label %unreachable
110 %7 = icmp sgt i32 %a, %b
111 br i1 %7, label %next6, label %unreachable
113 %8 = icmp sge i32 %a, %b
114 br i1 %8, label %next7, label %unreachable
116 %9 = icmp slt i32 %a, %b
117 br i1 %9, label %next8, label %unreachable
119 %10 = icmp sle i32 %a, %b
120 br i1 %10, label %next9, label %unreachable
125 define i32 @loop(i32 %i) {
128 %c = phi i32 [ %i, %0 ], [ %j, %do ]
129 %p = phi i32 [ %r, %do ], [ 789, %0 ]
130 %1 = icmp eq i32 %c, 0
131 br i1 %1, label %do, label %done
141 declare void @personalityFn()
143 define void @exn() personality void ()* @personalityFn {
146 to label %via.cleanup unwind label %exn.dispatch
149 to label %via.catchswitch unwind label %cleanup.inner
151 %cp.inner = cleanuppad within none []
152 cleanupret from %cp.inner unwind label %exn.dispatch
155 to label %exit unwind label %dispatch.inner
157 %cs.inner = catchswitch within none [label %pad.inner] unwind label %exn.dispatch
159 %catch.inner = catchpad within %cs.inner [i32 0]
160 catchret from %catch.inner to label %exit
162 %cs = catchswitch within none [label %pad1, label %pad2] unwind label %cleanup
164 catchpad within %cs [i32 1]
167 catchpad within %cs [i32 2]
170 %cp = cleanuppad within none []
171 cleanupret from %cp unwind to caller
176 define void @with_debuginfo() !dbg !4 {
180 declare i8* @llvm.stacksave()
181 declare void @llvm.stackrestore(i8*)
182 declare void @llvm.lifetime.start.p0i8(i64, i8*)
183 declare void @llvm.lifetime.end.p0i8(i64, i8*)
185 define void @test_intrinsics() {
187 %sp = call i8* @llvm.stacksave()
189 %0 = bitcast i32* %x to i8*
190 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0)
191 call void @llvm.lifetime.end.p0i8(i64 4, i8* %0)
192 call void @llvm.stackrestore(i8* %sp)
196 !llvm.dbg.cu = !{!0, !2}
197 !llvm.module.flags = !{!3}
199 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
200 !1 = !DIFile(filename: "echo.ll", directory: "/llvm/test/Bindings/llvm-c/echo.ll")
201 !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
202 !3 = !{i32 2, !"Debug Info Version", i32 3}
203 !4 = distinct !DISubprogram(name: "with_debuginfo", linkageName: "_with_debuginfo", scope: null, file: !1, line: 42, type: !5, isLocal: false, isDefinition: true, scopeLine: 1519, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !6, retainedNodes: !6)
204 !5 = !DISubroutineType(types: !6)
206 !7 = !DILocation(line: 42, scope: !8, inlinedAt: !11)
207 !8 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42, column: 12)
208 !9 = distinct !DISubprogram(name: "fake_inlined_block", linkageName: "_fake_inlined_block", scope: null, file: !1, line: 82, type: !5, isLocal: false, isDefinition: true, scopeLine: 82, flags: DIFlagPrototyped, isOptimized: true, unit: !2, templateParams: !6, retainedNodes: !6)
209 !10 = distinct !DILocation(line: 84, scope: !8, inlinedAt: !11)
210 !11 = !DILocation(line: 42, scope: !4)