From e1e299f3356d1977e33d7c654a8f5f49d5a0446a Mon Sep 17 00:00:00 2001 From: =?utf8?q?Henry=20Linjam=C3=A4ki?= Date: Fri, 29 Sep 2017 16:57:18 +0000 Subject: [PATCH] [BRIGFE] Fix crash with calls with more than 4 args. Also fix a misexecution issue with kernels that have both unexpanded ID functions and calls to subfunctions. From-SVN: r253298 --- gcc/brig/ChangeLog | 7 +++++++ gcc/brig/brigfrontend/brig-branch-inst-handler.cc | 6 ++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/gcc/brig/ChangeLog b/gcc/brig/ChangeLog index fb2b09d70e4..c66b16fba98 100644 --- a/gcc/brig/ChangeLog +++ b/gcc/brig/ChangeLog @@ -1,3 +1,10 @@ +2017-09-29 Henry Linjamäki + + * brigfrontend/brig-branch-inst-handler.cc: Fix crash with + calls with more than 4 args. Also fix a misexecution issue + with kernels that have both unexpanded ID functions and + calls to subfunctions. + 2017-09-28 Henry Linjamäki * brig-lang.c: Added function attributes and their handlers. diff --git a/gcc/brig/brigfrontend/brig-branch-inst-handler.cc b/gcc/brig/brigfrontend/brig-branch-inst-handler.cc index c8912dbccd7..a32dd996044 100644 --- a/gcc/brig/brigfrontend/brig-branch-inst-handler.cc +++ b/gcc/brig/brigfrontend/brig-branch-inst-handler.cc @@ -42,7 +42,8 @@ brig_branch_inst_handler::operator () (const BrigBase *base) vec *out_args; vec_alloc (out_args, 1); vec *in_args; - vec_alloc (in_args, 4); + /* Ten elem initially, more reserved if needed. */ + vec_alloc (in_args, 10); size_t operand_count = operand_entries->byteCount / 4; gcc_assert (operand_count < 4); @@ -96,6 +97,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) } gcc_assert (var != NULL_TREE); + vec_safe_reserve (args, 1); vec_safe_push (args, var); ++operand_ptr; bytes -= 4; @@ -125,6 +127,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) /* TODO: ensure the callee's frame is aligned! */ + vec_safe_reserve (in_args, 4); vec_safe_push (in_args, m_parent.m_cf->m_context_arg); vec_safe_push (in_args, m_parent.m_cf->m_group_base_arg); vec_safe_push (in_args, group_local_offset); @@ -147,7 +150,6 @@ brig_branch_inst_handler::operator () (const BrigBase *base) m_parent.m_cf->append_statement (call); } - m_parent.m_cf->m_has_unexpanded_dp_builtins = false; m_parent.m_cf->m_called_functions.push_back (func_ref); return base->byteCount; -- 2.30.2