github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/compiler/testdata/generics.ll (about)

     1  ; ModuleID = 'generics.go'
     2  source_filename = "generics.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  %"main.Point[int]" = type { i32, i32 }
     7  %"main.Point[float32]" = type { float, float }
     8  
     9  declare noalias nonnull i8* @runtime.alloc(i32, i8*, i8*) #0
    10  
    11  declare void @runtime.trackPointer(i8* nocapture readonly, i8*) #0
    12  
    13  ; Function Attrs: nounwind
    14  define hidden void @main.init(i8* %context) unnamed_addr #1 {
    15  entry:
    16    ret void
    17  }
    18  
    19  ; Function Attrs: nounwind
    20  define hidden void @main.main(i8* %context) unnamed_addr #1 {
    21  entry:
    22    %bi = alloca %"main.Point[int]", align 8
    23    %ai = alloca %"main.Point[int]", align 8
    24    %bf = alloca %"main.Point[float32]", align 8
    25    %af = alloca %"main.Point[float32]", align 8
    26    %af.repack = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %af, i32 0, i32 0
    27    store float 0.000000e+00, float* %af.repack, align 8
    28    %af.repack1 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %af, i32 0, i32 1
    29    store float 0.000000e+00, float* %af.repack1, align 4
    30    %0 = bitcast %"main.Point[float32]"* %af to i8*
    31    call void @runtime.trackPointer(i8* nonnull %0, i8* undef) #2
    32    %bf.repack = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %bf, i32 0, i32 0
    33    store float 0.000000e+00, float* %bf.repack, align 8
    34    %bf.repack2 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %bf, i32 0, i32 1
    35    store float 0.000000e+00, float* %bf.repack2, align 4
    36    %1 = bitcast %"main.Point[float32]"* %bf to i8*
    37    call void @runtime.trackPointer(i8* nonnull %1, i8* undef) #2
    38    %.elt = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %af, i32 0, i32 0
    39    %.unpack = load float, float* %.elt, align 8
    40    %.elt3 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %af, i32 0, i32 1
    41    %.unpack4 = load float, float* %.elt3, align 4
    42    %.elt5 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %bf, i32 0, i32 0
    43    %.unpack6 = load float, float* %.elt5, align 8
    44    %.elt7 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %bf, i32 0, i32 1
    45    %.unpack8 = load float, float* %.elt7, align 4
    46    %2 = call %"main.Point[float32]" @"main.Add[float32]"(float %.unpack, float %.unpack4, float %.unpack6, float %.unpack8, i8* undef)
    47    %ai.repack = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %ai, i32 0, i32 0
    48    store i32 0, i32* %ai.repack, align 8
    49    %ai.repack9 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %ai, i32 0, i32 1
    50    store i32 0, i32* %ai.repack9, align 4
    51    %3 = bitcast %"main.Point[int]"* %ai to i8*
    52    call void @runtime.trackPointer(i8* nonnull %3, i8* undef) #2
    53    %bi.repack = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %bi, i32 0, i32 0
    54    store i32 0, i32* %bi.repack, align 8
    55    %bi.repack10 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %bi, i32 0, i32 1
    56    store i32 0, i32* %bi.repack10, align 4
    57    %4 = bitcast %"main.Point[int]"* %bi to i8*
    58    call void @runtime.trackPointer(i8* nonnull %4, i8* undef) #2
    59    %.elt11 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %ai, i32 0, i32 0
    60    %.unpack12 = load i32, i32* %.elt11, align 8
    61    %.elt13 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %ai, i32 0, i32 1
    62    %.unpack14 = load i32, i32* %.elt13, align 4
    63    %.elt15 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %bi, i32 0, i32 0
    64    %.unpack16 = load i32, i32* %.elt15, align 8
    65    %.elt17 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %bi, i32 0, i32 1
    66    %.unpack18 = load i32, i32* %.elt17, align 4
    67    %5 = call %"main.Point[int]" @"main.Add[int]"(i32 %.unpack12, i32 %.unpack14, i32 %.unpack16, i32 %.unpack18, i8* undef)
    68    ret void
    69  }
    70  
    71  ; Function Attrs: nounwind
    72  define linkonce_odr hidden %"main.Point[float32]" @"main.Add[float32]"(float %a.X, float %a.Y, float %b.X, float %b.Y, i8* %context) unnamed_addr #1 {
    73  entry:
    74    %complit = alloca %"main.Point[float32]", align 8
    75    %b = alloca %"main.Point[float32]", align 8
    76    %a = alloca %"main.Point[float32]", align 8
    77    %a.repack = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %a, i32 0, i32 0
    78    store float 0.000000e+00, float* %a.repack, align 8
    79    %a.repack9 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %a, i32 0, i32 1
    80    store float 0.000000e+00, float* %a.repack9, align 4
    81    %0 = bitcast %"main.Point[float32]"* %a to i8*
    82    call void @runtime.trackPointer(i8* nonnull %0, i8* undef) #2
    83    %a.repack10 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %a, i32 0, i32 0
    84    store float %a.X, float* %a.repack10, align 8
    85    %a.repack11 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %a, i32 0, i32 1
    86    store float %a.Y, float* %a.repack11, align 4
    87    %b.repack = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %b, i32 0, i32 0
    88    store float 0.000000e+00, float* %b.repack, align 8
    89    %b.repack13 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %b, i32 0, i32 1
    90    store float 0.000000e+00, float* %b.repack13, align 4
    91    %1 = bitcast %"main.Point[float32]"* %b to i8*
    92    call void @runtime.trackPointer(i8* nonnull %1, i8* undef) #2
    93    %b.repack14 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %b, i32 0, i32 0
    94    store float %b.X, float* %b.repack14, align 8
    95    %b.repack15 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %b, i32 0, i32 1
    96    store float %b.Y, float* %b.repack15, align 4
    97    call void @main.checkSize(i32 4, i8* undef) #2
    98    call void @main.checkSize(i32 8, i8* undef) #2
    99    %complit.repack = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %complit, i32 0, i32 0
   100    store float 0.000000e+00, float* %complit.repack, align 8
   101    %complit.repack17 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %complit, i32 0, i32 1
   102    store float 0.000000e+00, float* %complit.repack17, align 4
   103    %2 = bitcast %"main.Point[float32]"* %complit to i8*
   104    call void @runtime.trackPointer(i8* nonnull %2, i8* undef) #2
   105    %3 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %complit, i32 0, i32 0
   106    br i1 false, label %deref.throw, label %deref.next
   107  
   108  deref.next:                                       ; preds = %entry
   109    br i1 false, label %deref.throw1, label %deref.next2
   110  
   111  deref.next2:                                      ; preds = %deref.next
   112    %4 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %b, i32 0, i32 0
   113    %5 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %a, i32 0, i32 0
   114    %6 = load float, float* %5, align 8
   115    %7 = load float, float* %4, align 8
   116    %8 = fadd float %6, %7
   117    br i1 false, label %deref.throw3, label %deref.next4
   118  
   119  deref.next4:                                      ; preds = %deref.next2
   120    br i1 false, label %deref.throw5, label %deref.next6
   121  
   122  deref.next6:                                      ; preds = %deref.next4
   123    %9 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %b, i32 0, i32 1
   124    %10 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %a, i32 0, i32 1
   125    %11 = load float, float* %10, align 4
   126    %12 = load float, float* %9, align 4
   127    br i1 false, label %store.throw, label %store.next
   128  
   129  store.next:                                       ; preds = %deref.next6
   130    store float %8, float* %3, align 8
   131    br i1 false, label %store.throw7, label %store.next8
   132  
   133  store.next8:                                      ; preds = %store.next
   134    %13 = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %complit, i32 0, i32 1
   135    %14 = fadd float %11, %12
   136    store float %14, float* %13, align 4
   137    %.elt = getelementptr inbounds %"main.Point[float32]", %"main.Point[float32]"* %complit, i32 0, i32 0
   138    %.unpack = load float, float* %.elt, align 8
   139    %15 = insertvalue %"main.Point[float32]" undef, float %.unpack, 0
   140    %16 = insertvalue %"main.Point[float32]" %15, float %14, 1
   141    ret %"main.Point[float32]" %16
   142  
   143  deref.throw:                                      ; preds = %entry
   144    unreachable
   145  
   146  deref.throw1:                                     ; preds = %deref.next
   147    unreachable
   148  
   149  deref.throw3:                                     ; preds = %deref.next2
   150    unreachable
   151  
   152  deref.throw5:                                     ; preds = %deref.next4
   153    unreachable
   154  
   155  store.throw:                                      ; preds = %deref.next6
   156    unreachable
   157  
   158  store.throw7:                                     ; preds = %store.next
   159    unreachable
   160  }
   161  
   162  declare void @main.checkSize(i32, i8*) #0
   163  
   164  declare void @runtime.nilPanic(i8*) #0
   165  
   166  ; Function Attrs: nounwind
   167  define linkonce_odr hidden %"main.Point[int]" @"main.Add[int]"(i32 %a.X, i32 %a.Y, i32 %b.X, i32 %b.Y, i8* %context) unnamed_addr #1 {
   168  entry:
   169    %complit = alloca %"main.Point[int]", align 8
   170    %b = alloca %"main.Point[int]", align 8
   171    %a = alloca %"main.Point[int]", align 8
   172    %a.repack = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %a, i32 0, i32 0
   173    store i32 0, i32* %a.repack, align 8
   174    %a.repack9 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %a, i32 0, i32 1
   175    store i32 0, i32* %a.repack9, align 4
   176    %0 = bitcast %"main.Point[int]"* %a to i8*
   177    call void @runtime.trackPointer(i8* nonnull %0, i8* undef) #2
   178    %a.repack10 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %a, i32 0, i32 0
   179    store i32 %a.X, i32* %a.repack10, align 8
   180    %a.repack11 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %a, i32 0, i32 1
   181    store i32 %a.Y, i32* %a.repack11, align 4
   182    %b.repack = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %b, i32 0, i32 0
   183    store i32 0, i32* %b.repack, align 8
   184    %b.repack13 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %b, i32 0, i32 1
   185    store i32 0, i32* %b.repack13, align 4
   186    %1 = bitcast %"main.Point[int]"* %b to i8*
   187    call void @runtime.trackPointer(i8* nonnull %1, i8* undef) #2
   188    %b.repack14 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %b, i32 0, i32 0
   189    store i32 %b.X, i32* %b.repack14, align 8
   190    %b.repack15 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %b, i32 0, i32 1
   191    store i32 %b.Y, i32* %b.repack15, align 4
   192    call void @main.checkSize(i32 4, i8* undef) #2
   193    call void @main.checkSize(i32 8, i8* undef) #2
   194    %complit.repack = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %complit, i32 0, i32 0
   195    store i32 0, i32* %complit.repack, align 8
   196    %complit.repack17 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %complit, i32 0, i32 1
   197    store i32 0, i32* %complit.repack17, align 4
   198    %2 = bitcast %"main.Point[int]"* %complit to i8*
   199    call void @runtime.trackPointer(i8* nonnull %2, i8* undef) #2
   200    %3 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %complit, i32 0, i32 0
   201    br i1 false, label %deref.throw, label %deref.next
   202  
   203  deref.next:                                       ; preds = %entry
   204    br i1 false, label %deref.throw1, label %deref.next2
   205  
   206  deref.next2:                                      ; preds = %deref.next
   207    %4 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %b, i32 0, i32 0
   208    %5 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %a, i32 0, i32 0
   209    %6 = load i32, i32* %5, align 8
   210    %7 = load i32, i32* %4, align 8
   211    %8 = add i32 %6, %7
   212    br i1 false, label %deref.throw3, label %deref.next4
   213  
   214  deref.next4:                                      ; preds = %deref.next2
   215    br i1 false, label %deref.throw5, label %deref.next6
   216  
   217  deref.next6:                                      ; preds = %deref.next4
   218    %9 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %b, i32 0, i32 1
   219    %10 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %a, i32 0, i32 1
   220    %11 = load i32, i32* %10, align 4
   221    %12 = load i32, i32* %9, align 4
   222    br i1 false, label %store.throw, label %store.next
   223  
   224  store.next:                                       ; preds = %deref.next6
   225    store i32 %8, i32* %3, align 8
   226    br i1 false, label %store.throw7, label %store.next8
   227  
   228  store.next8:                                      ; preds = %store.next
   229    %13 = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %complit, i32 0, i32 1
   230    %14 = add i32 %11, %12
   231    store i32 %14, i32* %13, align 4
   232    %.elt = getelementptr inbounds %"main.Point[int]", %"main.Point[int]"* %complit, i32 0, i32 0
   233    %.unpack = load i32, i32* %.elt, align 8
   234    %15 = insertvalue %"main.Point[int]" undef, i32 %.unpack, 0
   235    %16 = insertvalue %"main.Point[int]" %15, i32 %14, 1
   236    ret %"main.Point[int]" %16
   237  
   238  deref.throw:                                      ; preds = %entry
   239    unreachable
   240  
   241  deref.throw1:                                     ; preds = %deref.next
   242    unreachable
   243  
   244  deref.throw3:                                     ; preds = %deref.next2
   245    unreachable
   246  
   247  deref.throw5:                                     ; preds = %deref.next4
   248    unreachable
   249  
   250  store.throw:                                      ; preds = %deref.next6
   251    unreachable
   252  
   253  store.throw7:                                     ; preds = %store.next
   254    unreachable
   255  }
   256  
   257  attributes #0 = { "target-features"="+bulk-memory,+nontrapping-fptoint,+sign-ext" }
   258  attributes #1 = { nounwind "target-features"="+bulk-memory,+nontrapping-fptoint,+sign-ext" }
   259  attributes #2 = { nounwind }