aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-07-14 14:09:06 +0100
committerPhilip Herron <philip.herron@embecosm.com>2022-07-14 14:11:21 +0100
commit4b82481d850a35765919cf5c91e7e063d9bceb29 (patch)
tree8cfe709a96e17ccb6a51653a3b0584975c3ca564 /gcc
parentab9f7f287ef0a775ac6a504d743e20c2f5488f6f (diff)
downloadgcc-4b82481d850a35765919cf5c91e7e063d9bceb29.zip
gcc-4b82481d850a35765919cf5c91e7e063d9bceb29.tar.gz
gcc-4b82481d850a35765919cf5c91e7e063d9bceb29.tar.bz2
Support aggregate types in transmute
In some testcases in libcore transmute is used on aggregate types like array's. The convert expression code assumes simple integer's. This this patch uses a gimple convert_expr to try and convert this type. This might change to a generic memcpy at somepoint but lets try this first and see how it works.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/rust/backend/rust-compile-intrinsic.cc16
1 files changed, 13 insertions, 3 deletions
diff --git a/gcc/rust/backend/rust-compile-intrinsic.cc b/gcc/rust/backend/rust-compile-intrinsic.cc
index 57a952f..65eddfa 100644
--- a/gcc/rust/backend/rust-compile-intrinsic.cc
+++ b/gcc/rust/backend/rust-compile-intrinsic.cc
@@ -542,9 +542,19 @@ transmute_intrinsic_handler (Context *ctx, TyTy::BaseType *fntype_tyty)
// BUILTIN transmute FN BODY BEGIN
tree result_type_tree = TREE_TYPE (DECL_RESULT (fndecl));
- tree result_expr
- = ctx->get_backend ()->convert_expression (result_type_tree,
- convert_me_expr, Location ());
+ tree result_expr = error_mark_node;
+ if (AGGREGATE_TYPE_P (TREE_TYPE (convert_me_expr)))
+ {
+ result_expr = fold_build1_loc (Location ().gcc_location (), CONVERT_EXPR,
+ result_type_tree, convert_me_expr);
+ }
+ else
+ {
+ result_expr = ctx->get_backend ()->convert_expression (result_type_tree,
+ convert_me_expr,
+ Location ());
+ }
+
auto return_statement
= ctx->get_backend ()->return_statement (fndecl, {result_expr},
Location ());