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
260f587c
Commit
260f587c
authored
Feb 01, 2013
by
Ian Lance Taylor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiler: Don't emit multiple methods for identical unnamed structs.
From-SVN: r195638
parent
04176553
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
0 deletions
+26
-0
gcc/go/gofrontend/types.cc
+20
-0
gcc/go/gofrontend/types.h
+6
-0
No files found.
gcc/go/gofrontend/types.cc
View file @
260f587c
...
@@ -4170,6 +4170,11 @@ Struct_field::is_field_name(const std::string& name) const
...
@@ -4170,6 +4170,11 @@ Struct_field::is_field_name(const std::string& name) const
// Class Struct_type.
// Class Struct_type.
// A hash table used to find identical unnamed structs so that they
// share method tables.
Struct_type
::
Identical_structs
Struct_type
::
identical_structs
;
// Traversal.
// Traversal.
int
int
...
@@ -4596,6 +4601,21 @@ Struct_type::finalize_methods(Gogo* gogo)
...
@@ -4596,6 +4601,21 @@ Struct_type::finalize_methods(Gogo* gogo)
{
{
if
(
this
->
all_methods_
!=
NULL
)
if
(
this
->
all_methods_
!=
NULL
)
return
;
return
;
// It is possible to have multiple identical structs that have
// methods. We want them to share method tables. Otherwise we will
// emit identical methods more than once, which is bad since they
// will even have the same names.
std
::
pair
<
Identical_structs
::
iterator
,
bool
>
ins
=
Struct_type
::
identical_structs
.
insert
(
std
::
make_pair
(
this
,
this
));
if
(
!
ins
.
second
)
{
// An identical struct was already entered into the hash table.
// Note that finalize_methods is, fortunately, not recursive.
this
->
all_methods_
=
ins
.
first
->
second
->
all_methods_
;
return
;
}
Type
::
finalize_methods
(
gogo
,
this
,
this
->
location_
,
&
this
->
all_methods_
);
Type
::
finalize_methods
(
gogo
,
this
,
this
->
location_
,
&
this
->
all_methods_
);
}
}
...
...
gcc/go/gofrontend/types.h
View file @
260f587c
...
@@ -2184,6 +2184,12 @@ class Struct_type : public Type
...
@@ -2184,6 +2184,12 @@ class Struct_type : public Type
do_export
(
Export
*
)
const
;
do_export
(
Export
*
)
const
;
private
:
private
:
// Used to merge method sets of identical unnamed structs.
typedef
Unordered_map_hash
(
Struct_type
*
,
Struct_type
*
,
Type_hash_identical
,
Type_identical
)
Identical_structs
;
static
Identical_structs
identical_structs
;
// Used to avoid infinite loops in field_reference_depth.
// Used to avoid infinite loops in field_reference_depth.
struct
Saw_named_type
struct
Saw_named_type
{
{
...
...
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