Skip to content

Commit

Permalink
i#1569 AArch64: Rename members of clean_call_info_t.
Browse files Browse the repository at this point in the history
This is to make the names also applicable to AArch64, in preparation
for moving some of x86/clean_call_opt.c into clean_call_opt_shared.c.

This is search-and-replace with a few adjustments to spaces and comments.

Review-URL: https://codereview.appspot.com/314120043
  • Loading branch information
egrimley-arm committed Nov 22, 2016
1 parent 93a3fef commit 23a236e
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 59 deletions.
18 changes: 9 additions & 9 deletions core/arch/aarchxx/mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,10 +201,10 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
#endif
if (cci == NULL)
cci = &default_clean_call_info;
if (cci->preserve_mcontext || cci->num_xmms_skip != NUM_SIMD_REGS) {
if (cci->preserve_mcontext || cci->num_simd_skip != NUM_SIMD_REGS) {
/* FIXME i#1551: once we add skipping of regs, need to keep shape here */
}
/* FIXME i#1551: once we have cci->num_xmms_skip, skip this if possible */
/* FIXME i#1551: once we have cci->num_simd_skip, skip this if possible */

#ifdef AARCH64

Expand Down Expand Up @@ -243,7 +243,7 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
OPND_CREATE_INT16(dstack_offs)));

/* save the push_pc operand to the priv_mcontext_t.pc field */
if (!(cci->skip_save_aflags)) {
if (!(cci->skip_save_flags)) {
if (opnd_is_immed_int(push_pc)) {
PRE(ilist, instr,
XINST_CREATE_load_int(dcontext, opnd_create_reg(DR_REG_X1), push_pc));
Expand Down Expand Up @@ -332,7 +332,7 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
SIMD_REG_LIST_LEN, SIMD_REG_LIST_0_15));
dstack_offs += NUM_SIMD_SLOTS*sizeof(dr_simd_t);
/* pc and aflags */
if (cci->skip_save_aflags) {
if (cci->skip_save_flags) {
/* even if we skip flag saves we want to keep mcontext shape */
int offs_beyond_xmm = 2 * XSP_SZ;
dstack_offs += offs_beyond_xmm;
Expand Down Expand Up @@ -390,8 +390,8 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
DR_REG_LIST_LENGTH_ARM, DR_REG_LIST_ARM));
}
dstack_offs += 15 * XSP_SZ;
ASSERT(cci->skip_save_aflags ||
cci->num_xmms_skip != 0 ||
ASSERT(cci->skip_save_flags ||
cci->num_simd_skip != 0 ||
cci->num_regs_skip != 0 ||
dstack_offs == (uint)get_clean_call_switch_stack_size());
#endif
Expand Down Expand Up @@ -444,7 +444,7 @@ insert_pop_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
OPND_CREATE_INT32(current_offs)));

/* load pc and flags */
if(!(cci->skip_save_aflags)) {
if(!(cci->skip_save_flags)) {
/* ldp w1, w2, [x0, #8] */
PRE(ilist, instr,
INSTR_CREATE_ldp(dcontext,
Expand Down Expand Up @@ -503,7 +503,7 @@ insert_pop_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
PRE(ilist, instr, INSTR_CREATE_pop(dcontext, opnd_create_reg(DR_REG_LR)));

/* pc and aflags */
if (cci->skip_save_aflags) {
if (cci->skip_save_flags) {
/* even if we skip flag saves we still keep mcontext shape */
int offs_beyond_xmm = 2 * XSP_SZ;
PRE(ilist, instr, XINST_CREATE_add(dcontext, opnd_create_reg(DR_REG_SP),
Expand All @@ -521,7 +521,7 @@ insert_pop_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
opnd_create_reg(scratch)));
PRE(ilist, instr, instr_create_restore_from_tls(dcontext, scratch, slot));
}
/* FIXME i#1551: once we have cci->num_xmms_skip, skip this if possible */
/* FIXME i#1551: once we have cci->num_simd_skip, skip this if possible */
PRE(ilist, instr, INSTR_CREATE_vldm_wb(dcontext, OPND_CREATE_MEMLIST(DR_REG_SP),
SIMD_REG_LIST_LEN, SIMD_REG_LIST_0_15));
PRE(ilist, instr, INSTR_CREATE_vldm_wb(dcontext, OPND_CREATE_MEMLIST(DR_REG_SP),
Expand Down
8 changes: 4 additions & 4 deletions core/arch/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ typedef struct _clean_call_info_t {
bool opt_inline;
bool should_align;
bool save_all_regs;
bool skip_save_aflags;
bool skip_clear_eflags;
uint num_xmms_skip;
bool xmm_skip[NUM_SIMD_REGS];
bool skip_save_flags;
bool skip_clear_flags;
uint num_simd_skip;
bool simd_skip[NUM_SIMD_REGS];
uint num_regs_skip;
bool reg_skip[NUM_GP_REGS];
bool preserve_mcontext; /* even if skip reg save, preserve mcontext shape */
Expand Down
8 changes: 4 additions & 4 deletions core/arch/mangle_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ prepare_for_clean_call(dcontext_t *dcontext, clean_call_info_t *cci,
/* check if need adjust stack for alignment. */
if (cci->should_align) {
uint num_slots = NUM_GP_REGS + NUM_EXTRA_SLOTS;
if (cci->skip_save_aflags)
if (cci->skip_save_flags)
num_slots -= 2;
num_slots -= cci->num_regs_skip; /* regs that not saved */
if ((num_slots % 2) == 1) {
Expand All @@ -290,8 +290,8 @@ prepare_for_clean_call(dcontext_t *dcontext, clean_call_info_t *cci,
}
}
#endif
ASSERT(cci->skip_save_aflags ||
cci->num_xmms_skip != 0 ||
ASSERT(cci->skip_save_flags ||
cci->num_simd_skip != 0 ||
cci->num_regs_skip != 0 ||
dstack_offs == sizeof(priv_mcontext_t) + clean_call_beyond_mcontext());
return dstack_offs;
Expand All @@ -309,7 +309,7 @@ cleanup_after_clean_call(dcontext_t *dcontext, clean_call_info_t *cci,
/* PR 218790: remove the padding we added for 16-byte rsp alignment */
if (cci->should_align) {
uint num_slots = NUM_GP_REGS + NUM_EXTRA_SLOTS;
if (cci->skip_save_aflags)
if (cci->skip_save_flags)
num_slots += 2;
num_slots -= cci->num_regs_skip; /* regs that not saved */
if ((num_slots % 2) == 1) {
Expand Down
40 changes: 20 additions & 20 deletions core/arch/x86/clean_call_opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1028,16 +1028,16 @@ analyze_clean_call_aflags(dcontext_t *dcontext,

/* If there's a flags read, we clear the flags. If there's a write or read,
* we save them, because a read creates a clear which is a write. */
cci->skip_clear_eflags = !ci->read_aflags;
cci->skip_save_aflags = !(ci->write_aflags || ci->read_aflags);
cci->skip_clear_flags = !ci->read_aflags;
cci->skip_save_flags = !(ci->write_aflags || ci->read_aflags);
/* XXX: this is a more aggressive optimization by analyzing the ilist
* to be instrumented. The client may change the ilist, which violate
* the analysis result. For example,
* I do not need save the aflags now if an instruction
* after "where" updating all aflags, but later the client can
* insert an instruction reads the aflags before that instruction.
*/
if (INTERNAL_OPTION(opt_cleancall) > 1 && !cci->skip_save_aflags) {
if (INTERNAL_OPTION(opt_cleancall) > 1 && !cci->skip_save_flags) {
for (instr = where; instr != NULL; instr = instr_get_next(instr)) {
uint flags = instr_get_arith_flags(instr, DR_QUERY_DEFAULT);
if (TESTANY(EFLAGS_READ_6, flags) || instr_is_cti(instr))
Expand All @@ -1046,7 +1046,7 @@ analyze_clean_call_aflags(dcontext_t *dcontext,
LOG(THREAD, LOG_CLEANCALL, 2,
"CLEANCALL: inserting clean call "PFX
", skip saving aflags.\n", ci->start);
cci->skip_save_aflags = true;
cci->skip_save_flags = true;
break;
}
}
Expand All @@ -1062,16 +1062,16 @@ analyze_clean_call_regs(dcontext_t *dcontext, clean_call_info_t *cci)
/* 1. xmm registers */
for (i = 0; i < NUM_SIMD_REGS; i++) {
if (info->xmm_used[i]) {
cci->xmm_skip[i] = false;
cci->simd_skip[i] = false;
} else {
LOG(THREAD, LOG_CLEANCALL, 3,
"CLEANCALL: if inserting clean call "PFX
", skip saving XMM%d.\n", info->start, i);
cci->xmm_skip[i] = true;
cci->num_xmms_skip++;
cci->simd_skip[i] = true;
cci->num_simd_skip++;
}
}
if (INTERNAL_OPTION(opt_cleancall) > 2 && cci->num_xmms_skip != NUM_SIMD_REGS)
if (INTERNAL_OPTION(opt_cleancall) > 2 && cci->num_simd_skip != NUM_SIMD_REGS)
cci->should_align = false;
/* 2. general purpose registers */
/* set regs not to be saved for clean call */
Expand All @@ -1088,7 +1088,7 @@ analyze_clean_call_regs(dcontext_t *dcontext, clean_call_info_t *cci)
}
}
/* we need save/restore rax if save aflags because rax is used */
if (!cci->skip_save_aflags && cci->reg_skip[0]) {
if (!cci->skip_save_flags && cci->reg_skip[0]) {
LOG(THREAD, LOG_CLEANCALL, 3,
"CLEANCALL: if inserting clean call "PFX
", cannot skip saving reg xax.\n", info->start);
Expand Down Expand Up @@ -1213,13 +1213,13 @@ analyze_clean_call_inline(dcontext_t *dcontext, clean_call_info_t *cci)
}
}
}
if (cci->num_xmms_skip == NUM_SIMD_REGS) {
STATS_INC(cleancall_xmm_skipped);
if (cci->num_simd_skip == NUM_SIMD_REGS) {
STATS_INC(cleancall_simd_skipped);
}
if (cci->skip_save_aflags) {
if (cci->skip_save_flags) {
STATS_INC(cleancall_aflags_save_skipped);
}
if (cci->skip_clear_eflags) {
if (cci->skip_clear_flags) {
STATS_INC(cleancall_aflags_clear_skipped);
}
} else {
Expand Down Expand Up @@ -1278,9 +1278,9 @@ analyze_clean_call(dcontext_t *dcontext, clean_call_info_t *cci, instr_t *where,
* code sequence to put in place: we may want to still use out-of-line
* unless multiple regs are able to be skipped.
*/
if ((cci->num_xmms_skip == 0 /* save all xmms */ &&
if ((cci->num_simd_skip == 0 /* save all xmms */ &&
cci->num_regs_skip == 0 /* save all regs */ &&
!cci->skip_save_aflags) ||
!cci->skip_save_flags) ||
always_out_of_line)
cci->out_of_line_swap = true;

Expand All @@ -1295,7 +1295,7 @@ insert_inline_reg_save(dcontext_t *dcontext, clean_call_info_t *cci,
int i;

/* Don't spill anything if we don't have to. */
if (cci->num_regs_skip == NUM_GP_REGS && cci->skip_save_aflags &&
if (cci->num_regs_skip == NUM_GP_REGS && cci->skip_save_flags &&
!ci->has_locals) {
return;
}
Expand All @@ -1306,7 +1306,7 @@ insert_inline_reg_save(dcontext_t *dcontext, clean_call_info_t *cci,
insert_get_mcontext_base(dcontext, ilist, where, ci->spill_reg);

/* Save used registers. */
ASSERT(cci->num_xmms_skip == NUM_SIMD_REGS);
ASSERT(cci->num_simd_skip == NUM_SIMD_REGS);
for (i = 0; i < NUM_GP_REGS; i++) {
if (!cci->reg_skip[i]) {
reg_id_t reg_id = DR_REG_XAX + (reg_id_t)i;
Expand All @@ -1320,7 +1320,7 @@ insert_inline_reg_save(dcontext_t *dcontext, clean_call_info_t *cci,
}

/* Save aflags if necessary via XAX, which was just saved if needed. */
if (!cci->skip_save_aflags) {
if (!cci->skip_save_flags) {
ASSERT(!cci->reg_skip[DR_REG_XAX - DR_REG_XAX]);
dr_save_arith_flags_to_xax(dcontext, ilist, where);
PRE(ilist, where, INSTR_CREATE_mov_st
Expand All @@ -1343,13 +1343,13 @@ insert_inline_reg_restore(dcontext_t *dcontext, clean_call_info_t *cci,
callee_info_t *ci = cci->callee_info;

/* Don't restore regs if we don't have to. */
if (cci->num_regs_skip == NUM_GP_REGS && cci->skip_save_aflags &&
if (cci->num_regs_skip == NUM_GP_REGS && cci->skip_save_flags &&
!ci->has_locals) {
return;
}

/* Restore aflags before regs because it uses xax. */
if (!cci->skip_save_aflags) {
if (!cci->skip_save_flags) {
PRE(ilist, where, INSTR_CREATE_mov_ld
(dcontext, opnd_create_reg(DR_REG_XAX),
callee_info_slot_opnd(ci, SLOT_FLAGS, 0)));
Expand Down
18 changes: 9 additions & 9 deletions core/arch/x86/mangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ insert_clear_eflags(dcontext_t *dcontext, clean_call_info_t *cci,
instrlist_t *ilist, instr_t *instr)
{
/* clear eflags for callee's usage */
if (cci == NULL || !cci->skip_clear_eflags) {
if (cci == NULL || !cci->skip_clear_flags) {
if (dynamo_options.cleancall_ignore_eflags) {
/* we still clear DF since some compiler assumes
* DF is cleared at each function.
Expand Down Expand Up @@ -335,9 +335,9 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
int offs_beyond_xmm = 0;
if (cci == NULL)
cci = &default_clean_call_info;
if (cci->preserve_mcontext || cci->num_xmms_skip != NUM_SIMD_REGS) {
if (cci->preserve_mcontext || cci->num_simd_skip != NUM_SIMD_REGS) {
int offs = XMM_SLOTS_SIZE + PRE_XMM_PADDING;
if (cci->preserve_mcontext && cci->skip_save_aflags) {
if (cci->preserve_mcontext && cci->skip_save_flags) {
offs_beyond_xmm = 2*XSP_SZ; /* pc and flags */
offs += offs_beyond_xmm;
}
Expand All @@ -362,7 +362,7 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
uint opcode = move_mm_reg_opcode(ALIGNED(alignment, 16), ALIGNED(alignment, 32));
ASSERT(proc_has_feature(FEATURE_SSE));
for (i=0; i<NUM_SIMD_SAVED; i++) {
if (!cci->xmm_skip[i]) {
if (!cci->simd_skip[i]) {
PRE(ilist, instr, instr_create_1dst_1src
(dcontext, opcode,
opnd_create_base_disp(REG_XSP, REG_NULL, 0,
Expand All @@ -376,7 +376,7 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
ASSERT(XMM_SAVED_SIZE <= XMM_SLOTS_SIZE);
}
/* pc and aflags */
if (!cci->skip_save_aflags) {
if (!cci->skip_save_flags) {
ASSERT(offs_beyond_xmm == 0);
if (opnd_is_immed_int(push_pc))
PRE(ilist, instr, INSTR_CREATE_push_imm(dcontext, push_pc));
Expand Down Expand Up @@ -430,8 +430,8 @@ insert_push_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
PRE(ilist, instr, INSTR_CREATE_pusha(dcontext));
dstack_offs += 8 * XSP_SZ;
#endif
ASSERT(cci->skip_save_aflags ||
cci->num_xmms_skip != 0 ||
ASSERT(cci->skip_save_flags ||
cci->num_simd_skip != 0 ||
cci->num_regs_skip != 0 ||
dstack_offs == (uint)get_clean_call_switch_stack_size());
return dstack_offs;
Expand Down Expand Up @@ -490,7 +490,7 @@ insert_pop_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
#else
PRE(ilist, instr, INSTR_CREATE_popa(dcontext));
#endif
if (!cci->skip_save_aflags) {
if (!cci->skip_save_flags) {
PRE(ilist, instr, INSTR_CREATE_popf(dcontext));
offs_beyond_xmm = XSP_SZ; /* pc */;
} else if (cci->preserve_mcontext) {
Expand All @@ -505,7 +505,7 @@ insert_pop_all_registers(dcontext_t *dcontext, clean_call_info_t *cci,
uint opcode = move_mm_reg_opcode(ALIGNED(alignment, 32), ALIGNED(alignment, 16));
ASSERT(proc_has_feature(FEATURE_SSE));
for (i=0; i<NUM_SIMD_SAVED; i++) {
if (!cci->xmm_skip[i]) {
if (!cci->simd_skip[i]) {
PRE(ilist, instr, instr_create_1dst_1src
(dcontext, opcode, opnd_create_reg(REG_SAVED_XMM0 + (reg_id_t)i),
opnd_create_base_disp(REG_XSP, REG_NULL, 0,
Expand Down
24 changes: 12 additions & 12 deletions core/lib/instrument.c
Original file line number Diff line number Diff line change
Expand Up @@ -5148,9 +5148,9 @@ dr_insert_clean_call_ex_varg(void *drcontext, instrlist_t *ilist, instr_t *where
if (TEST(DR_CLEANCALL_NOSAVE_FLAGS, save_flags)) {
/* even if we remove flag saves we want to keep mcontext shape */
cci.preserve_mcontext = true;
cci.skip_save_aflags = true;
cci.skip_save_flags = true;
/* we assume this implies DF should be 0 already */
cci.skip_clear_eflags = true;
cci.skip_clear_flags = true;
/* XXX: should also provide DR_CLEANCALL_NOSAVE_NONAFLAGS to
* preserve just arith flags on return from a call
*/
Expand All @@ -5163,13 +5163,13 @@ dr_insert_clean_call_ex_varg(void *drcontext, instrlist_t *ilist, instr_t *where
cci.preserve_mcontext = true;
/* start w/ all */
#if defined(X64) && defined(WINDOWS)
cci.num_xmms_skip = 6;
cci.num_simd_skip = 6;
#else
/* all 8 (or 16) are scratch */
cci.num_xmms_skip = NUM_SIMD_REGS;
cci.num_simd_skip = NUM_SIMD_REGS;
#endif
for (i=0; i<cci.num_xmms_skip; i++)
cci.xmm_skip[i] = true;
for (i=0; i<cci.num_simd_skip; i++)
cci.simd_skip[i] = true;
/* now remove those used for param/retval */
#ifdef X64
if (TEST(DR_CLEANCALL_NOSAVE_XMM_NONPARAM, save_flags)) {
Expand All @@ -5179,16 +5179,16 @@ dr_insert_clean_call_ex_varg(void *drcontext, instrlist_t *ilist, instr_t *where
# else
for (i=0; i<3; i++)
# endif
cci.xmm_skip[i] = false;
cci.num_xmms_skip -= i;
cci.simd_skip[i] = false;
cci.num_simd_skip -= i;
}
if (TEST(DR_CLEANCALL_NOSAVE_XMM_NONRET, save_flags)) {
/* xmm0 (and xmm1 for linux) are used for retvals */
cci.xmm_skip[0] = false;
cci.num_xmms_skip--;
cci.simd_skip[0] = false;
cci.num_simd_skip--;
# ifdef UNIX
cci.xmm_skip[1] = false;
cci.num_xmms_skip--;
cci.simd_skip[1] = false;
cci.num_simd_skip--;
# endif
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion core/lib/statsx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@
STATS_DEF("Clean Call analyzed", cleancall_analyzed)
STATS_DEF("Clean Call inserted", cleancall_inserted)
STATS_DEF("Clean Call inlined", cleancall_inlined)
STATS_DEF("Clean Call xmm skipped", cleancall_xmm_skipped)
STATS_DEF("Clean Call xmm skipped", cleancall_simd_skipped)
STATS_DEF("Clean Call aflags save skipped", cleancall_aflags_save_skipped)
STATS_DEF("Clean Call aflags clear skipped", cleancall_aflags_clear_skipped)
/* i#107 handle application using same segment register */
Expand Down

0 comments on commit 23a236e

Please sign in to comment.