LCOV - code coverage report
Current view: top level - lib/CodeGen/GlobalISel - Combiner.cpp (source / functions) Hit Total Coverage
Test: llvm-toolchain.info Lines: 0 20 0.0 %
Date: 2018-06-17 00:07:59 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //===-- lib/CodeGen/GlobalISel/GICombiner.cpp -----------------------===//
       2             : //
       3             : //                     The LLVM Compiler Infrastructure
       4             : //
       5             : // This file is distributed under the University of Illinois Open Source
       6             : // License. See LICENSE.TXT for details.
       7             : //
       8             : //===----------------------------------------------------------------------===//
       9             : //
      10             : // This file constains common code to combine machine functions at generic
      11             : // level.
      12             : //===----------------------------------------------------------------------===//
      13             : 
      14             : #include "llvm/CodeGen/GlobalISel/Combiner.h"
      15             : #include "llvm/CodeGen/GlobalISel/CombinerInfo.h"
      16             : #include "llvm/CodeGen/GlobalISel/MachineIRBuilder.h"
      17             : #include "llvm/CodeGen/MachineOptimizationRemarkEmitter.h"
      18             : #include "llvm/CodeGen/GlobalISel/GISelWorkList.h"
      19             : #include "llvm/ADT/PostOrderIterator.h"
      20             : #include "llvm/CodeGen/GlobalISel/Utils.h"
      21             : #include "llvm/CodeGen/MachineRegisterInfo.h"
      22             : #include "llvm/Support/Debug.h"
      23             : 
      24             : #define DEBUG_TYPE "gi-combiner"
      25             : 
      26             : using namespace llvm;
      27             : 
      28           0 : Combiner::Combiner(CombinerInfo &Info, const TargetPassConfig *TPC)
      29           0 :     : CInfo(Info), TPC(TPC) {
      30             :   (void)this->TPC; // FIXME: Remove when used.
      31           0 : }
      32             : 
      33           0 : bool Combiner::combineMachineInstrs(MachineFunction &MF) {
      34             :   // If the ISel pipeline failed, do not bother running this pass.
      35             :   // FIXME: Should this be here or in individual combiner passes.
      36           0 :   if (MF.getProperties().hasProperty(
      37             :           MachineFunctionProperties::Property::FailedISel))
      38             :     return false;
      39             : 
      40           0 :   MRI = &MF.getRegInfo();
      41           0 :   Builder.setMF(MF);
      42             : 
      43             :   LLVM_DEBUG(dbgs() << "Generic MI Combiner for: " << MF.getName() << '\n');
      44             : 
      45             :   MachineOptimizationRemarkEmitter MORE(MF, /*MBFI=*/nullptr);
      46             : 
      47             :   bool MFChanged = false;
      48             :   bool Changed;
      49             : 
      50           0 :   do {
      51             :     // Collect all instructions. Do a post order traversal for basic blocks and
      52             :     // insert with list bottom up, so while we pop_back_val, we'll traverse top
      53             :     // down RPOT.
      54             :     Changed = false;
      55           0 :     GISelWorkList<512> WorkList;
      56           0 :     for (MachineBasicBlock *MBB : post_order(&MF)) {
      57           0 :       if (MBB->empty())
      58           0 :         continue;
      59           0 :       for (auto MII = MBB->rbegin(), MIE = MBB->rend(); MII != MIE;) {
      60             :         MachineInstr *CurMI = &*MII;
      61             :         ++MII;
      62             :         // Erase dead insts before even adding to the list.
      63           0 :         if (isTriviallyDead(*CurMI, *MRI)) {
      64             :           LLVM_DEBUG(dbgs() << *CurMI << "Is dead; erasing.\n");
      65           0 :           CurMI->eraseFromParentAndMarkDBGValuesForRemoval();
      66           0 :           continue;
      67             :         }
      68           0 :         WorkList.insert(CurMI);
      69             :       }
      70             :     }
      71             :     // Main Loop. Process the instructions here.
      72           0 :     while (!WorkList.empty()) {
      73             :       MachineInstr *CurrInst = WorkList.pop_back_val();
      74             :       LLVM_DEBUG(dbgs() << "Try combining " << *CurrInst << "\n";);
      75           0 :       Changed |= CInfo.combine(*CurrInst, Builder);
      76             :     }
      77           0 :     MFChanged |= Changed;
      78             :   } while (Changed);
      79             : 
      80             :   return MFChanged;
      81             : }

Generated by: LCOV version 1.13