github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/interp/testdata/phi.ll (about) 1 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 2 target triple = "x86_64--linux" 3 4 @main.phiNodesResultA = global i8 0 5 @main.phiNodesResultB = global i8 0 6 7 define void @runtime.initAll() { 8 call void @main.init() 9 ret void 10 } 11 12 ; PHI nodes always use the value from the previous block, even in a loop. This 13 ; means that the loop below should swap the values %a and %b on each iteration. 14 ; Previously there was a bug which resulted in %b getting the value 3 on the 15 ; second iteration while it should have gotten 1 (from the first iteration of 16 ; %for.loop). 17 define internal void @main.init() { 18 entry: 19 br label %for.loop 20 21 for.loop: 22 %a = phi i8 [ 1, %entry ], [ %b, %for.loop ] 23 %b = phi i8 [ 3, %entry ], [ %a, %for.loop ] 24 %icmp = icmp eq i8 %a, 3 25 br i1 %icmp, label %for.done, label %for.loop 26 27 for.done: 28 store i8 %a, ptr @main.phiNodesResultA 29 store i8 %b, ptr @main.phiNodesResultB 30 ret void 31 }