X7ROOT File Manager
Current Path:
/opt/golang/1.19.4/src/cmd/compile/internal/ssa
opt
/
golang
/
1.19.4
/
src
/
cmd
/
compile
/
internal
/
ssa
/
📁
..
📄
README.md
(8.14 KB)
📄
TODO
(950 B)
📄
addressingmodes.go
(23.64 KB)
📄
bench_test.go
(531 B)
📄
biasedsparsemap.go
(2.71 KB)
📄
block.go
(11.1 KB)
📄
branchelim.go
(11.98 KB)
📄
branchelim_test.go
(5.21 KB)
📄
cache.go
(2.46 KB)
📄
check.go
(16.59 KB)
📄
checkbce.go
(956 B)
📄
compile.go
(18.19 KB)
📄
config.go
(11.7 KB)
📄
copyelim.go
(1.83 KB)
📄
copyelim_test.go
(1.29 KB)
📄
critical.go
(3.19 KB)
📄
cse.go
(9.43 KB)
📄
cse_test.go
(4.25 KB)
📄
deadcode.go
(9.61 KB)
📄
deadcode_test.go
(3.49 KB)
📄
deadstore.go
(9.08 KB)
📄
deadstore_test.go
(4.09 KB)
📄
debug.go
(56.34 KB)
📄
debug_lines_test.go
(8.29 KB)
📄
debug_test.go
(28.75 KB)
📄
decompose.go
(13.41 KB)
📄
dom.go
(7.98 KB)
📄
dom_test.go
(13.34 KB)
📄
expand_calls.go
(63.5 KB)
📄
export_test.go
(3.23 KB)
📄
flagalloc.go
(6.68 KB)
📄
flags_amd64_test.s
(533 B)
📄
flags_arm64_test.s
(699 B)
📄
flags_test.go
(2.49 KB)
📄
func.go
(27.08 KB)
📄
func_test.go
(13.07 KB)
📄
fuse.go
(6.5 KB)
📄
fuse_branchredirect.go
(3.24 KB)
📄
fuse_comparisons.go
(4.04 KB)
📄
fuse_test.go
(7.21 KB)
📁
gen
📄
html.go
(34.72 KB)
📄
id.go
(576 B)
📄
layout.go
(4.82 KB)
📄
lca.go
(3.77 KB)
📄
lca_test.go
(1.65 KB)
📄
likelyadjust.go
(15.24 KB)
📄
location.go
(3.06 KB)
📄
loopbce.go
(10.54 KB)
📄
loopreschedchecks.go
(15.86 KB)
📄
looprotate.go
(2.61 KB)
📄
lower.go
(1.36 KB)
📄
magic.go
(15.77 KB)
📄
magic_test.go
(9.1 KB)
📄
nilcheck.go
(11.06 KB)
📄
nilcheck_test.go
(12.17 KB)
📄
numberlines.go
(7.83 KB)
📄
op.go
(18.65 KB)
📄
opGen.go
(1.01 MB)
📄
opt.go
(308 B)
📄
passbm_test.go
(3.14 KB)
📄
phielim.go
(1.48 KB)
📄
phiopt.go
(8.08 KB)
📄
poset.go
(37.2 KB)
📄
poset_test.go
(18.14 KB)
📄
print.go
(3.85 KB)
📄
prove.go
(41.82 KB)
📄
regalloc.go
(83.69 KB)
📄
regalloc_test.go
(6.49 KB)
📄
rewrite.go
(53.49 KB)
📄
rewrite386.go
(289.01 KB)
📄
rewrite386splitload.go
(4.05 KB)
📄
rewriteAMD64.go
(888.95 KB)
📄
rewriteAMD64splitload.go
(21.41 KB)
📄
rewriteARM.go
(487.7 KB)
📄
rewriteARM64.go
(751.84 KB)
📄
rewriteCond_test.go
(10.62 KB)
📄
rewriteLOONG64.go
(193.44 KB)
📄
rewriteMIPS.go
(174.44 KB)
📄
rewriteMIPS64.go
(195.55 KB)
📄
rewritePPC64.go
(431.6 KB)
📄
rewriteRISCV64.go
(159.66 KB)
📄
rewriteS390X.go
(433.4 KB)
📄
rewriteWasm.go
(109.86 KB)
📄
rewrite_test.go
(6.91 KB)
📄
rewritedec.go
(10.16 KB)
📄
rewritedec64.go
(63.77 KB)
📄
rewritegeneric.go
(617.96 KB)
📄
schedule.go
(18.23 KB)
📄
schedule_test.go
(2.91 KB)
📄
shift_test.go
(4.05 KB)
📄
shortcircuit.go
(12.63 KB)
📄
shortcircuit_test.go
(1.31 KB)
📄
sizeof_test.go
(855 B)
📄
softfloat.go
(1.99 KB)
📄
sparsemap.go
(1.98 KB)
📄
sparseset.go
(1.54 KB)
📄
sparsetree.go
(8.05 KB)
📄
stackalloc.go
(12.79 KB)
📄
stackframe.go
(290 B)
📄
stmtlines_test.go
(2.96 KB)
📁
testdata
📄
tighten.go
(4.3 KB)
📄
trim.go
(4.24 KB)
📄
tuple.go
(1.97 KB)
📄
value.go
(15.21 KB)
📄
writebarrier.go
(19.29 KB)
📄
writebarrier_test.go
(1.75 KB)
📄
xposmap.go
(3.29 KB)
📄
zcse.go
(2.07 KB)
📄
zeroextension_test.go
(1.66 KB)
Editing: debug_lines_test.go
// 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" "internal/buildcfg" "runtime" "sort" "fmt" "internal/testenv" "io/ioutil" "os" "os/exec" "path/filepath" "reflect" "regexp" "strconv" "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][0-9]+\s+[0-9]+\s\(\+([0-9]+)\)`) // 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 + `[-a-zA-Z0-9_]+\.go:([0-9]+)`) // 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 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. switch testGoArch() { case "arm64", "amd64": // register ABI testDebugLines(t, "-N -l", "sayhi.go", "sayhi", []int{8, 9, 10, 11}, false) case "arm", "386": // probably not register ABI for a while testDebugLines(t, "-N -l", "sayhi.go", "sayhi", []int{9, 10, 11}, false) default: // expect ppc64le and riscv will pick up register ABI soonish, not sure about others t.Skip("skipped for many architectures, also changes w/ register ABI") } } func TestDebugLinesPushback(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") } switch testGoArch() { default: t.Skip("skipped for many architectures") case "arm64", "amd64": // register ABI fn := "(*List[go.shape.int_0]).PushBack" if buildcfg.Experiment.Unified { // Unified mangles differently fn = "(*List[int]).PushBack" } testDebugLines(t, "-N -l", "pushback.go", fn, []int{17, 18, 19, 20, 21, 22, 24}, true) } } func TestDebugLinesConvert(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") } switch testGoArch() { default: t.Skip("skipped for many architectures") case "arm64", "amd64": // register ABI fn := "G[go.shape.int_0]" if buildcfg.Experiment.Unified { // Unified mangles differently fn = "G[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 compileAndDump(t *testing.T, file, function, moreGCFlags string) []byte { testenv.MustHaveGoBuild(t) tmpdir, err := ioutil.TempDir("", "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 := exec.Command(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 bytes.Buffer 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", wantStacks, gotStacks) } } // 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) } } }
Upload File
Create Folder