+2016-03-21 Martin Liska <mliska@suse.cz>
+
+ PR hsa/70234
+ * hsa-brig.c (emit_function_directives): Mark unemitted
+ global variables for emission.
+ * hsa-gen.c (hsa_symbol::hsa_symbol): Initialize a new flag.
+ (get_symbol_for_decl): Likewise.
+ * hsa.h (struct hsa_symbol): New flag.
+
2016-03-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/70288
m_directive_offset (0), m_type (BRIG_TYPE_NONE),
m_segment (BRIG_SEGMENT_NONE), m_linkage (BRIG_LINKAGE_NONE), m_dim (0),
m_cst_value (NULL), m_global_scope_p (false), m_seen_error (false),
- m_allocation (BRIG_ALLOCATION_AUTOMATIC)
+ m_allocation (BRIG_ALLOCATION_AUTOMATIC), m_emitted_to_brig (false)
{
}
m_directive_offset (0), m_type (type), m_segment (segment),
m_linkage (linkage), m_dim (0), m_cst_value (NULL),
m_global_scope_p (global_scope_p), m_seen_error (false),
- m_allocation (allocation)
+ m_allocation (allocation), m_emitted_to_brig (false)
{
}
gcc_checking_assert (slot);
if (*slot)
{
+ hsa_symbol *sym = (*slot);
+
/* If the symbol is problematic, mark current function also as
problematic. */
- if ((*slot)->m_seen_error)
+ if (sym->m_seen_error)
hsa_fail_cfun ();
+ /* PR hsa/70234: If a global variable was marked to be emitted,
+ but HSAIL generation of a function using the variable fails,
+ we should retry to emit the variable in context of a different
+ function.
+
+ Iterate elements whether a symbol is already in m_global_symbols
+ of not. */
+ if (is_in_global_vars && !sym->m_emitted_to_brig)
+ {
+ for (unsigned i = 0; i < hsa_cfun->m_global_symbols.length (); i++)
+ if (hsa_cfun->m_global_symbols[i] == sym)
+ return *slot;
+ hsa_cfun->m_global_symbols.safe_push (sym);
+ }
+
return *slot;
}
else