Skip to content
Permalink
Browse files

all: fix build

  • Loading branch information...
mewmew committed Sep 4, 2019
1 parent d1d8141 commit 1768f6fb552b03f181e4e51dc751c3dd62a97bc8
Showing with 96 additions and 55 deletions.
  1. +1 −1 cmd/ll2dot/main.go
  2. +2 −2 cmd/ll2go/constant.go
  3. +1 −1 cmd/ll2go/instruction.go
  4. +8 −8 cmd/ll2go/main.go
  5. +6 −6 cmd/ll2go/primitive.go
  6. +1 −1 cmd/ll2go/type.go
  7. +11 −6 go.mod
  8. +61 −25 go.sum
  9. +1 −1 graph/cfg/cfg.go
  10. +4 −4 graph/cfg/dom.go
@@ -119,7 +119,7 @@ func ll2dot(llPath string, funcNames map[string]bool, force, img bool) error {
}

// Get functions set by `-funcs` or all functions if `-funcs` not used.
var funcs []*ir.Function
var funcs []*ir.Func
for _, f := range module.Funcs {
if len(funcNames) > 0 && !funcNames[f.GlobalName] {
dbg.Printf("skipping function %q.", f.Ident())
@@ -34,7 +34,7 @@ func (d *decompiler) constant(c constant.Constant) ast.Expr {
// Global variable and function addresses
case *ir.Global:
return d.globalIdent(c.GlobalName)
case *ir.Function:
case *ir.Func:
return d.globalIdent(c.GlobalName)
// Constant expressions
case constant.Expression:
@@ -330,7 +330,7 @@ func (d *decompiler) exprGetElementPtr(expr *constant.ExprGetElementPtr) ast.Exp
for _, index := range expr.Indices {
src = &ast.IndexExpr{
X: src,
Index: d.constant(index.Index),
Index: d.constant(index),
}
}
e := &ast.UnaryExpr{
@@ -508,7 +508,7 @@ func (d *decompiler) instSelect(inst *ir.InstSelect) []ast.Stmt {
func (d *decompiler) instCall(inst *ir.InstCall) ast.Stmt {
var callee ast.Expr
switch c := inst.Callee.(type) {
case *ir.Function:
case *ir.Func:
// global function identifier.
callee = d.globalIdent(c.GlobalName)
case *ir.Param:
@@ -117,7 +117,7 @@ func ll2go(llPath string, funcNames map[string]bool) (*ast.File, error) {
}

// Get functions set by `-funcs` or all functions if `-funcs` not used.
var funcs []*ir.Function
var funcs []*ir.Func
for _, f := range module.Funcs {
if len(funcNames) > 0 && !funcNames[f.GlobalName] {
dbg.Printf("skipping function %q.", f.Ident())
@@ -343,7 +343,7 @@ func (d *decompiler) pointerToConst(c constant.Constant) ast.Expr {
case *ir.Global:
// TODO: Check if `&g` should be returned instead of `g`.
return d.globalIdent(c.GlobalName)
case *ir.Function:
case *ir.Func:
// TODO: Check if `&f` should be returned instead of `f`.
return d.globalIdent(c.GlobalName)
// Constant expressions
@@ -356,7 +356,7 @@ func (d *decompiler) pointerToConst(c constant.Constant) ast.Expr {

// funcDecl converts the given LLVM IR function into a corresponding Go function
// declaration.
func (d *decompiler) funcDecl(f *ir.Function, prims []*primitive.Primitive) (*ast.FuncDecl, error) {
func (d *decompiler) funcDecl(f *ir.Func, prims []*primitive.Primitive) (*ast.FuncDecl, error) {
// Force generate local IDs.
_ = f.String()

@@ -377,7 +377,7 @@ func (d *decompiler) funcDecl(f *ir.Function, prims []*primitive.Primitive) (*as
// Reset basic block mapping.
d.blocks = make(map[string]*basicBlock)
for i, block := range f.Blocks {
d.blocks[block.LocalName] = &basicBlock{BasicBlock: block, num: i}
d.blocks[block.LocalName] = &basicBlock{Block: block, num: i}
}

// Record outgoing PHI values.
@@ -516,7 +516,7 @@ func (d *decompiler) value(v value.Value) ast.Expr {
switch v := v.(type) {
case value.Named:
switch v.(type) {
case *ir.Global, *ir.Function:
case *ir.Global, *ir.Func:
return d.globalIdent(v.Name())
default:
return d.localIdent(v.Name())
@@ -548,7 +548,7 @@ func (d *decompiler) uintLit(i uint64) ast.Expr {
// basicBlock represents a conceptual basic block, that may contain both LLVM IR
// instructions and Go statements.
type basicBlock struct {
*ir.BasicBlock
*ir.Block
// Go statements.
stmts []ast.Stmt
// Outgoing values for PHI instructions. In other words, a list of assignment
@@ -579,7 +579,7 @@ func (d *decompiler) stmts(block *basicBlock) []ast.Stmt {

// parsePrims parses the JSON file containing a mapping of control flow
// primitives for the given function.
func parsePrims(srcName string, f *ir.Function) ([]*primitive.Primitive, error) {
func parsePrims(srcName string, f *ir.Func) ([]*primitive.Primitive, error) {
graphsDir := fmt.Sprintf("%s_graphs", srcName)
jsonName := f.GlobalName + ".json"
jsonPath := filepath.Join(graphsDir, jsonName)
@@ -637,7 +637,7 @@ func locateEntryNode(g *cfg.Graph) (graph.Node, error) {

// genPrims returns the high-level primitives of the given function discovered
// by control flow analysis.
func genPrims(f *ir.Function) ([]*primitive.Primitive, error) {
func genPrims(f *ir.Func) ([]*primitive.Primitive, error) {
g := cfg.New(f)
entry, err := locateEntryNode(g)
if err != nil {
@@ -167,7 +167,7 @@ func (d *decompiler) primIf(condBlock, bodyBlock, exitBlock *basicBlock) (*basic
if _, ok := bodyBlock.Term.(*ir.TermBr); !ok {
return nil, errors.Errorf("invalid body terminator type; expected *ir.TermBr, got %T", bodyBlock.Term)
}
block := &basicBlock{BasicBlock: &ir.BasicBlock{}}
block := &basicBlock{Block: &ir.Block{}}
block.Term = exitBlock.Term
// Handle instructions.
block.stmts = append(block.stmts, d.stmts(condBlock)...)
@@ -213,7 +213,7 @@ func (d *decompiler) primIfElse(condBlock, bodyTrueBlock, bodyFalseBlock, exitBl
if _, ok := bodyFalseBlock.Term.(*ir.TermBr); !ok {
return nil, errors.Errorf("invalid body_false terminator type; expected *ir.TermBr, got %T", bodyFalseBlock.Term)
}
block := &basicBlock{BasicBlock: &ir.BasicBlock{}}
block := &basicBlock{Block: &ir.Block{}}
block.Term = exitBlock.Term
// Handle instructions.
block.stmts = append(block.stmts, d.stmts(condBlock)...)
@@ -246,7 +246,7 @@ func (d *decompiler) primIfReturn(condBlock, bodyBlock, exitBlock *basicBlock) (
// branch or the false branch. If body is the false branch, negate the
// condition.
bodyTermStmt := d.term(bodyBlock.Term)
block := &basicBlock{BasicBlock: &ir.BasicBlock{}}
block := &basicBlock{Block: &ir.Block{}}
block.Term = exitBlock.Term
// Handle instructions.
block.stmts = append(block.stmts, d.stmts(condBlock)...)
@@ -278,7 +278,7 @@ func (d *decompiler) primPreLoop(condBlock, bodyBlock, exitBlock *basicBlock) (*
if _, ok := bodyBlock.Term.(*ir.TermBr); !ok {
return nil, errors.Errorf("invalid body terminator type; expected *ir.TermBr, got %T", bodyBlock.Term)
}
block := &basicBlock{BasicBlock: &ir.BasicBlock{}}
block := &basicBlock{Block: &ir.Block{}}
block.Term = exitBlock.Term
// Handle instructions.
block.stmts = append(block.stmts, d.stmts(condBlock)...)
@@ -310,7 +310,7 @@ func (d *decompiler) primPostLoop(condBlock, exitBlock *basicBlock) (*basicBlock
// TODO: Figure out a clean way to check if the exit basic block is the true
// branch or the false branch. If exit is the true branch, negate the
// condition.
block := &basicBlock{BasicBlock: &ir.BasicBlock{}}
block := &basicBlock{Block: &ir.Block{}}
block.Term = exitBlock.Term
// Handle instructions.
body := &ast.BlockStmt{
@@ -339,7 +339,7 @@ func (d *decompiler) primSeq(entryBlock, exitBlock *basicBlock) (*basicBlock, er
if _, ok := entryBlock.Term.(*ir.TermBr); !ok {
return nil, errors.Errorf("invalid entry terminator type; expected *ir.TermBr, got %T", entryBlock.Term)
}
block := &basicBlock{BasicBlock: &ir.BasicBlock{}}
block := &basicBlock{Block: &ir.Block{}}
block.Term = exitBlock.Term
// Handle instructions.
block.stmts = append(block.stmts, d.stmts(entryBlock)...)
@@ -66,7 +66,7 @@ func (d *decompiler) goTypeDef(t irtypes.Type) ast.Expr {
return ast.NewIdent("float32")
case irtypes.FloatKindDouble:
return ast.NewIdent("float64")
case irtypes.FloatKindHalf, irtypes.FloatKindFP128, irtypes.FloatKindX86FP80, irtypes.FloatKindPPCFP128:
case irtypes.FloatKindHalf, irtypes.FloatKindFP128, irtypes.FloatKindX86_FP80, irtypes.FloatKindPPC_FP128:
// TODO: Add proper support for non-builtin float types.
return ast.NewIdent("float64")
default:
17 go.mod
@@ -1,10 +1,15 @@
module github.com/decomp/decomp

require (
github.com/graphism/exp v0.0.0-20181208150744-60e1f9ae6685
github.com/graphism/simple v0.0.0-20181208150621-c42395dbfa50
github.com/llir/llvm v0.3.0-pre4
github.com/mewkiz/pkg v0.0.0-20181119122551-9729f4f4ff2b
github.com/pkg/errors v0.8.0
gonum.org/v1/gonum v0.0.0-20181208091643-b71a28080e0f
github.com/graphism/exp v0.0.0-20190904093716-eaf14ca0c511
github.com/graphism/simple v0.0.0-20190824091927-3dbe7f1633cb
github.com/llir/llvm v0.3.0-pre7.0.20190702100948-293cf9ae11e2
github.com/mewkiz/pkg v0.0.0-20190828003901-6b61f1db6192
github.com/pkg/errors v0.8.1
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f // indirect
golang.org/x/tools v0.0.0-20190628222527-fb37f6ba8261 // indirect
gonum.org/v1/gonum v0.0.0-20190821101010-d61003946d0d
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e // indirect
)

go 1.13
86 go.sum
@@ -1,40 +1,76 @@
bitbucket.org/zombiezen/cardcpx v0.0.0-20150417151802-902f68ff43ef h1:Uc8hUoyAlYy8huPnrqJC++v34avlqflgbQate6HLIfw=
bitbucket.org/zombiezen/cardcpx v0.0.0-20150417151802-902f68ff43ef/go.mod h1:ZJR5FpaQx7Bt2bzIV3gBaCInI1+kG949WhNYYlRr8eA=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/graphism/exp v0.0.0-20181208150744-60e1f9ae6685 h1:9TMzM7bRC0lCmY8THiiNf2OI1TCIrV5AyFK7DAeOgOA=
github.com/graphism/exp v0.0.0-20181208150744-60e1f9ae6685/go.mod h1:GhC/PwcZ8bU9k1CN1f+jPClgqdXrZq6LRVFneaoZfh4=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
github.com/d4l3k/messagediff v1.2.2-0.20190827172131-afddc8bdbe1d h1:gCZKJxJZ/3MAq+ViFj+s3Uo0LfM4RaInvsKXe6zfqM4=
github.com/d4l3k/messagediff v1.2.2-0.20190827172131-afddc8bdbe1d/go.mod h1:Oozbb1TVXFac9FtSIxHBMnBCq2qeH/2KkEQxENCrlLo=
github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k=
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
github.com/graphism/exp v0.0.0-20190904093716-eaf14ca0c511 h1:clCBylphJ0eAdkTWgEddn791f7CI0Tw9QeiLDFeJwVo=
github.com/graphism/exp v0.0.0-20190904093716-eaf14ca0c511/go.mod h1:o6FrvUmFz48/wwB1fvhQYmGA14Zq5sXb3PPZD55KTwM=
github.com/graphism/simple v0.0.0-20181208150621-c42395dbfa50 h1:0dZv/2+dMWaPPFN6BMrBuq2Bh4jd5UmoED8iO543dYE=
github.com/graphism/simple v0.0.0-20181208150621-c42395dbfa50/go.mod h1:cox5q9v+f1rnFijpHx1qN0aS9dkJS4rFxCNHgcjBa8c=
github.com/inspirer/textmapper v0.0.0-20181202234051-312f7a0d146c h1:213Qb/08zOK1MMtHGdf8yuhnil4FcyJQpiP46PvLcCE=
github.com/inspirer/textmapper v0.0.0-20181202234051-312f7a0d146c/go.mod h1:SpoIwXu07A3gguovN379QUCTHpUk1lhX2KIjVxpQOas=
github.com/graphism/simple v0.0.0-20190824091927-3dbe7f1633cb h1:mg5G3mdtpMb3TLnvTnhb4lrMLfXBm2VyRCYVRBWIHvk=
github.com/graphism/simple v0.0.0-20190824091927-3dbe7f1633cb/go.mod h1:sYheWgIrtuh/RhKOczh7iOzK61IdSpcu1+bqe0A67AY=
github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/llir/ll v0.0.0-20181207163918-0cfcde00de3f h1:OJxImTgaK6hQ8w6OOEeNox1LFsORsRxLVQidQCm04nA=
github.com/llir/ll v0.0.0-20181207163918-0cfcde00de3f/go.mod h1:jPRfHdh8JEos8a05CSejK/nIKptCRRixCfhg0zngzpg=
github.com/llir/llvm v0.3.0-pre4 h1:gRG6TiB2QsShFH8PG6vcz00LcwLtZcRX0AlCUbp+5fE=
github.com/llir/llvm v0.3.0-pre4/go.mod h1:5oQbQPEpQQem6CujHgRhfvDzTpCW5iinW3s+W33dG3w=
github.com/mewkiz/pkg v0.0.0-20181119122551-9729f4f4ff2b h1:XHFBx9ZEVHnSCRiTz7w1a/NRBk9x7iyFiqnoN6R+vu8=
github.com/mewkiz/pkg v0.0.0-20181119122551-9729f4f4ff2b/go.mod h1:bhmdGJSMX5WCIBFmk27tBnUvBJm5WxXmarBV41qvbNI=
github.com/llir/ll v0.0.0-20190401085702-9e8d1b0d1612 h1:5oVz/F+NJfqFMFI34/Had22ICKVnhYDvKDUOPtld3Bo=
github.com/llir/ll v0.0.0-20190401085702-9e8d1b0d1612/go.mod h1:8W5HJz80PitAyPZUpOcljQxTu6LD5YKW1URTo+OjVoc=
github.com/llir/llvm v0.3.0-pre7.0.20190702100948-293cf9ae11e2 h1:HvPvVUkQUFwTv0VikBGc57IJnK8d3NpLOlgQzX6cFqQ=
github.com/llir/llvm v0.3.0-pre7.0.20190702100948-293cf9ae11e2/go.mod h1:f82xl2Z6BY+9QxDjzF9+kg9ywwGCxH5+TkTylbl6+rA=
github.com/mewkiz/pkg v0.0.0-20190317153131-e8616647c365/go.mod h1:NefHmmDOyP6U1WiFFk+jFR3YdHoTeueo8nOZ6i1vZbA=
github.com/mewkiz/pkg v0.0.0-20190828003901-6b61f1db6192 h1:3bApyjJo5cTtEFjRdzyc+XqtTYZTTSksEsif2wvE/SQ=
github.com/mewkiz/pkg v0.0.0-20190828003901-6b61f1db6192/go.mod h1:D1aXY6HcUk9IChUnRICtWcWwuK7yvN49X2c9EPM99oE=
github.com/mewmew/float v0.0.0-20181121163145-c0f786d7da73 h1:bTqCgPsW3TFb9MFtvaOmGFWVhCmN3EmRw02zkchdOHo=
github.com/mewmew/float v0.0.0-20181121163145-c0f786d7da73/go.mod h1:obQBs6O+vjhgOZLkGdALxItKw4xrI49lSBEnAMO6lWI=
github.com/mewspring/tools v0.0.0-20181204020634-6c6637dc82b6 h1:J/FwQ6PvTeHbDkhGt+nDlIXXGRdXUCqVdL85tmHflAg=
github.com/mewspring/tools v0.0.0-20181204020634-6c6637dc82b6/go.mod h1:UAdVbSksr+7Bg+z4mga16OaBg3qAcgdaF3x3AeqJHEs=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/mewspring/tools v0.0.0-20190326052302-906fcc68b3d8 h1:DSZ+nV7JOU9CznTYsSq6nZsnWf7pXrjRfGqMyTuwgwI=
github.com/mewspring/tools v0.0.0-20190326052302-906fcc68b3d8/go.mod h1:UAdVbSksr+7Bg+z4mga16OaBg3qAcgdaF3x3AeqJHEs=
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/remyoudompheng/bigfft v0.0.0-20170806203942-52369c62f446/go.mod h1:uYEyJGbgTkfkS4+E/PavXkNJcbFIpEtjt2B0KDQ5+9M=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20181206211736-68cc7b1f272e h1:gTD8phFoxK/U3l0n5zSIC8MM5MQ2N19bEwBN7cEKNso=
golang.org/x/exp v0.0.0-20181206211736-68cc7b1f272e/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20181210123644-7d6377eee41f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190312203227-4b39c73a6495/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f h1:F3VDpCbV+46wJMDIwbFSefCwLlvK2CoEKVEYHO8p5Os=
golang.org/x/exp v0.0.0-20190627132806-fd42eb6b336f/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20190220214146-31aff87c08e9/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181206194817-bcd4e47d0288/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181207222222-4c874b978acb h1:YIXCxYolAiiPmVSqA4gVUVcHo8Mi1ivU7ANnK9a63JY=
golang.org/x/tools v0.0.0-20181207222222-4c874b978acb/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190330180304-aef51cc3777c/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190628222527-fb37f6ba8261 h1:KP5slYyJf3GFQbPLTWjQ0TCqBQ73hYpqtCElF+iSruQ=
golang.org/x/tools v0.0.0-20190628222527-fb37f6ba8261/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI=
gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20181208091643-b71a28080e0f h1:mTXdxjj6u0sKi+UItZVxq7mfSaNBQFpeu0AOv8u/CCU=
gonum.org/v1/gonum v0.0.0-20181208091643-b71a28080e0f/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20181210083604-572d9101fe4f/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo=
gonum.org/v1/gonum v0.0.0-20190331200053-3d26580ed485/go.mod h1:2ltnJ7xHfj0zHS40VVPYEAAMTa3ZGguvHGBSJeRWqE0=
gonum.org/v1/gonum v0.0.0-20190821101010-d61003946d0d h1:6lN6mPOoQL2pCuKVr+GGvWa5yz3hDZAC1eroxeE6WUg=
gonum.org/v1/gonum v0.0.0-20190821101010-d61003946d0d/go.mod h1:9mxDZsDKxgMAuccQkewq682L+0eCu4dCN2yonUJTCLU=
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6 h1:4WsZyVtkthqrHTbDCJfiTs8IWNYE4uvsSDgaV6xpp+o=
gonum.org/v1/netlib v0.0.0-20181029234149-ec6d1f5cefe6/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw=
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e h1:jRyg0XfpwWlhEV8mDfdNGBeSJM2fuyh9Yjrnd8kF2Ts=
gonum.org/v1/netlib v0.0.0-20190331212654-76723241ea4e/go.mod h1:kS+toOQn6AQKjmKJ7gzohV1XkqsFehRA2FbsbkopSuQ=
gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc=
modernc.org/cc v1.0.0/go.mod h1:1Sk4//wdnYJiUIxnW8ddKpaOJCF37yAdqYnkxUpaYxw=
modernc.org/golex v1.0.0/go.mod h1:b/QX9oBD/LhixY6NDh+IdGv17hgB+51fET1i2kPSmvk=
modernc.org/mathutil v1.0.0/go.mod h1:wU0vUrJsVWBZ4P6e7xtFJEhFSNsfRLJ8H458uRjg03k=
modernc.org/strutil v1.0.0/go.mod h1:lstksw84oURvj9y3tn8lGvRxyRC1S2+g5uuIzNfIOBs=
modernc.org/xc v1.0.0/go.mod h1:mRNCo0bvLjGhHO9WsyuKVU4q0ceiDDDoEeWDJHrNx8I=
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
@@ -22,7 +22,7 @@ type Graph struct {
}

// New returns a new control flow graph based on the given function.
func New(f *ir.Function) *Graph {
func New(f *ir.Func) *Graph {
g := &Graph{
DirectedGraph: simple.NewDirectedGraph(),
nodes: make(map[string]*Node),
@@ -2,23 +2,23 @@ package cfg

import (
"gonum.org/v1/gonum/graph"
"gonum.org/v1/gonum/graph/path"
"gonum.org/v1/gonum/graph/flow"
)

// A DominatorTree represents a dominator tree.
type DominatorTree struct {
path.DominatorTree
flow.DominatorTree
}

// NewDom returns a new dominator tree based on the given graph.
func NewDom(g graph.Directed, entry graph.Node) DominatorTree {
dt := path.Dominators(entry, g)
dt := flow.Dominators(entry, g)
return DominatorTree{
DominatorTree: dt,
}
}

// Dominates reports whether A dominates B.
func (dt DominatorTree) Dominates(a, b graph.Node) bool {
return a == dt.DominatorTree.DominatorOf(b)
return a.ID() == dt.DominatorTree.DominatorOf(b.ID()).ID()
}

0 comments on commit 1768f6f

Please sign in to comment.
You can’t perform that action at this time.