diff --git a/core/arch/aarchxx/mangle.c b/core/arch/aarchxx/mangle.c index f95f55cb59c..38ccd1c090a 100644 --- a/core/arch/aarchxx/mangle.c +++ b/core/arch/aarchxx/mangle.c @@ -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 @@ -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)); @@ -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; @@ -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 @@ -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, @@ -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), @@ -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), diff --git a/core/arch/arch.h b/core/arch/arch.h index 45b10a648af..53d636f2b98 100644 --- a/core/arch/arch.h +++ b/core/arch/arch.h @@ -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 */ diff --git a/core/arch/mangle_shared.c b/core/arch/mangle_shared.c index 2448d95b822..d95a0293866 100644 --- a/core/arch/mangle_shared.c +++ b/core/arch/mangle_shared.c @@ -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) { @@ -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; @@ -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) { diff --git a/core/arch/x86/clean_call_opt.c b/core/arch/x86/clean_call_opt.c index 875b5efb1f2..77e2f8a3cc3 100644 --- a/core/arch/x86/clean_call_opt.c +++ b/core/arch/x86/clean_call_opt.c @@ -1028,8 +1028,8 @@ 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, @@ -1037,7 +1037,7 @@ analyze_clean_call_aflags(dcontext_t *dcontext, * 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)) @@ -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; } } @@ -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 */ @@ -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); @@ -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 { @@ -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; @@ -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; } @@ -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; @@ -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 @@ -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))); diff --git a/core/arch/x86/mangle.c b/core/arch/x86/mangle.c index 5cd3512671a..0332dabc6da 100644 --- a/core/arch/x86/mangle.c +++ b/core/arch/x86/mangle.c @@ -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. @@ -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; } @@ -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; ixmm_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, @@ -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)); @@ -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; @@ -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) { @@ -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; ixmm_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, diff --git a/core/lib/instrument.c b/core/lib/instrument.c index a3fa8c52824..e166492c5be 100644 --- a/core/lib/instrument.c +++ b/core/lib/instrument.c @@ -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 */ @@ -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