+/**
+ * Create the location data for the given debug info.
+ */
+static void create_location_data(dbg_info *dbg, block_id_walker_data_t *wd)
+{
+ unsigned lineno;
+ const char *fname = be_retrieve_dbg_info(dbg, &lineno);
+
+ if (fname) {
+ pmap_entry *entry = pmap_find(wd->fname_map, (void *)fname);
+ ir_entity *ent;
+
+ if (! entry) {
+ static unsigned nr = 0;
+ ident *id;
+ char buf[128];
+ ir_type *arr;
+ int i, len = strlen(fname) + 1;
+ tarval **tarval_string;
+
+ snprintf(buf, sizeof(buf), "firm_name_arr.%d", nr);
+ arr = new_type_array(new_id_from_str(buf), 1, wd->tp_char);
+ set_array_bounds_int(arr, 0, 0, len);
+
+ snprintf(buf, sizeof(buf), "__firm_name.%d", nr++);
+ id = new_id_from_str(buf);
+ ent = new_entity(get_glob_type(), id, arr);
+ set_entity_ld_ident(ent, id);
+
+ pmap_insert(wd->fname_map, (void *)fname, ent);
+
+ /* initialize file name string constant */
+ tarval_string = alloca(sizeof(*tarval_string) * (len));
+ for (i = 0; i < len; ++i) {
+ tarval_string[i] = new_tarval_from_long(fname[i], mode_Bs);
+ }
+ set_entity_variability(ent, variability_constant);
+ set_array_entity_values(ent, tarval_string, len);
+ } else {
+ ent = entry->value;
+ }
+ wd->locs[wd->id].fname = ent;
+ wd->locs[wd->id].lineno = lineno;
+ } else {
+ wd->locs[wd->id].fname = NULL;
+ wd->locs[wd->id].lineno = 0;
+ }
+}
+
+/**
+ * Walker: assigns an ID to every block.
+ * Builds the string table
+ */