Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/goPublic

Commit3fa4a78

Browse files
committed
[release-branch.go1.3] cmd/6g, cmd/8g: fix, test byte-sized magic multiply
««« CL 124950043 / 8e5ec6948793cmd/6g, cmd/8g: fix, test byte-sized magic multiplyCredit to Rémy for finding and writing test case.Fixes#8325.LGTM=rR=golang-codereviews, rCC=dave, golang-codereviews, iant, remyoudomphenghttps://golang.org/cl/124950043»»»TBR=rscCC=golang-codereviewshttps://golang.org/cl/126000043
1 parentfa02130 commit3fa4a78

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

‎src/cmd/6g/ggen.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -943,7 +943,7 @@ cgen_hmul(Node *nl, Node *nr, Node *res)
943943
if(t->width==1) {
944944
// byte multiply behaves differently.
945945
nodreg(&ax,t,D_AH);
946-
nodreg(&dx,t,D_DL);
946+
nodreg(&dx,t,D_DX);
947947
gmove(&ax,&dx);
948948
}
949949
nodreg(&dx,t,D_DX);

‎src/cmd/6g/peep.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,11 @@ copyu(Prog *p, Adr *v, Adr *s)
838838
staticint
839839
copyas(Adr*a,Adr*v)
840840
{
841+
if(D_AL <=a->type&&a->type <=D_R15B)
842+
fatal("use of byte register");
843+
if(D_AL <=v->type&&v->type <=D_R15B)
844+
fatal("use of byte register");
845+
841846
if(a->type!=v->type)
842847
return0;
843848
if(regtyp(v))

‎src/cmd/8g/ggen.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -991,7 +991,7 @@ cgen_hmul(Node *nl, Node *nr, Node *res)
991991
if(t->width==1) {
992992
// byte multiply behaves differently.
993993
nodreg(&ax,t,D_AH);
994-
nodreg(&dx,t,D_DL);
994+
nodreg(&dx,t,D_DX);
995995
gmove(&ax,&dx);
996996
}
997997
nodreg(&dx,t,D_DX);

‎src/cmd/8g/peep.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ copyu(Prog *p, Adr *v, Adr *s)
634634
staticint
635635
copyas(Adr*a,Adr*v)
636636
{
637+
if(D_AL <=a->type&&a->type <=D_R15B)
638+
fatal("use of byte register");
639+
if(D_AL <=v->type&&v->type <=D_R15B)
640+
fatal("use of byte register");
641+
637642
if(a->type!=v->type)
638643
return0;
639644
if(regtyp(v))

‎test/fixedbugs/issue8325.go‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// run
2+
3+
// Copyright 2014 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
// Issue 8325: corrupted byte operations during optimization
8+
// pass.
9+
10+
package main
11+
12+
constalphanum="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
13+
14+
funcmain() {
15+
varbytes= []byte{10,20,30,40,50}
16+
17+
fori,b:=rangebytes {
18+
bytes[i]=alphanum[b%byte(len(alphanum))]
19+
}
20+
21+
for_,b:=rangebytes {
22+
switch {
23+
case'0'<=b&&b<='9',
24+
'A'<=b&&b<='Z':
25+
default:
26+
println("found a bad character",string(b))
27+
panic("BUG")
28+
}
29+
30+
}
31+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp