core/x86/interp.c
/* increments a given counter - assuming XCX is dead */
increments a given counter - assuming XCX is dead
increments a given counter - assuming XCX is dead
int
insert_increment_stat_counter(dcontext_t *dcontext, instrlist_t *trace, instr_t *next,                 
                              uint *counter_address)
{
    int added_size = 0;
    opnd_t private_branchtype_counter = 
        OPND_CREATE_ABSMEM(counter_address, OPSZ_4);
    added_size += tracelist_add(dcontext, trace, next,
                                INSTR_CREATE_mov_ld(dcontext, opnd_create_reg(REG_ECX),
                                                    private_branchtype_counter)
                                );
    added_size += tracelist_add(dcontext, trace, next,
                                INSTR_CREATE_lea(dcontext, opnd_create_reg(REG_ECX),
                                                 opnd_create_base_disp(REG_ECX, 
                                                                       REG_NULL, 0, 1, OPSZ_lea)));
    added_size += tracelist_add(dcontext, trace, next,
                                INSTR_CREATE_mov_st(dcontext, 
                                                    private_branchtype_counter,
                                                    opnd_create_reg(REG_ECX)));
    return added_size;
}
int insert_increment_stat_counter ( dcontext_t * dcontext , instrlist_t * trace , instr_t * next , uint * counter_address ) { int added_size = 0 ; opnd_t private_branchtype_counter = OPND_CREATE_ABSMEM ( counter_address , OPSZ_4 ) ; added_size += tracelist_add ( dcontext , trace , next , INSTR_CREATE_mov_ld ( dcontext , opnd_create_reg ( REG_ECX ) , private_branchtype_counter ) ) ; added_size += tracelist_add ( dcontext , trace , next , INSTR_CREATE_lea ( dcontext , opnd_create_reg ( REG_ECX ) , opnd_create_base_disp ( REG_ECX , REG_NULL , 0 , 1 , OPSZ_lea ) ) ) ; added_size += tracelist_add ( dcontext , trace , next , INSTR_CREATE_mov_st ( dcontext , private_branchtype_counter , opnd_create_reg ( REG_ECX ) ) ) ; return added_size ; }
increments a given counter - assuming XCX is dead
increments a given counter - assuming XCX is dead
/* incrementing a branch-type specific thread private counter */ /* using LEA to avoid clobbering eflags in a simple load-increment-store */ /*>>>    movl    counter, %ecx */ /*>>>    lea     1(%ecx), %ecx    */ /*>>>    movl    %ecx, counter */ /* x64: the counter is still 32 bits */