Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
riscv-gcc-1
Commits
6a2cd809
Commit
6a2cd809
authored
Dec 23, 2014
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Evaluate array range expression once before iteration.
Fixes issue 34. From-SVN: r219045
parent
34b42fb0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
2 deletions
+5
-2
gcc/go/gofrontend/statements.cc
+5
-2
No files found.
gcc/go/gofrontend/statements.cc
View file @
6a2cd809
...
...
@@ -5558,8 +5558,9 @@ For_range_statement::lower_range_array(Gogo* gogo,
// The loop we generate:
// len_temp := len(range)
// range_temp := range
// for index_temp = 0; index_temp < len_temp; index_temp++ {
// value_temp = range[index_temp]
// value_temp = range
_temp
[index_temp]
// index = index_temp
// value = value_temp
// original body
...
...
@@ -5573,9 +5574,11 @@ For_range_statement::lower_range_array(Gogo* gogo,
Block
*
init
=
new
Block
(
enclosing
,
loc
);
Expression
*
ref
=
this
->
make_range_ref
(
range_object
,
range_temp
,
loc
);
range_temp
=
Statement
::
make_temporary
(
NULL
,
ref
,
loc
);
Expression
*
len_call
=
this
->
call_builtin
(
gogo
,
"len"
,
ref
,
loc
);
Temporary_statement
*
len_temp
=
Statement
::
make_temporary
(
index_temp
->
type
(),
len_call
,
loc
);
init
->
add_statement
(
range_temp
);
init
->
add_statement
(
len_temp
);
Expression
*
zexpr
=
Expression
::
make_integer_ul
(
0
,
NULL
,
loc
);
...
...
@@ -5605,7 +5608,7 @@ For_range_statement::lower_range_array(Gogo* gogo,
{
iter_init
=
new
Block
(
body_block
,
loc
);
ref
=
this
->
make_range_ref
(
range_object
,
range_temp
,
loc
);
ref
=
Expression
::
make_temporary_reference
(
range_temp
,
loc
);
Expression
*
ref2
=
Expression
::
make_temporary_reference
(
index_temp
,
loc
);
Expression
*
index
=
Expression
::
make_index
(
ref
,
ref2
,
NULL
,
NULL
,
loc
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment