Commit d43adbf1 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Give be_Relocations debug info.

parent 6f4e50f8
......@@ -31,7 +31,7 @@ libFirm 1.22.1 (2016-01-07)
* api: Remove `get_{class,segment,struct,union}_{ident,name}()`, use `get_compound_{ident,name}()` instead
* ir: Improve IR graph verifier
* arm: Improve address mode use in instruction selection
* ir: Slightly improve preservation of debug info during transformations
* be, ir: Improve preservation of debug info during transformations
* amd64: Improve use of `lea` in instruction selection
* sparc: Support the asm constaint `K`
* sparc: Support computed goto
......
......@@ -35,14 +35,14 @@ static bool is_externally_visible(ir_entity const *const entity)
panic("invalid visibility in %+F", entity);
}
static ir_node *create_gotpcrel_load(ir_graph *irg, ir_entity *const entity)
static ir_node *create_gotpcrel_load(dbg_info *const dbgi, ir_graph *const irg, ir_entity *const entity)
{
ir_node *const addr
= be_new_Relocation(irg, X86_IMM_GOTPCREL, entity, mode_P);
= be_new_Relocation(dbgi, irg, X86_IMM_GOTPCREL, entity, mode_P);
ir_type *const type = get_entity_type(entity);
ir_node *const nomem = get_irg_no_mem(irg);
ir_node *const block = get_irg_start_block(irg);
ir_node *const load = new_rd_Load(NULL, block, nomem, addr, mode_P,
ir_node *const load = new_rd_Load(dbgi, block, nomem, addr, mode_P,
type, cons_floats);
return new_r_Proj(load, mode_P, pn_Load_res);
}
......@@ -57,17 +57,18 @@ static void fix_address_pic_mach_o(ir_node *const node, void *const data)
if (is_tls_entity(entity))
continue;
ir_graph *const irg = get_irn_irg(node);
ir_node * res;
ir_node *res;
dbg_info *const dbgi = get_irn_dbg_info(pred);
ir_graph *const irg = get_irn_irg(node);
if (i == n_Call_ptr && is_Call(node)) {
// Somehow we can always call PC relative. Are there trampolines
// involved?
res = be_new_Relocation(irg, X86_IMM_PCREL, entity, mode_P);
res = be_new_Relocation(dbgi, irg, X86_IMM_PCREL, entity, mode_P);
} else if (entity_has_definition(entity)
&& !(get_entity_linkage(entity) & IR_LINKAGE_MERGE)) {
res = be_new_Relocation(irg, X86_IMM_PCREL, entity, mode_P);
res = be_new_Relocation(dbgi, irg, X86_IMM_PCREL, entity, mode_P);
} else {
res = create_gotpcrel_load(irg, entity);
res = create_gotpcrel_load(dbgi, irg, entity);
}
set_irn_n(node, i, res);
}
......@@ -83,6 +84,7 @@ static void fix_address_pic_elf(ir_node *const node, void *const data)
if (is_tls_entity(entity))
continue;
dbg_info *const dbgi = get_irn_dbg_info(pred);
ir_graph *const irg = get_irn_irg(node);
bool const ext_visible = is_externally_visible(entity);
ir_node * res;
......@@ -91,11 +93,11 @@ static void fix_address_pic_elf(ir_node *const node, void *const data)
* goes through the PLT */
x86_immediate_kind_t const reloc
= ext_visible ? X86_IMM_PLT : X86_IMM_PCREL;
res = be_new_Relocation(irg, reloc, entity, mode_P);
res = be_new_Relocation(dbgi, irg, reloc, entity, mode_P);
} else if (!ext_visible) {
res = be_new_Relocation(irg, X86_IMM_PCREL, entity, mode_P);
res = be_new_Relocation(dbgi, irg, X86_IMM_PCREL, entity, mode_P);
} else {
res = create_gotpcrel_load(irg, entity);
res = create_gotpcrel_load(dbgi, irg, entity);
}
set_irn_n(node, i, res);
}
......
......@@ -469,7 +469,7 @@ static ir_node *gen_Address(ir_node *const node)
return new_bd_amd64_mov_imm(dbgi, block, X86_SIZE_64, &imm);
}
static ir_node *create_picaddr_lea(ir_node *const block,
static ir_node *create_picaddr_lea(dbg_info *const dbgi, ir_node *const block,
x86_immediate_kind_t const kind,
ir_entity *const entity)
{
......@@ -480,11 +480,12 @@ static ir_node *create_picaddr_lea(ir_node *const block,
},
.variant = X86_ADDR_RIP,
};
return new_bd_amd64_lea(NULL, block, 0, NULL, NULL, X86_SIZE_64, addr);
return new_bd_amd64_lea(dbgi, block, 0, NULL, NULL, X86_SIZE_64, addr);
}
static ir_node *gen_be_Relocation(ir_node *const node)
{
dbg_info *const dbgi = get_irn_dbg_info(node);
ir_node *const block = be_transform_nodes_block(node);
ir_entity *const entity = be_get_Relocation_entity(node);
x86_immediate_kind_t const kind
......@@ -496,11 +497,11 @@ static ir_node *gen_be_Relocation(ir_node *const node)
.kind = X86_IMM_ADDR,
.entity = entity,
};
return new_bd_amd64_mov_imm(NULL, block, X86_SIZE_64, &imm);
return new_bd_amd64_mov_imm(dbgi, block, X86_SIZE_64, &imm);
}
case X86_IMM_PCREL:
case X86_IMM_GOTPCREL: /* can GOTPCREL happen here? */
return create_picaddr_lea(block, kind, entity);
return create_picaddr_lea(dbgi, block, kind, entity);
default:
break;
}
......@@ -1547,7 +1548,7 @@ static ir_node *gen_Switch(ir_node *const node)
x86_addr_t addr;
if (be_options.pic_style != BE_PIC_NONE) {
ir_node *const base
= create_picaddr_lea(new_block, X86_IMM_PCREL, entity);
= create_picaddr_lea(dbgi, new_block, X86_IMM_PCREL, entity);
ir_node *load_in[3];
int load_arity = 0;
int load_base = load_arity++;
......
......@@ -449,11 +449,10 @@ ir_node *be_new_Asm(dbg_info *const dbgi, ir_node *const block, int const n_ins,
return asmn;
}
ir_node *be_new_Relocation(ir_graph *irg, unsigned kind, ir_entity *entity,
ir_mode *mode)
ir_node *be_new_Relocation(dbg_info *const dbgi, ir_graph *const irg, unsigned const kind, ir_entity *const entity, ir_mode *const mode)
{
ir_node *const block = get_irg_start_block(irg);
ir_node *const node = new_ir_node(NULL, irg, block, op_be_Relocation,
ir_node *const node = new_ir_node(dbgi, irg, block, op_be_Relocation,
mode, 0, NULL);
be_relocation_attr_t *const attr
= (be_relocation_attr_t*)get_irn_generic_attr(node);
......
......@@ -191,8 +191,7 @@ ir_node *be_new_Asm(dbg_info *dbgi, ir_node *block, int n_ins, ir_node **ins, ar
* specific. This node is meant to be used in preparation phases for position
* independent code.
*/
ir_node *be_new_Relocation(ir_graph *irg, unsigned kind, ir_entity *entity,
ir_mode *mode);
ir_node *be_new_Relocation(dbg_info *dbgi, ir_graph *irg, unsigned kind, ir_entity *entity, ir_mode *mode);
ir_entity *be_get_Relocation_entity(ir_node const* node);
......
......@@ -79,9 +79,7 @@ static ir_entity *get_nonlazyptr(be_main_env_t *env, ir_entity *entity)
return result;
}
static ir_node *get_eip_relative(ir_graph *const irg,
x86_immediate_kind_t const kind,
ir_entity *const entity)
static ir_node *get_eip_relative(dbg_info *const dbgi, ir_graph *const irg, x86_immediate_kind_t const kind, ir_entity *const entity)
{
/* Everything else is accessed relative to EIP. */
ir_node *const pic_base = ia32_get_pic_base(irg);
......@@ -89,22 +87,21 @@ static ir_node *get_eip_relative(ir_graph *const irg,
set_irn_mode(pic_base, mode_P);
ir_node *const block = get_irg_start_block(irg);
ir_mode *const offset_mode = get_reference_offset_mode(mode_P);
ir_node *reloc = be_new_Relocation(irg, (unsigned)kind, entity, offset_mode);
ir_node *const reloc = be_new_Relocation(dbgi, irg, (unsigned)kind, entity, offset_mode);
/* All ok now for locally constructed stuff. */
ir_node *const add = new_rd_Add(NULL, block, pic_base, reloc);
ir_node *const add = new_rd_Add(dbgi, block, pic_base, reloc);
/* Make sure the walker doesn't visit this add again. */
mark_irn_visited(add);
return add;
}
static ir_node *get_table_load(ir_graph *irg, x86_immediate_kind_t const kind,
ir_entity *const entity)
static ir_node *get_table_load(dbg_info *const dbgi, ir_graph *const irg, x86_immediate_kind_t const kind, ir_entity *const entity)
{
ir_node *const addr = get_eip_relative(irg, kind, entity);
ir_node *const addr = get_eip_relative(dbgi, irg, kind, entity);
ir_type *const type = get_entity_type(entity);
ir_node *const nomem = get_irg_no_mem(irg);
ir_node *const block = get_irg_start_block(irg);
ir_node *const load = new_rd_Load(NULL, block, nomem, addr, mode_P, type,
ir_node *const load = new_rd_Load(dbgi, block, nomem, addr, mode_P, type,
cons_floats);
return new_r_Proj(load, mode_P, pn_Load_res);
}
......@@ -119,8 +116,9 @@ static void fix_address_elf(ir_node *const node, void *const data)
if (is_tls_entity(entity))
continue;
ir_graph *const irg = get_irn_irg(node);
ir_node * res;
ir_node *res;
dbg_info *const dbgi = get_irn_dbg_info(pred);
ir_graph *const irg = get_irn_irg(node);
if (i == n_Call_ptr && is_Call(node)) {
/* Calls can jump to relative addresses, so we can directly jump to
* the (relatively) known call address or the trampoline */
......@@ -129,10 +127,10 @@ static void fix_address_elf(ir_node *const node, void *const data)
continue;
if (be_options.pic_style == BE_PIC_ELF_PLT) {
res = be_new_Relocation(irg, X86_IMM_PLT, entity, mode_P);
res = be_new_Relocation(dbgi, irg, X86_IMM_PLT, entity, mode_P);
} else {
assert(be_options.pic_style == BE_PIC_ELF_NO_PLT);
res = get_table_load(irg, X86_IMM_GOT, entity);
res = get_table_load(dbgi, irg, X86_IMM_GOT, entity);
}
} else {
ir_visibility const visibility = get_entity_visibility(entity);
......@@ -140,9 +138,9 @@ static void fix_address_elf(ir_node *const node, void *const data)
&& visibility != ir_visibility_external_private) {
assert(visibility == ir_visibility_local
|| visibility == ir_visibility_private);
res = get_eip_relative(irg, X86_IMM_GOTOFF, entity);
res = get_eip_relative(dbgi, irg, X86_IMM_GOTOFF, entity);
} else {
res = get_table_load(irg, X86_IMM_GOT, entity);
res = get_table_load(dbgi, irg, X86_IMM_GOT, entity);
}
}
set_irn_n(node, i, res);
......@@ -161,9 +159,10 @@ static void fix_address_macho(ir_node *const node, void *const data)
if (is_tls_entity(entity))
continue;
ir_graph *const irg = get_irn_irg(node);
be_main_env_t *const be = be_get_irg_main_env(irg);
ir_node *res;
dbg_info *const dbgi = get_irn_dbg_info(pred);
ir_graph *const irg = get_irn_irg(node);
be_main_env_t *const be = be_get_irg_main_env(irg);
if (i == n_Call_ptr && is_Call(node)) {
/* Calls can jump to relative addresses, so we can directly jump to
* the (relatively) known call address or the trampoline */
......@@ -172,15 +171,15 @@ static void fix_address_macho(ir_node *const node, void *const data)
continue;
ir_entity *const trampoline = get_trampoline(be, entity);
res = be_new_Relocation(irg, X86_IMM_ADDR, trampoline, mode_P);
res = be_new_Relocation(dbgi, irg, X86_IMM_ADDR, trampoline, mode_P);
} else {
/* Everything else is accessed relative to EIP. */
if (entity_has_definition(entity)
&& !(get_entity_linkage(entity) & IR_LINKAGE_MERGE)) {
res = get_eip_relative(irg, X86_IMM_PICBASE_REL, entity);
res = get_eip_relative(dbgi, irg, X86_IMM_PICBASE_REL, entity);
} else {
ir_entity *const nonlazyptr = get_nonlazyptr(be, entity);
res = get_table_load(irg, X86_IMM_PICBASE_REL, nonlazyptr);
res = get_table_load(dbgi, irg, X86_IMM_PICBASE_REL, nonlazyptr);
}
}
set_irn_n(node, i, res);
......
Markdown is supported
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