| 11465 | } |
| 11466 | |
| 11467 | void BeMCContext::DoRegFinalization() |
| 11468 | { |
| 11469 | SizedArray<int, 32> savedVolatileVRegs; |
| 11470 | |
| 11471 | mUsedRegs.Clear(); |
| 11472 | |
| 11473 | SetCurrentInst(NULL); |
| 11474 | |
| 11475 | // Remove the Def instructions, replace vreg |
| 11476 | for (auto mcBlock : mBlocks) |
| 11477 | { |
| 11478 | mActiveBlock = mcBlock; |
| 11479 | |
| 11480 | //for (int instIdx = 0; instIdx < (int)mcBlock->mInstructions.size(); instIdx++) |
| 11481 | for (auto instEnum = BeInstEnumerator(this, mcBlock); instEnum.HasMore(); instEnum.Next()) |
| 11482 | { |
| 11483 | auto inst = instEnum.Get(); |
| 11484 | SetCurrentInst(inst); |
| 11485 | if (inst->IsDef()) |
| 11486 | { |
| 11487 | auto vregInfo = GetVRegInfo(inst->mArg0); |
| 11488 | if (vregInfo->mDbgVariable != NULL) |
| 11489 | vregInfo->mAwaitingDbgStart = true; |
| 11490 | instEnum.RemoveCurrent(); |
| 11491 | continue; |
| 11492 | } |
| 11493 | |
| 11494 | // This is similar to an optimization we have in DoLegalization, but it allows for directRelTo's to match |
| 11495 | // We can't match those in DoLegalization because it would alter the liveness |
| 11496 | if (inst->mKind == BeMCInstKind_Mov) |
| 11497 | { |
| 11498 | // Useless mov, remove it |
| 11499 | if (OperandsEqual(inst->mArg0, inst->mArg1, false)) |
| 11500 | { |
| 11501 | if (inst->mDbgLoc != NULL) |
| 11502 | { |
| 11503 | inst->mKind = BeMCInstKind_EnsureInstructionAt; |
| 11504 | inst->mArg0 = BeMCOperand(); |
| 11505 | inst->mArg1 = BeMCOperand(); |
| 11506 | } |
| 11507 | else |
| 11508 | { |
| 11509 | //RemoveInst(mcBlock, instIdx); |
| 11510 | //instIdx--; |
| 11511 | instEnum.RemoveCurrent(); |
| 11512 | } |
| 11513 | |
| 11514 | continue; |
| 11515 | } |
| 11516 | } |
| 11517 | |
| 11518 | if ((inst->mKind >= BeMCInstKind_Def) && (inst->mKind <= BeMCInstKind_LifetimeEnd)) |
| 11519 | continue; |
| 11520 | |
| 11521 | if (inst->mResult == inst->mArg0) |
| 11522 | { |
| 11523 | // Destination is implicitly arg0 |
| 11524 | inst->mResult.mKind = BeMCOperandKind_None; |
nothing calls this directly
no test coverage detected