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

     1  ; ModuleID = 'channel.go'
     2  source_filename = "channel.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.channelBlockedList = type { ptr, ptr, ptr, { ptr, i32, i32 } }
     7  %runtime.chanSelectState = type { ptr, ptr }
     8  
     9  ; Function Attrs: allockind("alloc,zeroed") allocsize(0)
    10  declare noalias nonnull ptr @runtime.alloc(i32, ptr, ptr) #0
    11  
    12  declare void @runtime.trackPointer(ptr nocapture readonly, ptr, ptr) #1
    13  
    14  ; Function Attrs: nounwind
    15  define hidden void @main.init(ptr %context) unnamed_addr #2 {
    16  entry:
    17    ret void
    18  }
    19  
    20  ; Function Attrs: nounwind
    21  define hidden void @main.chanIntSend(ptr dereferenceable_or_null(32) %ch, ptr %context) unnamed_addr #2 {
    22  entry:
    23    %chan.blockedList = alloca %runtime.channelBlockedList, align 8
    24    %chan.value = alloca i32, align 4
    25    call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %chan.value)
    26    store i32 3, ptr %chan.value, align 4
    27    call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %chan.blockedList)
    28    call void @runtime.chanSend(ptr %ch, ptr nonnull %chan.value, ptr nonnull %chan.blockedList, ptr undef) #4
    29    call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %chan.blockedList)
    30    call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %chan.value)
    31    ret void
    32  }
    33  
    34  ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
    35  declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #3
    36  
    37  declare void @runtime.chanSend(ptr dereferenceable_or_null(32), ptr, ptr dereferenceable_or_null(24), ptr) #1
    38  
    39  ; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
    40  declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #3
    41  
    42  ; Function Attrs: nounwind
    43  define hidden void @main.chanIntRecv(ptr dereferenceable_or_null(32) %ch, ptr %context) unnamed_addr #2 {
    44  entry:
    45    %chan.blockedList = alloca %runtime.channelBlockedList, align 8
    46    %chan.value = alloca i32, align 4
    47    call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %chan.value)
    48    call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %chan.blockedList)
    49    %0 = call i1 @runtime.chanRecv(ptr %ch, ptr nonnull %chan.value, ptr nonnull %chan.blockedList, ptr undef) #4
    50    call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %chan.value)
    51    call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %chan.blockedList)
    52    ret void
    53  }
    54  
    55  declare i1 @runtime.chanRecv(ptr dereferenceable_or_null(32), ptr, ptr dereferenceable_or_null(24), ptr) #1
    56  
    57  ; Function Attrs: nounwind
    58  define hidden void @main.chanZeroSend(ptr dereferenceable_or_null(32) %ch, ptr %context) unnamed_addr #2 {
    59  entry:
    60    %chan.blockedList = alloca %runtime.channelBlockedList, align 8
    61    call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %chan.blockedList)
    62    call void @runtime.chanSend(ptr %ch, ptr null, ptr nonnull %chan.blockedList, ptr undef) #4
    63    call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %chan.blockedList)
    64    ret void
    65  }
    66  
    67  ; Function Attrs: nounwind
    68  define hidden void @main.chanZeroRecv(ptr dereferenceable_or_null(32) %ch, ptr %context) unnamed_addr #2 {
    69  entry:
    70    %chan.blockedList = alloca %runtime.channelBlockedList, align 8
    71    call void @llvm.lifetime.start.p0(i64 24, ptr nonnull %chan.blockedList)
    72    %0 = call i1 @runtime.chanRecv(ptr %ch, ptr null, ptr nonnull %chan.blockedList, ptr undef) #4
    73    call void @llvm.lifetime.end.p0(i64 24, ptr nonnull %chan.blockedList)
    74    ret void
    75  }
    76  
    77  ; Function Attrs: nounwind
    78  define hidden void @main.selectZeroRecv(ptr dereferenceable_or_null(32) %ch1, ptr dereferenceable_or_null(32) %ch2, ptr %context) unnamed_addr #2 {
    79  entry:
    80    %select.states.alloca = alloca [2 x %runtime.chanSelectState], align 8
    81    %select.send.value = alloca i32, align 4
    82    store i32 1, ptr %select.send.value, align 4
    83    call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %select.states.alloca)
    84    store ptr %ch1, ptr %select.states.alloca, align 8
    85    %select.states.alloca.repack1 = getelementptr inbounds %runtime.chanSelectState, ptr %select.states.alloca, i32 0, i32 1
    86    store ptr %select.send.value, ptr %select.states.alloca.repack1, align 4
    87    %0 = getelementptr inbounds [2 x %runtime.chanSelectState], ptr %select.states.alloca, i32 0, i32 1
    88    store ptr %ch2, ptr %0, align 8
    89    %.repack3 = getelementptr inbounds [2 x %runtime.chanSelectState], ptr %select.states.alloca, i32 0, i32 1, i32 1
    90    store ptr null, ptr %.repack3, align 4
    91    %select.result = call { i32, i1 } @runtime.tryChanSelect(ptr undef, ptr nonnull %select.states.alloca, i32 2, i32 2, ptr undef) #4
    92    call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %select.states.alloca)
    93    %1 = extractvalue { i32, i1 } %select.result, 0
    94    %2 = icmp eq i32 %1, 0
    95    br i1 %2, label %select.done, label %select.next
    96  
    97  select.done:                                      ; preds = %select.body, %select.next, %entry
    98    ret void
    99  
   100  select.next:                                      ; preds = %entry
   101    %3 = icmp eq i32 %1, 1
   102    br i1 %3, label %select.body, label %select.done
   103  
   104  select.body:                                      ; preds = %select.next
   105    br label %select.done
   106  }
   107  
   108  declare { i32, i1 } @runtime.tryChanSelect(ptr, ptr, i32, i32, ptr) #1
   109  
   110  attributes #0 = { allockind("alloc,zeroed") allocsize(0) "alloc-family"="runtime.alloc" "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   111  attributes #1 = { "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   112  attributes #2 = { nounwind "target-features"="+bulk-memory,+mutable-globals,+nontrapping-fptoint,+sign-ext" }
   113  attributes #3 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
   114  attributes #4 = { nounwind }