// Constant float assignment must survive in both compilers. // // The legacy interp read a constant float through LLVMConstRealGetDouble. // That C function returns double in XMM0, but the purego binding read the // return register RAX, so every constant float assignment came out 0 while // integers (returned in RAX) survived. stage4 never used the binding, so the // two compilers disagreed. The shapes below are the exact ones that were // measured: single and multi-value, both widths, and a negative value. // // The values used to sit in package-level initializers; that form is now // illegal in user code (zero value plus assignment in init(), and a main // package cannot declare init()), so the assignments live at the top of main // and the same constant-float codegen is exercised. package main var a1 float64 var b1, b2 float64 var e1 float32 var c1 int32 var d1, d2 int32 // A main package cannot declare init(), and a global may not be assigned in // main(), so the assignments live in an init-named helper called first - // exactly when the old package initializer ran. func initGlobals() { a1 = 1.5 b1, b2 = 2.5, -3.5 e1 = 7.5 c1 = 4 d1, d2 = 5, 6 } func main() { initGlobals() if a1 != 1.5 { panic("float64 single initializer") } if b1 != 2.5 || b2 != -3.5 { panic("float64 pair initializer") } if e1 != 7.5 { panic("float32 single initializer") } if c1 != 4 || d1 != 5 || d2 != 6 { panic("int initializer") } println("ok") }