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 4 5source_filename = "/test/Bindings/echo.ll" 6target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 7target triple = "x86_64-apple-macosx10.11.0" 8 9module asm "classical GAS" 10 11%S = type { i64, %S* } 12 13@var = global i32 42 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 24@nullptr = global i32* null 25 26@aliased1 = alias i32, i32* @var 27@aliased2 = internal alias i32, i32* @var 28@aliased3 = external alias i32, i32* @var 29@aliased4 = weak alias i32, i32* @var 30@aliased5 = weak_odr alias i32, i32* @var 31 32@ifunc = ifunc i32 (i32), i64 ()* @ifunc_resolver 33 34define i64 @ifunc_resolver() { 35entry: 36 ret i64 0 37} 38 39define { i64, %S* } @unpackrepack(%S %s) { 40 %1 = extractvalue %S %s, 0 41 %2 = extractvalue %S %s, 1 42 %3 = insertvalue { i64, %S* } undef, %S* %2, 1 43 %4 = insertvalue { i64, %S* } %3, i64 %1, 0 44 ret { i64, %S* } %4 45} 46 47declare void @decl() 48 49; TODO: label and metadata types 50define void @types() { 51 %1 = alloca half, align 2 52 %2 = alloca float, align 4 53 %3 = alloca double, align 8 54 %4 = alloca x86_fp80, align 16 55 %5 = alloca fp128, align 16 56 %6 = alloca ppc_fp128, align 16 57 %7 = alloca i7, align 1 58 %8 = alloca void (i1)*, align 8 59 %9 = alloca [3 x i22], align 4 60 %10 = alloca i328 addrspace(5)*, align 8 61 %11 = alloca <5 x i23*>, align 64 62 %12 = alloca x86_mmx, align 8 63 ret void 64} 65 66define i32 @iops(i32 %a, i32 %b) { 67 %1 = add i32 %a, %b 68 %2 = mul i32 %a, %1 69 %3 = sub i32 %2, %1 70 %4 = udiv i32 %3, %b 71 %5 = sdiv i32 %2, %4 72 %6 = urem i32 %3, %5 73 %7 = srem i32 %2, %6 74 %8 = shl i32 %1, %b 75 %9 = lshr i32 %a, %7 76 %10 = ashr i32 %b, %8 77 %11 = and i32 %9, %10 78 %12 = or i32 %2, %11 79 %13 = xor i32 %12, %4 80 ret i32 %13 81} 82 83define i32 @call() { 84 %1 = call i32 @iops(i32 23, i32 19) 85 ret i32 %1 86} 87 88define i32 @cond(i32 %a, i32 %b) { 89 br label %br 90unreachable: 91 unreachable 92br: 93 %1 = icmp eq i32 %a, %b 94 br i1 %1, label %next0, label %unreachable 95next0: 96 %2 = icmp ne i32 %a, %b 97 br i1 %2, label %next1, label %unreachable 98next1: 99 %3 = icmp ugt i32 %a, %b 100 br i1 %3, label %next2, label %unreachable 101next2: 102 %4 = icmp uge i32 %a, %b 103 br i1 %4, label %next3, label %unreachable 104next3: 105 %5 = icmp ult i32 %a, %b 106 br i1 %5, label %next4, label %unreachable 107next4: 108 %6 = icmp ule i32 %a, %b 109 br i1 %6, label %next5, label %unreachable 110next5: 111 %7 = icmp sgt i32 %a, %b 112 br i1 %7, label %next6, label %unreachable 113next6: 114 %8 = icmp sge i32 %a, %b 115 br i1 %8, label %next7, label %unreachable 116next7: 117 %9 = icmp slt i32 %a, %b 118 br i1 %9, label %next8, label %unreachable 119next8: 120 %10 = icmp sle i32 %a, %b 121 br i1 %10, label %next9, label %unreachable 122next9: 123 ret i32 0 124} 125 126define i32 @loop(i32 %i) { 127 br label %cond 128cond: 129 %c = phi i32 [ %i, %0 ], [ %j, %do ] 130 %p = phi i32 [ %r, %do ], [ 789, %0 ] 131 %1 = icmp eq i32 %c, 0 132 br i1 %1, label %do, label %done 133do: 134 %2 = sub i32 %p, 23 135 %j = sub i32 %i, 1 136 %r = mul i32 %2, 3 137 br label %cond 138done: 139 ret i32 %p 140} 141 142define void @memops(i8* %ptr) { 143 %a = load i8, i8* %ptr 144 %b = load volatile i8, i8* %ptr 145 %c = load i8, i8* %ptr, align 8 146 %d = load atomic i8, i8* %ptr acquire, align 32 147 store i8 0, i8* %ptr 148 store volatile i8 0, i8* %ptr 149 store i8 0, i8* %ptr, align 8 150 store atomic i8 0, i8* %ptr release, align 32 151 %e = atomicrmw add i8* %ptr, i8 0 monotonic 152 %f = atomicrmw volatile xchg i8* %ptr, i8 0 acq_rel 153 %g = cmpxchg i8* %ptr, i8 1, i8 2 seq_cst acquire 154 %h = cmpxchg weak i8* %ptr, i8 1, i8 2 seq_cst acquire 155 %i = cmpxchg volatile i8* %ptr, i8 1, i8 2 monotonic monotonic 156 ret void 157} 158 159define i32 @vectorops(i32, i32) { 160 %a = insertelement <4 x i32> undef, i32 %0, i32 0 161 %b = insertelement <4 x i32> %a, i32 %1, i32 2 162 %c = shufflevector <4 x i32> %b, <4 x i32> undef, <4 x i32> zeroinitializer 163 %d = shufflevector <4 x i32> %c, <4 x i32> %b, <4 x i32> <i32 1, i32 2, i32 3, i32 0> 164 %e = add <4 x i32> %d, %a 165 %f = mul <4 x i32> %e, %b 166 %g = xor <4 x i32> %f, %d 167 %h = or <4 x i32> %f, %e 168 %i = lshr <4 x i32> %h, <i32 2, i32 2, i32 2, i32 2> 169 %j = shl <4 x i32> %i, <i32 2, i32 3, i32 4, i32 5> 170 %k = shufflevector <4 x i32> %j, <4 x i32> %i, <4 x i32> <i32 2, i32 3, i32 undef, i32 undef> 171 %m = shufflevector <4 x i32> %k, <4 x i32> undef, <1 x i32> <i32 1> 172 %n = shufflevector <4 x i32> %j, <4 x i32> undef, <8 x i32> <i32 0, i32 0, i32 1, i32 2, i32 undef, i32 3, i32 undef, i32 undef> 173 %p = extractelement <8 x i32> %n, i32 5 174 ret i32 %p 175} 176 177define i32 @scalablevectorops(i32, <vscale x 4 x i32>) { 178 %a = insertelement <vscale x 4 x i32> undef, i32 %0, i32 0 179 %b = insertelement <vscale x 4 x i32> %a, i32 %0, i32 2 180 %c = shufflevector <vscale x 4 x i32> %b, <vscale x 4 x i32> undef, <vscale x 4 x i32> zeroinitializer 181 %e = add <vscale x 4 x i32> %a, %1 182 %f = mul <vscale x 4 x i32> %e, %b 183 %g = xor <vscale x 4 x i32> %f, %e 184 %h = or <vscale x 4 x i32> %g, %e 185 %i = lshr <vscale x 4 x i32> %h, undef 186 %j = extractelement <vscale x 4 x i32> %i, i32 3 187 ret i32 %j 188} 189 190declare void @personalityFn() 191 192define void @exn() personality void ()* @personalityFn { 193entry: 194 invoke void @decl() 195 to label %via.cleanup unwind label %exn.dispatch 196via.cleanup: 197 invoke void @decl() 198 to label %via.catchswitch unwind label %cleanup.inner 199cleanup.inner: 200 %cp.inner = cleanuppad within none [] 201 cleanupret from %cp.inner unwind label %exn.dispatch 202via.catchswitch: 203 invoke void @decl() 204 to label %exit unwind label %dispatch.inner 205dispatch.inner: 206 %cs.inner = catchswitch within none [label %pad.inner] unwind label %exn.dispatch 207pad.inner: 208 %catch.inner = catchpad within %cs.inner [i32 0] 209 catchret from %catch.inner to label %exit 210exn.dispatch: 211 %cs = catchswitch within none [label %pad1, label %pad2] unwind label %cleanup 212pad1: 213 catchpad within %cs [i32 1] 214 unreachable 215pad2: 216 catchpad within %cs [i32 2] 217 unreachable 218cleanup: 219 %cp = cleanuppad within none [] 220 cleanupret from %cp unwind to caller 221exit: 222 ret void 223} 224 225define void @with_debuginfo() !dbg !4 { 226 ret void, !dbg !7 227} 228 229declare i8* @llvm.stacksave() 230declare void @llvm.stackrestore(i8*) 231declare void @llvm.lifetime.start.p0i8(i64, i8*) 232declare void @llvm.lifetime.end.p0i8(i64, i8*) 233 234define void @test_intrinsics() { 235entry: 236 %sp = call i8* @llvm.stacksave() 237 %x = alloca i32, align 4 238 %0 = bitcast i32* %x to i8* 239 call void @llvm.lifetime.start.p0i8(i64 4, i8* %0) 240 call void @llvm.lifetime.end.p0i8(i64 4, i8* %0) 241 call void @llvm.stackrestore(i8* %sp) 242 ret void 243} 244 245!llvm.dbg.cu = !{!0, !2} 246!llvm.module.flags = !{!3} 247 248!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 249!1 = !DIFile(filename: "echo.ll", directory: "/llvm/test/Bindings/llvm-c/echo.ll") 250!2 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug) 251!3 = !{i32 2, !"Debug Info Version", i32 3} 252!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) 253!5 = !DISubroutineType(types: !6) 254!6 = !{} 255!7 = !DILocation(line: 42, scope: !8, inlinedAt: !11) 256!8 = distinct !DILexicalBlock(scope: !9, file: !1, line: 42, column: 12) 257!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) 258!10 = distinct !DILocation(line: 84, scope: !8, inlinedAt: !11) 259!11 = !DILocation(line: 42, scope: !4) 260