// Regression: generated basic-block labels used to be named b1, b2, ... and // `_entry`, which share one namespace with values in LLVM IR. A parameter // named b1 therefore collided with block b1 and clang rejected the module // with "'%b1' is not a basic block" at `br label %b1`. The labels are now // dotted (bb.1, bb.entry) so no source identifier can reach them. package main import "fmt" // A parameter named exactly like the old block labels, in a function with // branches (which is what needs the generated blocks). func pick(b1 byte, b2 byte) (r int32) { if b1 > b2 { r = int32(b1) - int32(b2) } else if b1 == b2 { r = 0 } else { r = int32(b2) - int32(b1) } for i := byte(0); i < b1; i++ { r = r + int32(i) } return } // The entry label as a parameter name. func entry(_entry int32) (r int32) { switch _entry { case 0: r = 10 case 1: r = 20 default: r = 30 } return } func main() { if got := pick(3, 1); got != 2+0+1+2 { panic("pick(3,1)") } if got := pick(1, 4); got != 3 { panic("pick(1,4)") } if got := pick(2, 2); got != 1 { panic("pick(2,2)") } if entry(0)+entry(1)+entry(2) != 60 { panic("entry") } fmt.Println("ok") }