From 86a4bce32e2aaf3d377c0acf865f0630a7c30495 Mon Sep 17 00:00:00 2001 From: buzbee Date: Tue, 6 Mar 2012 18:15:00 -0800 Subject: Fix branch bug (showed up in codegen for debug) There are a few "safe" optimizations in the compiler - removing register copies where source and target are the same, deleting branches to the next instruction, etc. One of the redundant branch optimizations, however, was incorrect and resulted in a good branch being deleted. This one showed up in the debug build, and resulted in a failure to do a suspend check (because the branch to the suspend check was deleted). I had hoped that this but might also be the case of some other unexpected failures, but unfortunately I was only able to trigger it when doing a "codegen for debug" build. The source of the bug was a confusion around 16 v/ 32-bit unconditional branch encodings. For a 32-bit unconditional branch, going to the next instruction means an displacement of zero. However, for 16-bit branches, the next instruction is represented by a displacement of -1. To help track down this sort of thing in the future, this CL also adds a new optimization disable flag: kSafeOptimizations. This will allow us to really turn off all optimizations for A/B testing. Also in this CL we are re-enabling the ability to promote argument registers and improving somewhat the code sequence for suspend check when debug is enabled. Change-Id: Ib6b202746eac751cab3b4609805a389c18cb67b2 --- src/compiler/codegen/RallocUtil.cc | 8 -------- 1 file changed, 8 deletions(-) (limited to 'src/compiler/codegen/RallocUtil.cc') diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc index bb2abbaad5..232b304304 100644 --- a/src/compiler/codegen/RallocUtil.cc +++ b/src/compiler/codegen/RallocUtil.cc @@ -1143,10 +1143,6 @@ extern void oatDoPromotion(CompilationUnit* cUnit) // Promote fpRegs for (int i = 0; (fpRegs[i].count > 0) && (i < numRegs); i++) { if (cUnit->promotionMap[fpRegs[i].sReg].fpLocation != kLocPhysReg) { - if (fpRegs[i].sReg >= cUnit->numRegs) { - // don't promote arg regs - continue; - } int reg = oatAllocPreservedFPReg(cUnit, fpRegs[i].sReg, fpRegs[i].doubleStart); if (reg < 0) { @@ -1159,10 +1155,6 @@ extern void oatDoPromotion(CompilationUnit* cUnit) for (int i = 0; (coreRegs[i].count > 0) && i < numRegs; i++) { if (cUnit->promotionMap[coreRegs[i].sReg].coreLocation != kLocPhysReg) { - if (coreRegs[i].sReg >= cUnit->numRegs) { - // don't promote arg regs - continue; - } int reg = oatAllocPreservedCoreReg(cUnit, coreRegs[i].sReg); if (reg < 0) { break; // No more left -- cgit v1.2.3-59-g8ed1b