This is an archive of the discontinued LLVM Phabricator instance.

[LLDB][MIPS32]Merge emulation of similar instructions
ClosedPublic

Authored by bhushan on Jan 5 2016, 2:32 AM.

Details

Reviewers
clayborg
Summary

Currently there is a separate emulation function for each branch instruction, however the emulation logic is almost identical for many of these instructions.
This patch merges emulation of similar instructions into a single function (wherever possible) to remove code duplication.

Diff Detail

Repository
rL LLVM

Event Timeline

bhushan updated this revision to Diff 43970.Jan 5 2016, 2:32 AM
bhushan retitled this revision from to [LLDB][MIPS32]Merge emulation of similar instructions.
bhushan updated this object.
bhushan added a reviewer: clayborg.
bhushan set the repository for this revision to rL LLVM.
clayborg accepted this revision.Jan 5 2016, 10:03 AM
clayborg edited edge metadata.

Looks fine.

This revision is now accepted and ready to land.Jan 5 2016, 10:03 AM
labath added a subscriber: labath.Jan 6 2016, 1:58 AM

Hi, this introduces loads of new compiler warnings like:

lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:1434:14: warning: variable 'target' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
    else if (!strcasecmp (op_name, "BNE") ||
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:1447:77: note: uninitialized use occurs here
    if (!WriteRegisterUnsigned (context, eRegisterKindDWARF, dwarf_pc_mips, target))
                                                                            ^~~~~~
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:1434:10: note: remove the 'if' if its condition is always true
    else if (!strcasecmp (op_name, "BNE") ||
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
lldb/source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.cpp:1407:31: note: initialize the variable 'target' to silence this warning
    int32_t offset, pc, target, rs_val, rt_val;
                              ^
                               = 0

Could you please resolve these?

Hi Pavel,

Could you please confirm if http://reviews.llvm.org/rL256929 resolves the build warnings?

labath added a comment.Jan 6 2016, 6:19 AM

It's looking good now, thanks.

source/Plugins/Instruction/MIPS/EmulateInstructionMIPS.h