OXIESEC PANEL
- Current Dir:
/
/
opt
/
golang
/
1.22.0
/
src
/
cmd
/
compile
/
internal
/
ssa
Server IP: 191.96.63.230
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/02/2024 06:09:55 PM
rwxr-xr-x
📄
README.md
8.14 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
TODO
950 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📁
_gen
-
02/02/2024 06:09:55 PM
rwxr-xr-x
📄
addressingmodes.go
24.26 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
allocators.go
7.37 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
bench_test.go
835 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
biasedsparsemap.go
2.67 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
block.go
11.03 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
branchelim.go
12.7 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
branchelim_test.go
5.21 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
cache.go
1.55 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
check.go
17.52 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
checkbce.go
956 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
compile.go
18.66 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
config.go
12.95 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
copyelim.go
1.83 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
copyelim_test.go
1.29 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
critical.go
3.06 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
cse.go
9.63 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
cse_test.go
4.2 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
deadcode.go
9.25 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
deadcode_test.go
3.49 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
deadstore.go
10.42 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
deadstore_test.go
4.09 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
debug.go
56.4 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
debug_lines_test.go
8.44 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
debug_test.go
28.64 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
decompose.go
13.42 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
dom.go
7.35 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
dom_test.go
13.34 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
expand_calls.go
31.88 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
export_test.go
3.04 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
flagalloc.go
6.72 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
flags_amd64_test.s
533 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
flags_arm64_test.s
699 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
flags_test.go
2.47 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
fmahash_test.go
1.82 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
func.go
25.07 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
func_test.go
13.05 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
fuse.go
9.03 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
fuse_branchredirect.go
3.22 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
fuse_comparisons.go
4.04 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
fuse_test.go
7.37 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
generate.go
225 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
html.go
34.85 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
id.go
576 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
layout.go
4.97 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
lca.go
3.77 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
lca_test.go
1.65 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
likelyadjust.go
15.43 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
location.go
3.06 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
loopbce.go
11.81 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
loopreschedchecks.go
15.96 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
looprotate.go
2.68 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
lower.go
1.66 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
magic.go
15.77 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
magic_test.go
9.1 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
memcombine.go
18.44 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
nilcheck.go
11.3 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
nilcheck_test.go
12.33 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
numberlines.go
7.82 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
op.go
18.67 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
opGen.go
1.03 MB
02/02/2024 06:09:55 PM
rw-r--r--
📄
opt.go
309 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
passbm_test.go
3.14 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
phielim.go
1.48 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
phiopt.go
8.08 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
poset.go
37.21 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
poset_test.go
18.14 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
print.go
3.86 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
prove.go
49.44 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
regalloc.go
87.22 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
regalloc_test.go
6.31 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewrite.go
60.26 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewrite386.go
262.37 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewrite386splitload.go
4.04 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteAMD64.go
713.19 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteAMD64latelower.go
2.58 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteAMD64splitload.go
21.4 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteARM.go
486.78 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteARM64.go
623.93 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteARM64latelower.go
6.88 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteCond_test.go
11.12 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteLOONG64.go
195.82 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteMIPS.go
176.61 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteMIPS64.go
211.6 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewritePPC64.go
371.03 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewritePPC64latelower.go
14.78 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteRISCV64.go
203.12 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteRISCV64latelower.go
5.08 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteS390X.go
395.13 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewriteWasm.go
108.58 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewrite_test.go
6.91 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewritedec.go
24.94 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewritedec64.go
65.29 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
rewritegeneric.go
796.35 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sccp.go
17.56 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sccp_test.go
3.57 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
schedule.go
16.42 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
schedule_test.go
5.57 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
shift_test.go
4.05 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
shortcircuit.go
12.63 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
shortcircuit_test.go
1.31 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sizeof_test.go
855 bytes
02/02/2024 06:09:55 PM
rw-r--r--
📄
softfloat.go
1.99 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sparsemap.go
1.9 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sparsemappos.go
1.7 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sparseset.go
1.54 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
sparsetree.go
8.05 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
stackalloc.go
12.56 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
stmtlines_test.go
3.46 KB
02/02/2024 06:09:55 PM
rw-r--r--
📁
testdata
-
02/02/2024 06:09:55 PM
rwxr-xr-x
📄
tighten.go
7.67 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
trim.go
4.25 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
tuple.go
1.97 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
value.go
16.67 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
writebarrier.go
23.5 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
writebarrier_test.go
1.75 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
xposmap.go
3.29 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
zcse.go
2.07 KB
02/02/2024 06:09:55 PM
rw-r--r--
📄
zeroextension_test.go
1.66 KB
02/02/2024 06:09:55 PM
rw-r--r--
Editing: debug_lines_test.go
Close
// Copyright 2021 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. package ssa_test import ( "bufio" "bytes" "flag" "fmt" "internal/testenv" "os" "path/filepath" "reflect" "regexp" "runtime" "sort" "strconv" "strings" "testing" ) // Matches lines in genssa output that are marked "isstmt", and the parenthesized plus-prefixed line number is a submatch var asmLine *regexp.Regexp = regexp.MustCompile(`^\s[vb]\d+\s+\d+\s\(\+(\d+)\)`) // this matches e.g. ` v123456789 000007 (+9876654310) MOVUPS X15, ""..autotmp_2-32(SP)` // Matches lines in genssa output that describe an inlined file. // Note it expects an unadventurous choice of basename. var sepRE = regexp.QuoteMeta(string(filepath.Separator)) var inlineLine *regexp.Regexp = regexp.MustCompile(`^#\s.*` + sepRE + `[-\w]+\.go:(\d+)`) // this matches e.g. # /pa/inline-dumpxxxx.go:6 var testGoArchFlag = flag.String("arch", "", "run test for specified architecture") func testGoArch() string { if *testGoArchFlag == "" { return runtime.GOARCH } return *testGoArchFlag } func hasRegisterABI() bool { switch testGoArch() { case "amd64", "arm64", "loong64", "ppc64", "ppc64le", "riscv": return true } return false } func unixOnly(t *testing.T) { if runtime.GOOS != "linux" && runtime.GOOS != "darwin" { // in particular, it could be windows. t.Skip("this test depends on creating a file with a wonky name, only works for sure on Linux and Darwin") } } // testDebugLinesDefault removes the first wanted statement on architectures that are not (yet) register ABI. func testDebugLinesDefault(t *testing.T, gcflags, file, function string, wantStmts []int, ignoreRepeats bool) { unixOnly(t) if !hasRegisterABI() { wantStmts = wantStmts[1:] } testDebugLines(t, gcflags, file, function, wantStmts, ignoreRepeats) } func TestDebugLinesSayHi(t *testing.T) { // This test is potentially fragile, the goal is that debugging should step properly through "sayhi" // If the blocks are reordered in a way that changes the statement order but execution flows correctly, // then rearrange the expected numbers. Register abi and not-register-abi also have different sequences, // at least for now. testDebugLinesDefault(t, "-N -l", "sayhi.go", "sayhi", []int{8, 9, 10, 11}, false) } func TestDebugLinesPushback(t *testing.T) { unixOnly(t) switch testGoArch() { default: t.Skip("skipped for many architectures") case "arm64", "amd64": // register ABI fn := "(*List[go.shape.int_0]).PushBack" if true /* was buildcfg.Experiment.Unified */ { // Unified mangles differently fn = "(*List[go.shape.int]).PushBack" } testDebugLines(t, "-N -l", "pushback.go", fn, []int{17, 18, 19, 20, 21, 22, 24}, true) } } func TestDebugLinesConvert(t *testing.T) { unixOnly(t) switch testGoArch() { default: t.Skip("skipped for many architectures") case "arm64", "amd64": // register ABI fn := "G[go.shape.int_0]" if true /* was buildcfg.Experiment.Unified */ { // Unified mangles differently fn = "G[go.shape.int]" } testDebugLines(t, "-N -l", "convertline.go", fn, []int{9, 10, 11}, true) } } func TestInlineLines(t *testing.T) { if runtime.GOARCH != "amd64" && *testGoArchFlag == "" { // As of september 2021, works for everything except mips64, but still potentially fragile t.Skip("only runs for amd64 unless -arch explicitly supplied") } want := [][]int{{3}, {4, 10}, {4, 10, 16}, {4, 10}, {4, 11, 16}, {4, 11}, {4}, {5, 10}, {5, 10, 16}, {5, 10}, {5, 11, 16}, {5, 11}, {5}} testInlineStack(t, "inline-dump.go", "f", want) } func TestDebugLines_53456(t *testing.T) { testDebugLinesDefault(t, "-N -l", "b53456.go", "(*T).Inc", []int{15, 16, 17, 18}, true) } func compileAndDump(t *testing.T, file, function, moreGCFlags string) []byte { testenv.MustHaveGoBuild(t) tmpdir, err := os.MkdirTemp("", "debug_lines_test") if err != nil { panic(fmt.Sprintf("Problem creating TempDir, error %v", err)) } if testing.Verbose() { fmt.Printf("Preserving temporary directory %s\n", tmpdir) } else { defer os.RemoveAll(tmpdir) } source, err := filepath.Abs(filepath.Join("testdata", file)) if err != nil { panic(fmt.Sprintf("Could not get abspath of testdata directory and file, %v", err)) } cmd := testenv.Command(t, testenv.GoToolPath(t), "build", "-o", "foo.o", "-gcflags=-d=ssa/genssa/dump="+function+" "+moreGCFlags, source) cmd.Dir = tmpdir cmd.Env = replaceEnv(cmd.Env, "GOSSADIR", tmpdir) testGoos := "linux" // default to linux if testGoArch() == "wasm" { testGoos = "js" } cmd.Env = replaceEnv(cmd.Env, "GOOS", testGoos) cmd.Env = replaceEnv(cmd.Env, "GOARCH", testGoArch()) if testing.Verbose() { fmt.Printf("About to run %s\n", asCommandLine("", cmd)) } var stdout, stderr strings.Builder cmd.Stdout = &stdout cmd.Stderr = &stderr if err := cmd.Run(); err != nil { t.Fatalf("error running cmd %s: %v\nstdout:\n%sstderr:\n%s\n", asCommandLine("", cmd), err, stdout.String(), stderr.String()) } if s := stderr.String(); s != "" { t.Fatalf("Wanted empty stderr, instead got:\n%s\n", s) } dumpFile := filepath.Join(tmpdir, function+"_01__genssa.dump") dumpBytes, err := os.ReadFile(dumpFile) if err != nil { t.Fatalf("Could not read dump file %s, err=%v", dumpFile, err) } return dumpBytes } func sortInlineStacks(x [][]int) { sort.Slice(x, func(i, j int) bool { if len(x[i]) != len(x[j]) { return len(x[i]) < len(x[j]) } for k := range x[i] { if x[i][k] != x[j][k] { return x[i][k] < x[j][k] } } return false }) } // testInlineStack ensures that inlining is described properly in the comments in the dump file func testInlineStack(t *testing.T, file, function string, wantStacks [][]int) { // this is an inlining reporting test, not an optimization test. -N makes it less fragile dumpBytes := compileAndDump(t, file, function, "-N") dump := bufio.NewScanner(bytes.NewReader(dumpBytes)) dumpLineNum := 0 var gotStmts []int var gotStacks [][]int for dump.Scan() { line := dump.Text() dumpLineNum++ matches := inlineLine.FindStringSubmatch(line) if len(matches) == 2 { stmt, err := strconv.ParseInt(matches[1], 10, 32) if err != nil { t.Fatalf("Expected to parse a line number but saw %s instead on dump line #%d, error %v", matches[1], dumpLineNum, err) } if testing.Verbose() { fmt.Printf("Saw stmt# %d for submatch '%s' on dump line #%d = '%s'\n", stmt, matches[1], dumpLineNum, line) } gotStmts = append(gotStmts, int(stmt)) } else if len(gotStmts) > 0 { gotStacks = append(gotStacks, gotStmts) gotStmts = nil } } if len(gotStmts) > 0 { gotStacks = append(gotStacks, gotStmts) gotStmts = nil } sortInlineStacks(gotStacks) sortInlineStacks(wantStacks) if !reflect.DeepEqual(wantStacks, gotStacks) { t.Errorf("wanted inlines %+v but got %+v\n%s", wantStacks, gotStacks, dumpBytes) } } // testDebugLines compiles testdata/<file> with flags -N -l and -d=ssa/genssa/dump=<function> // then verifies that the statement-marked lines in that file are the same as those in wantStmts // These files must all be short because this is super-fragile. // "go build" is run in a temporary directory that is normally deleted, unless -test.v func testDebugLines(t *testing.T, gcflags, file, function string, wantStmts []int, ignoreRepeats bool) { dumpBytes := compileAndDump(t, file, function, gcflags) dump := bufio.NewScanner(bytes.NewReader(dumpBytes)) var gotStmts []int dumpLineNum := 0 for dump.Scan() { line := dump.Text() dumpLineNum++ matches := asmLine.FindStringSubmatch(line) if len(matches) == 2 { stmt, err := strconv.ParseInt(matches[1], 10, 32) if err != nil { t.Fatalf("Expected to parse a line number but saw %s instead on dump line #%d, error %v", matches[1], dumpLineNum, err) } if testing.Verbose() { fmt.Printf("Saw stmt# %d for submatch '%s' on dump line #%d = '%s'\n", stmt, matches[1], dumpLineNum, line) } gotStmts = append(gotStmts, int(stmt)) } } if ignoreRepeats { // remove repeats from gotStmts newGotStmts := []int{gotStmts[0]} for _, x := range gotStmts { if x != newGotStmts[len(newGotStmts)-1] { newGotStmts = append(newGotStmts, x) } } if !reflect.DeepEqual(wantStmts, newGotStmts) { t.Errorf("wanted stmts %v but got %v (with repeats still in: %v)", wantStmts, newGotStmts, gotStmts) } } else { if !reflect.DeepEqual(wantStmts, gotStmts) { t.Errorf("wanted stmts %v but got %v", wantStmts, gotStmts) } } }