Commit c27a52c7 authored by Matthias Braun's avatar Matthias Braun
Browse files

fix some assertions; correctly handle weak symbols

[r27031]
parent 2bc2dd4b
......@@ -133,16 +133,14 @@ typedef enum {
GCC: __attribute__((naked)). */
mtp_property_malloc = 0x00000020, /**< This method returns newly allocate memory.
GCC: __attribute__((malloc)). */
mtp_property_weak = 0x00000040, /**< This method is weak. It is expected that
GCC: __attribute__((weak)). */
mtp_property_returns_twice = 0x00000080, /**< This method can return more than one (typically setjmp).
mtp_property_returns_twice = 0x00000040, /**< This method can return more than one (typically setjmp).
GCC: __attribute__((returns_twice)). */
mtp_property_intrinsic = 0x00000100, /**< This method is intrinsic. It is expected that
mtp_property_intrinsic = 0x00000080, /**< This method is intrinsic. It is expected that
a lowering phase will remove all calls to it. */
mtp_property_runtime = 0x00000200, /**< This method represents a runtime routine. */
mtp_property_private = 0x00000400, /**< All method invocations are known, the backend is free to
mtp_property_runtime = 0x00000100, /**< This method represents a runtime routine. */
mtp_property_private = 0x00000200, /**< All method invocations are known, the backend is free to
optimize the call in any possible way. */
mtp_property_has_loop = 0x00000800, /**< Set, if this method contains one possible endless loop. */
mtp_property_has_loop = 0x00000400, /**< Set, if this method contains one possible endless loop. */
mtp_property_inherited = (1<<31) /**< Internal. Used only in irg's, means property is
inherited from type. */
} mtp_additional_property;
......
......@@ -715,7 +715,6 @@ void dump_entity_to_file_prefix(FILE *F, ir_entity *ent, char *prefix, unsigned
if (mask & mtp_property_nothrow) fputs("nothrow_function, ", F);
if (mask & mtp_property_naked) fputs("naked_function, ", F);
if (mask & mtp_property_malloc) fputs("malloc_function, ", F);
if (mask & mtp_property_weak) fputs("weak_function, ", F);
if (mask & mtp_property_returns_twice) fputs("weak_function, ", F);
if (mask & mtp_property_intrinsic) fputs("intrinsic_function, ", F);
if (mask & mtp_property_runtime) fputs("runtime_function, ", F);
......
......@@ -1285,12 +1285,17 @@ typedef struct _inline_env_t {
*
* @param call the call node
*/
static ir_graph *get_call_called_irg(ir_node *call) {
static ir_graph *get_call_called_irg(ir_node *call)
{
ir_node *addr;
addr = get_Call_ptr(call);
if (is_Global(addr)) {
ir_entity *ent = get_Global_entity(addr);
/* we don't know which function gets finally bound to a weak symbol */
if (get_entity_linkage(ent) & IR_LINKAGE_WEAK)
return NULL;
return get_entity_irg(ent);
}
......@@ -1357,8 +1362,7 @@ void inline_small_irgs(ir_graph *irg, int size) {
ir_graph *callee = entry->callee;
irg_inline_property prop = get_irg_inline_property(callee);
if (prop == irg_inline_forbidden || get_irg_additional_properties(callee) & mtp_property_weak) {
/* do not inline forbidden / weak graphs */
if (prop == irg_inline_forbidden) {
continue;
}
......@@ -1636,8 +1640,7 @@ void inline_leave_functions(unsigned maxsize, unsigned leavesize,
callee = entry->callee;
prop = get_irg_inline_property(callee);
if (prop == irg_inline_forbidden || get_irg_additional_properties(callee) & mtp_property_weak) {
/* do not inline forbidden / weak graphs */
if (prop == irg_inline_forbidden) {
continue;
}
......@@ -1691,8 +1694,7 @@ void inline_leave_functions(unsigned maxsize, unsigned leavesize,
callee = entry->callee;
prop = get_irg_inline_property(callee);
if (prop == irg_inline_forbidden || get_irg_additional_properties(callee) & mtp_property_weak) {
/* do not inline forbidden / weak graphs */
if (prop == irg_inline_forbidden) {
continue;
}
......@@ -1995,7 +1997,7 @@ static int calc_inline_benefice(call_entry *entry, ir_graph *callee)
return entry->benefice = INT_MIN;
}
if (get_irg_additional_properties(callee) & (mtp_property_noreturn | mtp_property_weak)) {
if (get_irg_additional_properties(callee) & mtp_property_noreturn) {
DB((dbg, LEVEL_2, "In %+F Call to %+F: not inlining noreturn or weak\n",
call, callee));
return entry->benefice = INT_MIN;
......
......@@ -187,12 +187,12 @@ static void collect_irg_calls(ir_node *call, void *env) {
callee = get_Global_entity(call_ptr);
/* we can only clone calls to existing entities */
if (get_entity_irg(callee) == NULL)
/* we don't know which function gets finally bound to a weak symbol */
if (get_entity_linkage(callee) & IR_LINKAGE_WEAK)
return;
/* we cannot clone calls to weak functions */
if (get_entity_additional_properties(callee) & mtp_property_weak)
/* we can only clone calls to existing entities */
if (get_entity_irg(callee) == NULL)
return;
process_call(call, callee, hmap);
......
......@@ -440,7 +440,10 @@ static void verify_linkage(ir_entity *entity)
/* local and extern are mutually exclusive */
(void) linkage;
assert(! ((linkage & IR_LINKAGE_EXTERN) && (linkage & IR_LINKAGE_LOCAL)));
assert(! (linkage & IR_LINKAGE_EXTERN) || !entity_has_definition(entity));
if (!is_method_entity(entity) && (linkage & IR_LINKAGE_EXTERN)) {
assert(!entity_has_definition(entity));
}
assert(! ((linkage & IR_LINKAGE_CONSTANT) && (linkage & IR_LINKAGE_WEAK)));
}
void set_entity_linkage(ir_entity *entity, ir_linkage linkage)
......
......@@ -365,7 +365,6 @@ void set_type_state(ir_type *tp, ir_type_state state)
case tpo_struct:
for (i = 0; i < get_struct_n_members(tp); i++) {
assert(get_entity_offset(get_struct_member(tp, i)) > -1);
assert((get_entity_allocation(get_struct_member(tp, i)) == allocation_automatic));
}
break;
case tpo_union:
......
Supports Markdown
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