aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Chigot <clement.chigot@atos.net>2020-09-16 14:03:10 +0200
committerIan Lance Taylor <iant@golang.org>2020-09-22 10:24:07 -0700
commit30bf947649e7381402637d1434d6b1ef22d031f1 (patch)
tree2403b6e131a5985677735a0797fd12782a1bdc14
parentf74c87f85f510248874cb90ad0b0527b015034b9 (diff)
downloadgcc-30bf947649e7381402637d1434d6b1ef22d031f1.zip
gcc-30bf947649e7381402637d1434d6b1ef22d031f1.tar.gz
gcc-30bf947649e7381402637d1434d6b1ef22d031f1.tar.bz2
compiler: call runtime.eqtype for non-interface type switch on aix
All type switch clauses must call runtime.eqtype if the linker isn't able to merge type descriptors pointers. Previously, only interface-type clauses were doing it. Updates golang/go#39276 Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/255202
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/statements.cc27
-rw-r--r--gcc/go/gofrontend/statements.h4
3 files changed, 21 insertions, 12 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index e4f8fac..a8ba5a3 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-a59167c29d6ad2ddf533b3a12b365f72df0e1476
+b24062f0b2e8f6173731d5654afe0addf857270e
The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index a059ee4..ad89807 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -4627,7 +4627,8 @@ Type_case_clauses::Type_case_clause::traverse(Traverse* traverse)
// statements.
void
-Type_case_clauses::Type_case_clause::lower(Type* switch_val_type,
+Type_case_clauses::Type_case_clause::lower(Gogo* gogo,
+ Type* switch_val_type,
Block* b,
Temporary_statement* descriptor_temp,
Unnamed_label* break_label,
@@ -4666,9 +4667,16 @@ Type_case_clauses::Type_case_clause::lower(Type* switch_val_type,
Expression::make_nil(loc),
loc);
else if (type->interface_type() == NULL)
- cond = Expression::make_binary(OPERATOR_EQEQ, ref,
- Expression::make_type_descriptor(type, loc),
- loc);
+ {
+ if (!gogo->need_eqtype())
+ cond = Expression::make_binary(OPERATOR_EQEQ, ref,
+ Expression::make_type_descriptor(type, loc),
+ loc);
+ else
+ cond = Runtime::make_call(Runtime::EQTYPE, loc, 2,
+ Expression::make_type_descriptor(type, loc),
+ ref);
+ }
else
cond = Runtime::make_call(Runtime::IFACET2IP, loc, 2,
Expression::make_type_descriptor(type, loc),
@@ -4826,7 +4834,8 @@ Type_case_clauses::check_duplicates() const
// BREAK_LABEL is the label at the end of the type switch.
void
-Type_case_clauses::lower(Type* switch_val_type, Block* b,
+Type_case_clauses::lower(Gogo* gogo, Type* switch_val_type,
+ Block* b,
Temporary_statement* descriptor_temp,
Unnamed_label* break_label) const
{
@@ -4838,7 +4847,7 @@ Type_case_clauses::lower(Type* switch_val_type, Block* b,
++p)
{
if (!p->is_default())
- p->lower(switch_val_type, b, descriptor_temp, break_label,
+ p->lower(gogo, switch_val_type, b, descriptor_temp, break_label,
&stmts_label);
else
{
@@ -4850,7 +4859,7 @@ Type_case_clauses::lower(Type* switch_val_type, Block* b,
go_assert(stmts_label == NULL);
if (default_case != NULL)
- default_case->lower(switch_val_type, b, descriptor_temp, break_label,
+ default_case->lower(gogo, switch_val_type, b, descriptor_temp, break_label,
NULL);
}
@@ -4905,7 +4914,7 @@ Type_switch_statement::do_traverse(Traverse* traverse)
// equality testing.
Statement*
-Type_switch_statement::do_lower(Gogo*, Named_object*, Block* enclosing,
+Type_switch_statement::do_lower(Gogo* gogo, Named_object*, Block* enclosing,
Statement_inserter*)
{
const Location loc = this->location();
@@ -4943,7 +4952,7 @@ Type_switch_statement::do_lower(Gogo*, Named_object*, Block* enclosing,
b->add_statement(s);
if (this->clauses_ != NULL)
- this->clauses_->lower(val_type, b, descriptor_temp, this->break_label());
+ this->clauses_->lower(gogo, val_type, b, descriptor_temp, this->break_label());
s = Statement::make_unnamed_label_statement(this->break_label_);
b->add_statement(s);
diff --git a/gcc/go/gofrontend/statements.h b/gcc/go/gofrontend/statements.h
index f1c6be9..47092b4 100644
--- a/gcc/go/gofrontend/statements.h
+++ b/gcc/go/gofrontend/statements.h
@@ -2089,7 +2089,7 @@ class Type_case_clauses
// Lower to if and goto statements.
void
- lower(Type*, Block*, Temporary_statement* descriptor_temp,
+ lower(Gogo*, Type*, Block*, Temporary_statement* descriptor_temp,
Unnamed_label* break_label) const;
// Return true if these clauses may fall through to the statements
@@ -2138,7 +2138,7 @@ class Type_case_clauses
// Lower to if and goto statements.
void
- lower(Type*, Block*, Temporary_statement* descriptor_temp,
+ lower(Gogo*, Type*, Block*, Temporary_statement* descriptor_temp,
Unnamed_label* break_label, Unnamed_label** stmts_label) const;
// Return true if this clause may fall through to execute the