Commit 14108eda by Pekka Jääskeläinen

[BRIGFE] Support BRIG_KIND_NONE directives.

These directives are legal everywhere.  They can be used to
patch away BRIG entries at the binary level.

Also add extra error detection for zeroed regions: make sure
the byteCount field is never zero.

The call code still failed a few PRM test cases. Now all PRM
branch cases pass again.

From-SVN: r253545
parent 63eea5dc
2017-10-09 Pekka Jääskeläinen <pekka.jaaskelainen@parmance.com>
* brigfrontend/brig-to-generic.cc: Support BRIG_KIND_NONE
directives. These directives are legal everywhere. They
can be used to patch away BRIG entries at the binary level.
Also add extra error detection for zeroed regions: make sure
the byteCount field is never zero.
* brig/brigfrontend/phsa.h: Added a new error prefix for
errors which are due to corrupted BRIG modules.
2017-10-09 Henry Linjamäki <henry.linjamaki@parmance.com>
* brigfrontend/brig-branch-inst-handler.cc: The call code
still failed a few test cases. Now all PRM cases pass again.
2017-10-03 Henry Linjamäki <henry.linjamaki@parmance.com> 2017-10-03 Henry Linjamäki <henry.linjamaki@parmance.com>
* brigfrontend/brig-branch-inst-handler.cc: Fix (more) crash with * brigfrontend/brig-branch-inst-handler.cc: Fix (more) crash with
......
...@@ -70,7 +70,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) ...@@ -70,7 +70,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base)
const BrigOperandOffset32_t *operand_ptr const BrigOperandOffset32_t *operand_ptr
= (const BrigOperandOffset32_t *) data->bytes; = (const BrigOperandOffset32_t *) data->bytes;
vec<tree, va_gc> *&args = i == 0 ? out_args : in_args; bool out_args_p = i == 0;
while (bytes > 0) while (bytes > 0)
{ {
...@@ -85,7 +85,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) ...@@ -85,7 +85,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base)
if (brig_var->type & BRIG_TYPE_ARRAY) if (brig_var->type & BRIG_TYPE_ARRAY)
{ {
/* Array return values are passed as the first argument. */ /* Array return values are passed as the first argument. */
args = in_args; out_args_p = false;
/* Pass pointer to the element zero and use its element zero /* Pass pointer to the element zero and use its element zero
as the base address. */ as the base address. */
tree etype = TREE_TYPE (TREE_TYPE (var)); tree etype = TREE_TYPE (TREE_TYPE (var));
...@@ -97,8 +97,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base) ...@@ -97,8 +97,7 @@ brig_branch_inst_handler::operator () (const BrigBase *base)
} }
gcc_assert (var != NULL_TREE); gcc_assert (var != NULL_TREE);
vec_safe_reserve (args, 1); vec_safe_push (out_args_p ? out_args : in_args, var);
vec_safe_push (args, var);
++operand_ptr; ++operand_ptr;
bytes -= 4; bytes -= 4;
} }
......
...@@ -248,7 +248,12 @@ brig_to_generic::analyze (const char *brig_blob) ...@@ -248,7 +248,12 @@ brig_to_generic::analyze (const char *brig_blob)
if (handlers[i].kind == entry->kind) if (handlers[i].kind == entry->kind)
handler = handlers[i].handler; handler = handlers[i].handler;
} }
b += (*handler) (entry);
int bytes_processed = (*handler) (entry);
if (bytes_processed == 0)
fatal_error (UNKNOWN_LOCATION, PHSA_ERROR_PREFIX_CORRUPTED_MODULE
"Element with 0 bytes.");
b += bytes_processed;
} }
if (m_cf != NULL) if (m_cf != NULL)
...@@ -335,7 +340,10 @@ brig_to_generic::parse (const char *brig_blob) ...@@ -335,7 +340,10 @@ brig_to_generic::parse (const char *brig_blob)
/* There are no supported pragmas at this moment. */ /* There are no supported pragmas at this moment. */
{BRIG_KIND_DIRECTIVE_PRAGMA, &skipped_handler}, {BRIG_KIND_DIRECTIVE_PRAGMA, &skipped_handler},
{BRIG_KIND_DIRECTIVE_CONTROL, &control_handler}, {BRIG_KIND_DIRECTIVE_CONTROL, &control_handler},
{BRIG_KIND_DIRECTIVE_EXTENSION, &skipped_handler}}; {BRIG_KIND_DIRECTIVE_EXTENSION, &skipped_handler},
/* BRIG_KIND_NONE entries are valid anywhere. They can be used
for patching BRIGs before finalization. */
{BRIG_KIND_NONE, &skipped_handler}};
const BrigSectionHeader *csection_header = (const BrigSectionHeader *) m_code; const BrigSectionHeader *csection_header = (const BrigSectionHeader *) m_code;
......
...@@ -61,9 +61,10 @@ typedef struct __attribute__((__packed__)) ...@@ -61,9 +61,10 @@ typedef struct __attribute__((__packed__))
#define PHSA_DESC_SECTION_PREFIX "phsa.desc." #define PHSA_DESC_SECTION_PREFIX "phsa.desc."
#define PHSA_HOST_DEF_PTR_PREFIX "__phsa.host_def." #define PHSA_HOST_DEF_PTR_PREFIX "__phsa.host_def."
/* The frontend error messages are parsed by the host runtime, known /* The frontend error messages are parsed by the host runtime. Known
prefix strings are used to separate the different runtime error prefix strings are used to separate the different runtime error
codes. */ codes. */
#define PHSA_ERROR_PREFIX_INCOMPATIBLE_MODULE "Incompatible module:" #define PHSA_ERROR_PREFIX_INCOMPATIBLE_MODULE "Incompatible module: "
#define PHSA_ERROR_PREFIX_CORRUPTED_MODULE "Corrupted module: "
#endif #endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment