Skip to content

Commit babfb4e

Browse files
committed
cmd/internal/obj: change Link.Flag_shared to bool
Change-Id: I9bda2ce6f45fb8292503f86d8f9f161601f222b7 Reviewed-on: https://go-review.googlesource.com/22053 Reviewed-by: Michael Hudson-Doyle <[email protected]>
1 parent 980ab12 commit babfb4e

15 files changed

Lines changed: 35 additions & 43 deletions

File tree

src/cmd/asm/main.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,7 @@ func main() {
3939
}
4040
ctxt.LineHist.TrimPathPrefix = *flags.TrimPath
4141
ctxt.Flag_dynlink = *flags.Dynlink
42-
if *flags.Shared || *flags.Dynlink {
43-
ctxt.Flag_shared = 1
44-
}
42+
ctxt.Flag_shared = *flags.Shared || *flags.Dynlink
4543
ctxt.Bso = bufio.NewWriter(os.Stdout)
4644
defer ctxt.Bso.Flush()
4745

src/cmd/compile/internal/gc/cgen.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2363,7 +2363,7 @@ func Ginscall(f *Node, proc int) {
23632363
// If the MOVD is not needed, insert a hardware NOP
23642364
// so that the same number of instructions are used
23652365
// on ppc64 in both shared and non-shared modes.
2366-
if Ctxt.Flag_shared != 0 {
2366+
if Ctxt.Flag_shared {
23672367
p := Thearch.Gins(ppc64.AMOVD, nil, nil)
23682368
p.From.Type = obj.TYPE_MEM
23692369
p.From.Offset = 24

src/cmd/compile/internal/gc/main.go

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,7 @@ func Main() {
207207
flag.BoolVar(&ssaEnabled, "ssa", true, "use SSA backend to generate code")
208208
obj.Flagparse(usage)
209209

210-
if flag_dynlink {
211-
flag_shared = true
212-
}
213-
if flag_shared {
214-
// TODO(mdempsky): Change Flag_shared to bool.
215-
Ctxt.Flag_shared = 1
216-
}
210+
Ctxt.Flag_shared = flag_dynlink || flag_shared
217211
Ctxt.Flag_dynlink = flag_dynlink
218212
Ctxt.Flag_optimize = Debug['N'] == 0
219213

src/cmd/compile/internal/ppc64/galign.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
)
1212

1313
func betypeinit() {
14-
if gc.Ctxt.Flag_shared != 0 {
14+
if gc.Ctxt.Flag_shared {
1515
gc.Thearch.ReservedRegs = append(gc.Thearch.ReservedRegs, ppc64.REG_R2)
1616
gc.Thearch.ReservedRegs = append(gc.Thearch.ReservedRegs, ppc64.REG_R12)
1717
}

src/cmd/compile/internal/ppc64/gsubr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ func rawgins(as obj.As, f *gc.Node, t *gc.Node) *obj.Prog {
580580
case obj.ACALL:
581581
if p.To.Type == obj.TYPE_REG && p.To.Reg != ppc64.REG_CTR {
582582
// Allow front end to emit CALL REG, and rewrite into MOV REG, CTR; CALL CTR.
583-
if gc.Ctxt.Flag_shared != 0 {
583+
if gc.Ctxt.Flag_shared {
584584
// Make sure function pointer is in R12 as well when
585585
// compiling Go into PIC.
586586
// TODO(mwhudson): it would obviously be better to
@@ -602,7 +602,7 @@ func rawgins(as obj.As, f *gc.Node, t *gc.Node) *obj.Prog {
602602
p.To.Type = obj.TYPE_REG
603603
p.To.Reg = ppc64.REG_CTR
604604

605-
if gc.Ctxt.Flag_shared != 0 {
605+
if gc.Ctxt.Flag_shared {
606606
// When compiling Go into PIC, the function we just
607607
// called via pointer might have been implemented in
608608
// a separate module and so overwritten the TOC

src/cmd/compile/internal/ppc64/reg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ func excludedregs() uint64 {
113113
// Exclude registers with fixed functions
114114
regbits := 1<<0 | RtoB(ppc64.REGSP) | RtoB(ppc64.REGG) | RtoB(ppc64.REGTLS) | RtoB(ppc64.REGTMP)
115115

116-
if gc.Ctxt.Flag_shared != 0 {
116+
if gc.Ctxt.Flag_shared {
117117
// When compiling Go into PIC, R2 is reserved to be the TOC pointer
118118
// and R12 so that calls via function pointer can stomp on it.
119119
regbits |= RtoB(ppc64.REG_R2)

src/cmd/compile/internal/x86/reg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func regnames(n *int) []string {
6262
}
6363

6464
func excludedregs() uint64 {
65-
if gc.Ctxt.Flag_shared != 0 {
65+
if gc.Ctxt.Flag_shared {
6666
return RtoB(x86.REG_SP) | RtoB(x86.REG_CX)
6767
} else {
6868
return RtoB(x86.REG_SP)

src/cmd/internal/obj/arm/asm5.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -870,7 +870,7 @@ func addpool(ctxt *obj.Link, p *obj.Prog, a *obj.Addr) {
870870
t.To.Type = a.Type
871871
t.To.Name = a.Name
872872

873-
if ctxt.Flag_shared != 0 && t.To.Sym != nil {
873+
if ctxt.Flag_shared && t.To.Sym != nil {
874874
t.Rel = p
875875
}
876876

@@ -1015,7 +1015,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
10151015

10161016
ctxt.Instoffset = 0 // s.b. unused but just in case
10171017
if a.Sym.Type == obj.STLSBSS {
1018-
if ctxt.Flag_shared != 0 {
1018+
if ctxt.Flag_shared {
10191019
return C_TLS_IE
10201020
} else {
10211021
return C_TLS_LE
@@ -1322,7 +1322,7 @@ func buildop(ctxt *obj.Link) {
13221322
}
13231323
for n = 0; optab[n].as != obj.AXXX; n++ {
13241324
if optab[n].flag&LPCREL != 0 {
1325-
if ctxt.Flag_shared != 0 {
1325+
if ctxt.Flag_shared {
13261326
optab[n].size += int8(optab[n].pcrelsiz)
13271327
} else {
13281328
optab[n].flag &^= LPCREL
@@ -1633,7 +1633,7 @@ func asmout(ctxt *obj.Link, p *obj.Prog, o *Optab, out []uint32) {
16331633
rel.Sym = p.To.Sym
16341634
rel.Add = p.To.Offset
16351635

1636-
if ctxt.Flag_shared != 0 {
1636+
if ctxt.Flag_shared {
16371637
if p.To.Name == obj.NAME_GOTREF {
16381638
rel.Type = obj.R_GOTPCREL
16391639
} else {

src/cmd/internal/obj/arm64/asm7.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ func aclass(ctxt *obj.Link, a *obj.Addr) int {
972972
ctxt.Instoffset = a.Offset
973973
if a.Sym != nil { // use relocation
974974
if a.Sym.Type == obj.STLSBSS {
975-
if ctxt.Flag_shared != 0 {
975+
if ctxt.Flag_shared {
976976
return C_TLS_IE
977977
} else {
978978
return C_TLS_LE

src/cmd/internal/obj/link.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,7 @@ type Link struct {
617617
Debugvlog int32
618618
Debugdivmod int32
619619
Debugpcln int32
620-
Flag_shared int32
620+
Flag_shared bool
621621
Flag_dynlink bool
622622
Flag_optimize bool
623623
Bso *bufio.Writer

0 commit comments

Comments
 (0)