aboutsummaryrefslogtreecommitdiff
path: root/gcc/go
diff options
context:
space:
mode:
authorCherry Mui <cherryyz@google.com>2021-08-04 18:24:47 -0400
committerIan Lance Taylor <iant@golang.org>2021-08-04 21:24:00 -0700
commitac8a2fbedf59eecda6d1c049952e10946ffc4a61 (patch)
treeef823a4dfd8c8527048853b7f61ec572fa3f4d4a /gcc/go
parentc16f21c7cf97ce48967e42d3b5d22ea169a9c2c8 (diff)
downloadgcc-ac8a2fbedf59eecda6d1c049952e10946ffc4a61.zip
gcc-ac8a2fbedf59eecda6d1c049952e10946ffc4a61.tar.gz
gcc-ac8a2fbedf59eecda6d1c049952e10946ffc4a61.tar.bz2
compiler: make escape analysis more robust about builtin functions
In the places where we handle builtin functions, list all supported ones, and fail if an unexpected one is seen. So if a new builtin function is added in the future we can detect it, instead of silently treating it as nonescaping. Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/339992
Diffstat (limited to 'gcc/go')
-rw-r--r--gcc/go/gofrontend/MERGE2
-rw-r--r--gcc/go/gofrontend/escape.cc56
2 files changed, 55 insertions, 3 deletions
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index be1a90f..394530c 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -1,4 +1,4 @@
-616ee658a6238e7de53592ebda5997f6de6a00de
+b47bcf942daa9a0c252db9b57b8f138adbfcdaa2
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/escape.cc b/gcc/go/gofrontend/escape.cc
index 347ac25..c8978ac 100644
--- a/gcc/go/gofrontend/escape.cc
+++ b/gcc/go/gofrontend/escape.cc
@@ -1608,8 +1608,33 @@ Escape_analysis_assign::expression(Expression** pexpr)
}
break;
- default:
+ case Builtin_call_expression::BUILTIN_CLOSE:
+ case Builtin_call_expression::BUILTIN_DELETE:
+ case Builtin_call_expression::BUILTIN_PRINT:
+ case Builtin_call_expression::BUILTIN_PRINTLN:
+ case Builtin_call_expression::BUILTIN_LEN:
+ case Builtin_call_expression::BUILTIN_CAP:
+ case Builtin_call_expression::BUILTIN_COMPLEX:
+ case Builtin_call_expression::BUILTIN_REAL:
+ case Builtin_call_expression::BUILTIN_IMAG:
+ case Builtin_call_expression::BUILTIN_RECOVER:
+ case Builtin_call_expression::BUILTIN_ALIGNOF:
+ case Builtin_call_expression::BUILTIN_OFFSETOF:
+ case Builtin_call_expression::BUILTIN_SIZEOF:
+ // these do not escape.
+ break;
+
+ case Builtin_call_expression::BUILTIN_ADD:
+ case Builtin_call_expression::BUILTIN_SLICE:
+ // handled in ::assign.
break;
+
+ case Builtin_call_expression::BUILTIN_MAKE:
+ case Builtin_call_expression::BUILTIN_NEW:
+ // should have been lowered to runtime calls at this point.
+ // fallthrough
+ default:
+ go_unreachable();
}
break;
}
@@ -2372,8 +2397,35 @@ Escape_analysis_assign::assign(Node* dst, Node* src)
}
break;
- default:
+ case Builtin_call_expression::BUILTIN_LEN:
+ case Builtin_call_expression::BUILTIN_CAP:
+ case Builtin_call_expression::BUILTIN_COMPLEX:
+ case Builtin_call_expression::BUILTIN_REAL:
+ case Builtin_call_expression::BUILTIN_IMAG:
+ case Builtin_call_expression::BUILTIN_RECOVER:
+ case Builtin_call_expression::BUILTIN_ALIGNOF:
+ case Builtin_call_expression::BUILTIN_OFFSETOF:
+ case Builtin_call_expression::BUILTIN_SIZEOF:
+ // these do not escape.
+ break;
+
+ case Builtin_call_expression::BUILTIN_COPY:
+ // handled in ::expression.
break;
+
+ case Builtin_call_expression::BUILTIN_CLOSE:
+ case Builtin_call_expression::BUILTIN_DELETE:
+ case Builtin_call_expression::BUILTIN_PRINT:
+ case Builtin_call_expression::BUILTIN_PRINTLN:
+ case Builtin_call_expression::BUILTIN_PANIC:
+ // these do not have result.
+ // fallthrough
+ case Builtin_call_expression::BUILTIN_MAKE:
+ case Builtin_call_expression::BUILTIN_NEW:
+ // should have been lowered to runtime calls at this point.
+ // fallthrough
+ default:
+ go_unreachable();
}
break;
}