Quick compiler: refactored listing & const fix
This CL started off as a simple fix to Issue 4959751, which
identified a case in which compiler debugging listings could read
uninitialized data. The fix ended up pulling a few strings - we
had two distinct dex printing routines (one was focused on SSA names
and was used by the .dot graph dumper), while the other was used with
verbose codegen listing.
Ended up combining the two routines and significantly enhancing the
value of the verbose debug output. We now always use ssa register
names, and also show the constant values of ssa names which are known
to be const following constant propagation.
Along the way, deleted a bit of useless code that remapped all
registers in a phi set to have the same name, and also got rid of
some duplicate listing helper LIR pseudo ops.
Somee examples of the new listing:
-------- dalvik offset: 0x2 @ const/4 v0_1#0x1, #1
the format of the vreg is:
v<orignal Dalvik vnum>_<ssa instance>[#hex value of immediate]
In this example, we don't add any new info (the listing already had #1),
but we also show this form in uses:
invoke-virtual v0_2, v1_3#0x40
Also improved is the listing output of potentially throwing instructions
which are broken into two parts: the check portion and the work portion.
Both halves now show the full disassembly. For example:
-------- dalvik offset: 0x13 @ Check1: invoke-virtual v0_2, v1_3#0x40
....code here
....code here
-------- dalvik offset: 0x13 @ Check2: invoke-virtual v0_2, v1_3#0x40
Dalvik instructions which are optimized away prior to code generation
are displayed in sqare brackets. For example:
-------- dalvik offset: 0x16 @ [move-result-object v0_3]--optimized away
Finally, Phi nodes show which incoming block an operand came through.
In the following example:
-------- dalvik offset: 0x5 @ Phi v1_2 = (v1_1#0x0:4, v1_2:12, v1_3#0x1:14)
Sreg v1_2 is a merge of a constant 0x0 from incoming block 4, a non-const
value from block 12 and a const 0x1 from block 14.
Change-Id: Ib6c19c19ab8a48509d43d8b0e5ed3e8e7ce9fc82
diff --git a/src/compiler/codegen/mir_to_lir.cc b/src/compiler/codegen/mir_to_lir.cc
index fc3df6e..6ec7edb 100644
--- a/src/compiler/codegen/mir_to_lir.cc
+++ b/src/compiler/codegen/mir_to_lir.cc
@@ -611,29 +611,11 @@
return res;
}
-// Process extended MIR instructions (such as PHI).
+// Process extended MIR instructions
static void HandleExtendedMethodMIR(CompilationUnit* cu, BasicBlock* bb, MIR* mir)
{
Codegen* cg = cu->cg.get();
- int op_offset = mir->dalvikInsn.opcode - kMirOpFirst;
- char* msg = NULL;
- if (cu->verbose) {
- msg = static_cast<char*>(NewMem(cu, strlen(extended_mir_op_names[op_offset]) + 1,
- false, kAllocDebugInfo));
- strcpy(msg, extended_mir_op_names[op_offset]);
- }
- LIR* op = NewLIR1(cu, kPseudoExtended, reinterpret_cast<uintptr_t>(msg));
-
switch (static_cast<ExtendedMIROpcode>(mir->dalvikInsn.opcode)) {
- case kMirOpPhi: {
- char* ssa_string = NULL;
- if (cu->verbose) {
- ssa_string = GetSSAString(cu, mir->ssa_rep);
- }
- op->flags.is_nop = true;
- NewLIR1(cu, kPseudoSSARep, reinterpret_cast<uintptr_t>(ssa_string));
- break;
- }
case kMirOpCopy: {
RegLocation rl_src = GetSrc(cu, mir, 0);
RegLocation rl_dest = GetDest(cu, mir);
@@ -719,7 +701,7 @@
// Mark the beginning of a Dalvik instruction for line tracking.
char* inst_str = cu->verbose ?
- GetDalvikDisassembly(cu, mir->dalvikInsn, "") : NULL;
+ GetDalvikDisassembly(cu, mir) : NULL;
boundary_lir = MarkBoundary(cu, mir->offset, inst_str);
// Remember the first LIR for this block.
if (head_lir == NULL) {
@@ -728,12 +710,6 @@
head_lir->def_mask = ENCODE_ALL;
}
- // Don't generate the SSA annotation unless verbose mode is on.
- if (cu->verbose && mir->ssa_rep) {
- char* ssa_string = GetSSAString(cu, mir->ssa_rep);
- NewLIR1(cu, kPseudoSSARep, reinterpret_cast<uintptr_t>(ssa_string));
- }
-
if (opcode == kMirOpCheck) {
// Combine check and work halves of throwing instruction.
MIR* work_half = mir->meta.throw_insn;
@@ -742,7 +718,7 @@
SSARepresentation* ssa_rep = work_half->ssa_rep;
work_half->ssa_rep = mir->ssa_rep;
mir->ssa_rep = ssa_rep;
- work_half->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpNop);
+ work_half->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpCheckPart2);
}
if (opcode >= kMirOpFirst) {