#include "xmalloc.h"
#include "irtools.h"
#include "iroptimize.h"
+#include "instrument.h"
#include "../beabi.h"
#include "../beirg_t.h"
* |___/
**************************************************/
+static ir_entity *mcount = NULL;
+
+#define ID(s) new_id_from_chars(s, sizeof(s) - 1)
+
static void ia32_before_abi(void *self) {
lower_mode_b_config_t lower_mode_b_config = {
mode_Iu, /* lowered mode */
ir_lower_mode_b(cg->irg, &lower_mode_b_config);
if (cg->dump)
be_dump(cg->irg, "-lower_modeb", dump_ir_block_graph_sched);
- if (cg->gprof)
- instrument_initcall(cg->irg);
+ if (cg->gprof) {
+ if (mcount == NULL) {
+ ir_type *tp = new_type_method(ID("FKT.mcount"), 0, 0);
+ mcount = new_entity(get_glob_type(), ID("mcount"), tp);
+ /* FIXME: enter the right ld_ident here */
+ set_entity_ld_ident(mcount, get_entity_ident(mcount));
+ set_entity_visibility(mcount, visibility_external_allocated);
+ }
+ instrument_initcall(cg->irg, mcount);
+ }
}
/**
cg->dump = (birg->main_env->options->dump_flags & DUMP_BE) ? 1 : 0;
cg->gprof = (birg->main_env->options->gprof) ? 1 : 0;
+ if (cg->gprof) {
+ /* Linux gprof implementation needs base pointer */
+ birg->main_env->options->omit_fp = 0;
+ }
+
/* enter it */
isa->cg = cg;