github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/interface.ll (about) 1 ; ModuleID = 'interface.go' 2 source_filename = "interface.go" 3 target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20" 4 target triple = "wasm32-unknown-wasi" 5 6 %runtime._interface = type { ptr, ptr } 7 %runtime._string = type { ptr, i32 } 8 9 @"reflect/types.type:basic:int" = linkonce_odr constant { i8, ptr } { i8 -62, ptr @"reflect/types.type:pointer:basic:int" }, align 4 10 @"reflect/types.type:pointer:basic:int" = linkonce_odr constant { i8, i16, ptr } { i8 -43, i16 0, ptr @"reflect/types.type:basic:int" }, align 4 11 @"reflect/types.type:pointer:named:error" = linkonce_odr constant { i8, i16, ptr } { i8 -43, i16 0, ptr @"reflect/types.type:named:error" }, align 4 12 @"reflect/types.type:named:error" = linkonce_odr constant { i8, i16, ptr, ptr, ptr, [7 x i8] } { i8 116, i16 0, ptr @"reflect/types.type:pointer:named:error", ptr @"reflect/types.type:interface:{Error:func:{}{basic:string}}", ptr @"reflect/types.type.pkgpath.empty", [7 x i8] c".error\00" }, align 4 13 @"reflect/types.type.pkgpath.empty" = linkonce_odr unnamed_addr constant [1 x i8] zeroinitializer, align 1 14 @"reflect/types.type:interface:{Error:func:{}{basic:string}}" = linkonce_odr constant { i8, ptr } { i8 84, ptr @"reflect/types.type:pointer:interface:{Error:func:{}{basic:string}}" }, align 4 15 @"reflect/types.type:pointer:interface:{Error:func:{}{basic:string}}" = linkonce_odr constant { i8, i16, ptr } { i8 -43, i16 0, ptr @"reflect/types.type:interface:{Error:func:{}{basic:string}}" }, align 4 16 @"reflect/types.type:pointer:interface:{String:func:{}{basic:string}}" = linkonce_odr constant { i8, i16, ptr } { i8 -43, i16 0, ptr @"reflect/types.type:interface:{String:func:{}{basic:string}}" }, align 4 17 @"reflect/types.type:interface:{String:func:{}{basic:string}}" = linkonce_odr constant { i8, ptr } { i8 84, ptr @"reflect/types.type:pointer:interface:{String:func:{}{basic:string}}" }, align 4 18 @"reflect/types.typeid:basic:int" = external constant i8 19 20 ; Function Attrs: allockind("alloc,zeroed") allocsize(0) 21 declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0 22 23 declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1 24 25 ; Function Attrs: nounwind 26 define hidden void @main.init(ptr %context) unnamed_addr #2 { 27 entry: 28 ret void 29 } 30 31 ; Function Attrs: nounwind 32 define hidden %runtime._interface @main.simpleType(ptr %context) unnamed_addr #2 { 33 entry: 34 %stackalloc = alloca i8, align 1 35 call void @runtime.trackPointer(ptr nonnull @"reflect/types.type:basic:int", ptr nonnull %stackalloc, ptr undef) #7 36 call void @runtime.trackPointer(ptr null, ptr nonnull %stackalloc, ptr undef) #7 37 ret %runtime._interface { ptr @"reflect/types.type:basic:int", ptr null } 38 } 39 40 ; Function Attrs: nounwind 41 define hidden %runtime._interface @main.pointerType(ptr %context) unnamed_addr #2 { 42 entry: 43 %stackalloc = alloca i8, align 1 44 call void @runtime.trackPointer(ptr nonnull @"reflect/types.type:pointer:basic:int", ptr nonnull %stackalloc, ptr undef) #7 45 call void @runtime.trackPointer(ptr null, ptr nonnull %stackalloc, ptr undef) #7 46 ret %runtime._interface { ptr @"reflect/types.type:pointer:basic:int", ptr null } 47 } 48 49 ; Function Attrs: nounwind 50 define hidden %runtime._interface @main.interfaceType(ptr %context) unnamed_addr #2 { 51 entry: 52 %stackalloc = alloca i8, align 1 53 call void @runtime.trackPointer(ptr nonnull @"reflect/types.type:pointer:named:error", ptr nonnull %stackalloc, ptr undef) #7 54 call void @runtime.trackPointer(ptr null, ptr nonnull %stackalloc, ptr undef) #7 55 ret %runtime._interface { ptr @"reflect/types.type:pointer:named:error", ptr null } 56 } 57 58 ; Function Attrs: nounwind 59 define hidden %runtime._interface @main.anonymousInterfaceType(ptr %context) unnamed_addr #2 { 60 entry: 61 %stackalloc = alloca i8, align 1 62 call void @runtime.trackPointer(ptr nonnull @"reflect/types.type:pointer:interface:{String:func:{}{basic:string}}", ptr nonnull %stackalloc, ptr undef) #7 63 call void @runtime.trackPointer(ptr null, ptr nonnull %stackalloc, ptr undef) #7 64 ret %runtime._interface { ptr @"reflect/types.type:pointer:interface:{String:func:{}{basic:string}}", ptr null } 65 } 66 67 ; Function Attrs: nounwind 68 define hidden i1 @main.isInt(ptr %itf.typecode, ptr %itf.value, ptr %context) unnamed_addr #2 { 69 entry: 70 %typecode = call i1 @runtime.typeAssert(ptr %itf.typecode, ptr nonnull @"reflect/types.typeid:basic:int", ptr undef) #7 71 br i1 %typecode, label %typeassert.ok, label %typeassert.next 72 73 typeassert.next: ; preds = %typeassert.ok, %entry 74 ret i1 %typecode 75 76 typeassert.ok: ; preds = %entry 77 br label %typeassert.next 78 } 79 80 declare i1 @runtime.typeAssert(ptr, ptr dereferenceable_or_null(1), ptr) #1 81 82 ; Function Attrs: nounwind 83 define hidden i1 @main.isError(ptr %itf.typecode, ptr %itf.value, ptr %context) unnamed_addr #2 { 84 entry: 85 %0 = call i1 @"interface:{Error:func:{}{basic:string}}.$typeassert"(ptr %itf.typecode) #7 86 br i1 %0, label %typeassert.ok, label %typeassert.next 87 88 typeassert.next: ; preds = %typeassert.ok, %entry 89 ret i1 %0 90 91 typeassert.ok: ; preds = %entry 92 br label %typeassert.next 93 } 94 95 declare i1 @"interface:{Error:func:{}{basic:string}}.$typeassert"(ptr) #3 96 97 ; Function Attrs: nounwind 98 define hidden i1 @main.isStringer(ptr %itf.typecode, ptr %itf.value, ptr %context) unnamed_addr #2 { 99 entry: 100 %0 = call i1 @"interface:{String:func:{}{basic:string}}.$typeassert"(ptr %itf.typecode) #7 101 br i1 %0, label %typeassert.ok, label %typeassert.next 102 103 typeassert.next: ; preds = %typeassert.ok, %entry 104 ret i1 %0 105 106 typeassert.ok: ; preds = %entry 107 br label %typeassert.next 108 } 109 110 declare i1 @"interface:{String:func:{}{basic:string}}.$typeassert"(ptr) #4 111 112 ; Function Attrs: nounwind 113 define hidden i8 @main.callFooMethod(ptr %itf.typecode, ptr %itf.value, ptr %context) unnamed_addr #2 { 114 entry: 115 %0 = call i8 @"interface:{String:func:{}{basic:string},main.foo:func:{basic:int}{basic:uint8}}.foo$invoke"(ptr %itf.value, i32 3, ptr %itf.typecode, ptr undef) #7 116 ret i8 %0 117 } 118 119 declare i8 @"interface:{String:func:{}{basic:string},main.foo:func:{basic:int}{basic:uint8}}.foo$invoke"(ptr, i32, ptr, ptr) #5 120 121 ; Function Attrs: nounwind 122 define hidden %runtime._string @main.callErrorMethod(ptr %itf.typecode, ptr %itf.value, ptr %context) unnamed_addr #2 { 123 entry: 124 %stackalloc = alloca i8, align 1 125 %0 = call %runtime._string @"interface:{Error:func:{}{basic:string}}.Error$invoke"(ptr %itf.value, ptr %itf.typecode, ptr undef) #7 126 %1 = extractvalue %runtime._string %0, 0 127 call void @runtime.trackPointer(ptr %1, ptr nonnull %stackalloc, ptr undef) #7 128 ret %runtime._string %0 129 } 130 131 declare %runtime._string @"interface:{Error:func:{}{basic:string}}.Error$invoke"(ptr, ptr, ptr) #6 132 133 attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 134 attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 135 attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" } 136 attributes #3 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-methods"="reflect/methods.Error() string" } 137 attributes #4 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-methods"="reflect/methods.String() string" } 138 attributes #5 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-invoke"="main.$methods.foo(int) uint8" "tinygo-methods"="reflect/methods.String() string; main.$methods.foo(int) uint8" } 139 attributes #6 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" "tinygo-invoke"="reflect/methods.Error() string" "tinygo-methods"="reflect/methods.Error() string" } 140 attributes #7 = { nounwind }