Created
October 12, 2015 10:33
-
-
Save matt2909/7c1c5880621f9c6d8775 to your computer and use it in GitHub Desktop.
This file generates a test that breaks the ARM64 compiler with "branch too far" errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"io" | |
"os" | |
) | |
func dumpTable(w io.Writer, tableSize int) { | |
fmt.Fprintln(w, "type funcPointer func() string") | |
fmt.Fprintln(w, "var (") | |
fmt.Fprintln(w, "funcTable = map[int]funcPointer{\n") | |
for i := 0; i < tableSize; i++ { | |
fmt.Fprintf(w, "%d: func_%d,\n", i, i) | |
} | |
fmt.Fprintln(w, "}\n") | |
fmt.Fprintln(w, ")\n") | |
} | |
func dumpFunctions(w io.Writer, tableSize int) { | |
for i := 0; i < tableSize; i++ { | |
fmt.Fprintln(w, "") | |
fmt.Fprintf(w, "func func_%d() string {\n", i) | |
fmt.Fprintf(w, "return \"func %d\"\n", i) | |
fmt.Fprintf(w, "}\n") | |
fmt.Fprintln(w, "") | |
} | |
} | |
func dumpHeader (w io.Writer) { | |
fmt.Fprintln(w, "package main") | |
fmt.Fprintln(w, "import \"fmt\"") | |
} | |
func dumpMain (w io.Writer, tableSize int) { | |
fmt.Fprintln(w, "func main() {") | |
fmt.Fprintf(w, "for i := 0; i < %d; i++ {\n", tableSize) | |
fmt.Fprintf(w, "fmt.Println(funcTable[i]())\n") | |
fmt.Fprintln(w, "}") | |
fmt.Fprintln(w, "}") | |
} | |
func main() { | |
dumpHeader(os.Stdout) | |
dumpTable(os.Stdout, 20000) | |
dumpFunctions(os.Stdout, 20000) | |
dumpMain(os.Stdout, 20000) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment