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
01c59996
Commit
01c59996
authored
Jan 26, 2011
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Copy initializer to heap if it may contain pointers.
From-SVN: r169297
parent
e435f098
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
10 deletions
+17
-10
gcc/go/gofrontend/expressions.cc
+17
-10
No files found.
gcc/go/gofrontend/expressions.cc
View file @
01c59996
...
@@ -11138,7 +11138,15 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
...
@@ -11138,7 +11138,15 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
return
error_mark_node
;
return
error_mark_node
;
bool
is_constant_initializer
=
TREE_CONSTANT
(
values
);
bool
is_constant_initializer
=
TREE_CONSTANT
(
values
);
bool
is_in_function
=
context
->
function
()
!=
NULL
;
// We have to copy the initial values into heap memory if we are in
// a function or if the values are not constants. We also have to
// copy them if they may contain pointers in a non-constant context,
// as otherwise the garbage collector won't see them.
bool
copy_to_heap
=
(
context
->
function
()
!=
NULL
||
!
is_constant_initializer
||
(
element_type
->
has_pointer
()
&&
!
context
->
is_const
()));
if
(
is_constant_initializer
)
if
(
is_constant_initializer
)
{
{
...
@@ -11148,12 +11156,12 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
...
@@ -11148,12 +11156,12 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
TREE_PUBLIC
(
tmp
)
=
0
;
TREE_PUBLIC
(
tmp
)
=
0
;
TREE_STATIC
(
tmp
)
=
1
;
TREE_STATIC
(
tmp
)
=
1
;
DECL_ARTIFICIAL
(
tmp
)
=
1
;
DECL_ARTIFICIAL
(
tmp
)
=
1
;
if
(
is_in_function
)
if
(
copy_to_heap
)
{
{
// If
this is not a function, we will only initialize the
// If
we are not copying the value to the heap, we will only
//
value once, so we can use this directly rather than
//
initialize the value once, so we can use this directly
//
copying it. In that case we can't make it read-only,
//
rather than copying it. In that case we can't make it
// because the program is permitted to change it.
//
read-only,
because the program is permitted to change it.
TREE_READONLY
(
tmp
)
=
1
;
TREE_READONLY
(
tmp
)
=
1
;
TREE_CONSTANT
(
tmp
)
=
1
;
TREE_CONSTANT
(
tmp
)
=
1
;
}
}
...
@@ -11164,10 +11172,9 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
...
@@ -11164,10 +11172,9 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
tree
space
;
tree
space
;
tree
set
;
tree
set
;
if
(
!
is_in_function
&&
is_constant_initializer
)
if
(
!
copy_to_heap
)
{
{
// Outside of a function, we know the initializer will only run
// the initializer will only run once.
// once.
space
=
build_fold_addr_expr
(
values
);
space
=
build_fold_addr_expr
(
values
);
set
=
NULL_TREE
;
set
=
NULL_TREE
;
}
}
...
@@ -11214,7 +11221,7 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
...
@@ -11214,7 +11221,7 @@ Open_array_construction_expression::do_get_tree(Translate_context* context)
tree
constructor
=
build_constructor
(
type_tree
,
init
);
tree
constructor
=
build_constructor
(
type_tree
,
init
);
if
(
constructor
==
error_mark_node
)
if
(
constructor
==
error_mark_node
)
return
error_mark_node
;
return
error_mark_node
;
if
(
!
is_in_function
&&
is_constant_initializer
)
if
(
!
copy_to_heap
)
TREE_CONSTANT
(
constructor
)
=
1
;
TREE_CONSTANT
(
constructor
)
=
1
;
if
(
set
==
NULL_TREE
)
if
(
set
==
NULL_TREE
)
...
...
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