]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.inline] cmd/internal/obj: use src.Pos in obj.Prog
authorDavid Lazar <lazard@golang.org>
Fri, 9 Dec 2016 17:34:01 +0000 (12:34 -0500)
committerDavid Lazar <lazard@golang.org>
Fri, 9 Dec 2016 20:25:10 +0000 (20:25 +0000)
This will let us use the src.Pos struct to thread inlining
information through to obj.

Change-Id: I96a16d3531167396988df66ae70f0b729049cc82
Reviewed-on: https://go-review.googlesource.com/34195
Run-TryBot: David Lazar <lazard@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
src/cmd/asm/internal/asm/asm.go
src/cmd/compile/internal/gc/gsubr.go
src/cmd/compile/internal/gc/plive.go
src/cmd/internal/obj/link.go
src/cmd/internal/obj/pcln.go
src/cmd/internal/obj/util.go

index d7c5687d3c7a3bdc8b716c78d162db5d5f70e9c7..c2a8784a277c0fea9c7e0a66f7c4ef23039d1450 100644 (file)
@@ -13,6 +13,7 @@ import (
        "cmd/asm/internal/flags"
        "cmd/asm/internal/lex"
        "cmd/internal/obj"
+       "cmd/internal/src"
        "cmd/internal/sys"
 )
 
@@ -163,7 +164,7 @@ func (p *Parser) asmText(word string, operands [][]lex.Token) {
        prog := &obj.Prog{
                Ctxt:   p.ctxt,
                As:     obj.ATEXT,
-               Lineno: p.histLineNum,
+               Lineno: src.MakePos(p.histLineNum),
                From:   nameAddr,
                From3: &obj.Addr{
                        Type:   obj.TYPE_CONST,
@@ -296,7 +297,7 @@ func (p *Parser) asmPCData(word string, operands [][]lex.Token) {
        prog := &obj.Prog{
                Ctxt:   p.ctxt,
                As:     obj.APCDATA,
-               Lineno: p.histLineNum,
+               Lineno: src.MakePos(p.histLineNum),
                From:   key,
                To:     value,
        }
@@ -326,7 +327,7 @@ func (p *Parser) asmFuncData(word string, operands [][]lex.Token) {
        prog := &obj.Prog{
                Ctxt:   p.ctxt,
                As:     obj.AFUNCDATA,
-               Lineno: p.histLineNum,
+               Lineno: src.MakePos(p.histLineNum),
                From:   valueAddr,
                To:     nameAddr,
        }
@@ -341,7 +342,7 @@ func (p *Parser) asmJump(op obj.As, cond string, a []obj.Addr) {
        var target *obj.Addr
        prog := &obj.Prog{
                Ctxt:   p.ctxt,
-               Lineno: p.histLineNum,
+               Lineno: src.MakePos(p.histLineNum),
                As:     op,
        }
        switch len(a) {
@@ -469,7 +470,7 @@ func (p *Parser) asmInstruction(op obj.As, cond string, a []obj.Addr) {
        // fmt.Printf("%s %+v\n", op, a)
        prog := &obj.Prog{
                Ctxt:   p.ctxt,
-               Lineno: p.histLineNum,
+               Lineno: src.MakePos(p.histLineNum),
                As:     op,
        }
        switch len(a) {
index 3a3effec2f54789b6af1e960cbc500fec4eb7c33..0b3d217948ffdd3c95d5d26b36d0ed21cbb2c753 100644 (file)
@@ -45,7 +45,7 @@ func Prog(as obj.As) *obj.Prog {
        }
 
        p.As = as
-       p.Lineno = int32(lineno.Line()) // TODO(gri) fix this
+       p.Lineno = lineno
        return p
 }
 
index 4cb829cc734cd1461b49cd1c0ad1f41fe45eadae..5fa864568fd5186c4390b0f3b2ab4642d59a8847 100644 (file)
@@ -17,7 +17,6 @@ package gc
 
 import (
        "cmd/internal/obj"
-       "cmd/internal/src"
        "cmd/internal/sys"
        "crypto/md5"
        "fmt"
@@ -1254,7 +1253,7 @@ func livenessepilogue(lv *Liveness) {
                                                if !n.Name.Needzero {
                                                        n.Name.Needzero = true
                                                        if debuglive >= 1 {
-                                                               Warnl(src.MakePos(p.Lineno), "%v: %L is ambiguously live", Curfn.Func.Nname, n)
+                                                               Warnl(p.Lineno, "%v: %L is ambiguously live", Curfn.Func.Nname, n)
                                                        }
                                                }
                                        }
@@ -1345,7 +1344,7 @@ func livenessepilogue(lv *Liveness) {
                                                }
                                                n := lv.vars[j]
                                                if n.Class != PPARAM {
-                                                       yyerrorl(src.MakePos(p.Lineno), "internal error: %v %L recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, n, p.Pc)
+                                                       yyerrorl(p.Lineno, "internal error: %v %L recorded as live on entry, p.Pc=%v", Curfn.Func.Nname, n, p.Pc)
                                                }
                                        }
                                }
index 2ab2aec9263ff70361111b00b8323286678a22c9..e428d1747dbfb6f5cb3e6392afbbc16aeded863c 100644 (file)
@@ -32,6 +32,7 @@ package obj
 
 import (
        "bufio"
+       "cmd/internal/src"
        "cmd/internal/sys"
        "fmt"
 )
@@ -238,7 +239,7 @@ type Prog struct {
        Forwd  *Prog       // for x86 back end
        Rel    *Prog       // for x86, arm back ends
        Pc     int64       // for back ends or assembler: virtual or actual program counter, depending on phase
-       Lineno int32       // line number of this instruction
+       Lineno src.Pos     // line number of this instruction
        Spadj  int32       // effect of instruction on stack pointer (increment or decrement amount)
        As     As          // assembler opcode
        Reg    int16       // 2nd source operand
index d9893e42cdbe4193e54f4c7531b6d8d516d32c2e..408bb2bfe72ececf2c8629843615f37fb6d76bd0 100644 (file)
@@ -138,10 +138,10 @@ func funcpctab(ctxt *Link, dst *Pcdata, func_ *LSym, desc string, valfunc func(*
 // Because p->lineno applies to p, phase == 0 (before p)
 // takes care of the update.
 func pctofileline(ctxt *Link, sym *LSym, oldval int32, p *Prog, phase int32, arg interface{}) int32 {
-       if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno == 0 || phase == 1 {
+       if p.As == ATEXT || p.As == ANOP || p.As == AUSEFIELD || p.Lineno.Line() == 0 || phase == 1 {
                return oldval
        }
-       f, l := linkgetline(ctxt, p.Lineno)
+       f, l := linkgetline(ctxt, p.Lineno.Line())
        if f == nil {
                //      print("getline failed for %s %v\n", ctxt->cursym->name, p);
                return oldval
index bc5d1c5d5a1552a4143915e984490c4ca2144b48..472e13bc4449a6174b5ffb8dc75bfeb484863308 100644 (file)
@@ -59,7 +59,7 @@ func Getgoextlinkenabled() string {
 }
 
 func (p *Prog) Line() string {
-       return p.Ctxt.LineHist.LineString(int(p.Lineno))
+       return p.Ctxt.LineHist.LineString(int(p.Lineno.Line()))
 }
 
 var armCondCode = []string{