Quick compiler: restore optimizations
This CL re-enables optizations on the Quick compile path.
Notes:
o Although all optimization are enabled, several are now useless
because of llvm and bitcode constraints:
- Large method de-optimization (i.e. - skipping expensive dataflow
analysis) can't be done because we have to do the analysis to
produce a CFG that makes the bitcode verifier happy.
- Small method pattern matching isn't applicable w/ bitcode (though
I can probably do something similar in the Quick backend, but
looking for bitcode instead of dex patterns).
- Branch fusing doesn't translate to bitcode.
- Bitcode generation has de-optimized code layout. We'll try to
repair the damage in a subsequent CL.
o There is an ugly workaround related to the way we're loading and
unloading the compiler .so containing llvm. [See comment in compiler.cc]
o We're still running single-threaded - need to add the magic to allow
multi-threaded use of llvm.
o With the CL, the phone boots, all target tests pass and all cts VM
tests pass (except those being dealt with via a verifier change).
o Compile time is pretty bad - when flashing it's best to follow
with an adb sync to avoid on-device compilation of system apps.
Change-Id: I1c98f9e64aefbcbd24b957c71544c28450eb2023
diff --git a/src/compiler/Frontend.cc b/src/compiler/Frontend.cc
index b893cca..3aedbe9 100644
--- a/src/compiler/Frontend.cc
+++ b/src/compiler/Frontend.cc
@@ -799,8 +799,6 @@
//cUnit->enableDebug |= (1 << kDebugVerifyBitcode);
//cUnit->printMe = true;
//cUnit->enableDebug |= (1 << kDebugDumpBitcodeFile);
- // Disable non-safe optimizations for now
- cUnit->disableOpt |= ~(1 << kSafeOptimizations);
}
#endif
/* Are we generating code for the debugger? */
@@ -1127,8 +1125,11 @@
// Combine vmap tables - core regs, then fp regs - into vmapTable
std::vector<uint16_t> vmapTable;
+ // Core regs may have been inserted out of order - sort first
+ std::sort(cUnit->coreVmapTable.begin(), cUnit->coreVmapTable.end());
for (size_t i = 0 ; i < cUnit->coreVmapTable.size(); i++) {
- vmapTable.push_back(cUnit->coreVmapTable[i]);
+ // Copy, stripping out the phys register sort key
+ vmapTable.push_back(~(-1 << VREG_NUM_WIDTH) & cUnit->coreVmapTable[i]);
}
// If we have a frame, push a marker to take place of lr
if (cUnit->frameSize > 0) {
@@ -1137,7 +1138,7 @@
DCHECK_EQ(__builtin_popcount(cUnit->coreSpillMask), 0);
DCHECK_EQ(__builtin_popcount(cUnit->fpSpillMask), 0);
}
- // Combine vmap tables - core regs, then fp regs
+ // Combine vmap tables - core regs, then fp regs. fp regs already sorted
for (uint32_t i = 0; i < cUnit->fpVmapTable.size(); i++) {
vmapTable.push_back(cUnit->fpVmapTable[i]);
}