| 2642 | } |
| 2643 | |
| 2644 | void BeModule::DoInlining(BeFunction* func) |
| 2645 | { |
| 2646 | //bool debugging = func->mName == "?Test@Program@bf@@CAXXZ"; |
| 2647 | //bool debugging = func->mName == "?TestA@TestClass@Bro@Dude@Hey@@SAX_J@Z"; |
| 2648 | //debugging |= func->mName == "?TestB@TestClass@Bro@Dude@Hey@@SAX_J@Z"; |
| 2649 | //debugging |= func->mName == "?TestC@TestClass@Bro@Dude@Hey@@SAX_J@Z"; |
| 2650 | // if (debugging) |
| 2651 | // { |
| 2652 | // Print(func); |
| 2653 | // } |
| 2654 | |
| 2655 | if (func->mDidInlinePass) |
| 2656 | return; |
| 2657 | // Set this true here so we don't recurse on the same function |
| 2658 | func->mDidInlinePass = true; |
| 2659 | |
| 2660 | int numHeadAllocas = 0; |
| 2661 | bool inHeadAllocas = true; |
| 2662 | |
| 2663 | int blockIdx = 0; |
| 2664 | |
| 2665 | // From head to resume |
| 2666 | std::unordered_multimap<BeBlock*, BeBlock*> inlineResumesMap; |
| 2667 | |
| 2668 | // From resume to head |
| 2669 | std::unordered_multimap<BeBlock*, BeBlock*> inlineHeadMap; |
| 2670 | |
| 2671 | bool hadInlining = false; |
| 2672 | |
| 2673 | std::function<void(int& blockIdx, BeBlock* endBlock, std::unordered_set<BeFunction*>& funcInlined)> _DoInlining; |
| 2674 | _DoInlining = [&](int& blockIdx, BeBlock* endBlock, std::unordered_set<BeFunction*>& funcInlined) |
| 2675 | { |
| 2676 | for (; blockIdx < (int)func->mBlocks.size(); blockIdx++) |
| 2677 | { |
| 2678 | auto beBlock = func->mBlocks[blockIdx]; |
| 2679 | if (beBlock == endBlock) |
| 2680 | { |
| 2681 | // Let previous handler deal with this |
| 2682 | --blockIdx; |
| 2683 | return; |
| 2684 | } |
| 2685 | |
| 2686 | for (int instIdx = 0; instIdx < (int)beBlock->mInstructions.size(); instIdx++) |
| 2687 | { |
| 2688 | auto inst = beBlock->mInstructions[instIdx]; |
| 2689 | if (inHeadAllocas) |
| 2690 | { |
| 2691 | switch (inst->GetTypeId()) |
| 2692 | { |
| 2693 | case BeAllocaInst::TypeId: |
| 2694 | case BeNumericCastInst::TypeId: |
| 2695 | case BeBitCastInst::TypeId: |
| 2696 | numHeadAllocas++; |
| 2697 | default: |
| 2698 | inHeadAllocas = false; |
| 2699 | } |
| 2700 | } |
| 2701 |
no test coverage detected