From: Matthias Braun Date: Wed, 3 Feb 2010 20:03:00 +0000 (+0000) Subject: fix some assertions; correctly handle weak symbols X-Git-Url: http://nsz.repo.hu/git/?a=commitdiff_plain;h=c27a52c764aebf4888d31984550634b76c409fc7;p=libfirm fix some assertions; correctly handle weak symbols [r27031] --- diff --git a/include/libfirm/firm_types.h b/include/libfirm/firm_types.h index e79266194..212fe2b98 100644 --- a/include/libfirm/firm_types.h +++ b/include/libfirm/firm_types.h @@ -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; diff --git a/ir/ir/irdumptxt.c b/ir/ir/irdumptxt.c index e36235260..2e1aa4df8 100644 --- a/ir/ir/irdumptxt.c +++ b/ir/ir/irdumptxt.c @@ -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); diff --git a/ir/opt/opt_inline.c b/ir/opt/opt_inline.c index a86020d65..c868be6d9 100644 --- a/ir/opt/opt_inline.c +++ b/ir/opt/opt_inline.c @@ -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; diff --git a/ir/opt/proc_cloning.c b/ir/opt/proc_cloning.c index ff0cf07d7..ca1d0341c 100644 --- a/ir/opt/proc_cloning.c +++ b/ir/opt/proc_cloning.c @@ -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); diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 9fb13a1b6..2af1a032e 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -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) diff --git a/ir/tr/type.c b/ir/tr/type.c index 0c29b4ede..d9c51263e 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -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: