1 //===- llvm/CodeGen/VirtRegMap.cpp - Virtual Register Map -----------------===//
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 implements the VirtRegMap class.
11 //
12 // It also contains implementations of the Spiller interface, which, given a
13 // virtual register map and a machine function, eliminates all virtual
14 // references by replacing them with physical register references - adding spill
15 // code as necessary.
16 //
17 //===----------------------------------------------------------------------===//
18 
19 #include "llvm/CodeGen/VirtRegMap.h"
20 #include "LiveDebugVariables.h"
21 #include "llvm/ADT/SmallVector.h"
22 #include "llvm/ADT/Statistic.h"
23 #include "llvm/CodeGen/LiveInterval.h"
24 #include "llvm/CodeGen/LiveIntervals.h"
25 #include "llvm/CodeGen/LiveStacks.h"
26 #include "llvm/CodeGen/MachineBasicBlock.h"
27 #include "llvm/CodeGen/MachineFrameInfo.h"
28 #include "llvm/CodeGen/MachineFunction.h"
29 #include "llvm/CodeGen/MachineFunctionPass.h"
30 #include "llvm/CodeGen/MachineInstr.h"
31 #include "llvm/CodeGen/MachineOperand.h"
32 #include "llvm/CodeGen/MachineRegisterInfo.h"
33 #include "llvm/CodeGen/SlotIndexes.h"
34 #include "llvm/CodeGen/TargetInstrInfo.h"
35 #include "llvm/CodeGen/TargetOpcodes.h"
36 #include "llvm/CodeGen/TargetRegisterInfo.h"
37 #include "llvm/CodeGen/TargetSubtargetInfo.h"
38 #include "llvm/Config/llvm-config.h"
39 #include "llvm/MC/LaneBitmask.h"
40 #include "llvm/Pass.h"
41 #include "llvm/Support/Compiler.h"
42 #include "llvm/Support/Debug.h"
43 #include "llvm/Support/raw_ostream.h"
44 #include <cassert>
45 #include <iterator>
46 #include <utility>
47 
48 using namespace llvm;
49 
50 #define DEBUG_TYPE "regalloc"
51 
52 STATISTIC(NumSpillSlots, "Number of spill slots allocated");
53 STATISTIC(NumIdCopies,   "Number of identity moves eliminated after rewriting");
54 
55 //===----------------------------------------------------------------------===//
56 //  VirtRegMap implementation
57 //===----------------------------------------------------------------------===//
58 
59 char VirtRegMap::ID = 0;
60 
61 INITIALIZE_PASS(VirtRegMap, "virtregmap", "Virtual Register Map", false, false)
62 
63 bool VirtRegMap::runOnMachineFunction(MachineFunction &mf) {
64   MRI = &mf.getRegInfo();
65   TII = mf.getSubtarget().getInstrInfo();
66   TRI = mf.getSubtarget().getRegisterInfo();
67   MF = &mf;
68 
69   Virt2PhysMap.clear();
70   Virt2StackSlotMap.clear();
71   Virt2SplitMap.clear();
72 
73   grow();
74   return false;
75 }
76 
77 void VirtRegMap::grow() {
78   unsigned NumRegs = MF->getRegInfo().getNumVirtRegs();
79   Virt2PhysMap.resize(NumRegs);
80   Virt2StackSlotMap.resize(NumRegs);
81   Virt2SplitMap.resize(NumRegs);
82 }
83 
84 void VirtRegMap::assignVirt2Phys(unsigned virtReg, MCPhysReg physReg) {
85   assert(TargetRegisterInfo::isVirtualRegister(virtReg) &&
86          TargetRegisterInfo::isPhysicalRegister(physReg));
87   assert(Virt2PhysMap[virtReg] == NO_PHYS_REG &&
88          "attempt to assign physical register to already mapped "
89          "virtual register");
90   assert(!getRegInfo().isReserved(physReg) &&
91          "Attempt to map virtReg to a reserved physReg");
92   Virt2PhysMap[virtReg] = physReg;
93 }
94 
95 unsigned VirtRegMap::createSpillSlot(const TargetRegisterClass *RC) {
96   unsigned Size = TRI->getSpillSize(*RC);
97   unsigned Align = TRI->getSpillAlignment(*RC);
98   int SS = MF->getFrameInfo().CreateSpillStackObject(Size, Align);
99   ++NumSpillSlots;
100   return SS;
101 }
102 
103 bool VirtRegMap::hasPreferredPhys(unsigned VirtReg) {
104   unsigned Hint = MRI->getSimpleHint(VirtReg);
105   if (!Hint)
106     return false;
107   if (TargetRegisterInfo::isVirtualRegister(Hint))
108     Hint = getPhys(Hint);
109   return getPhys(VirtReg) == Hint;
110 }
111 
112 bool VirtRegMap::hasKnownPreference(unsigned VirtReg) {
113   std::pair<unsigned, unsigned> Hint = MRI->getRegAllocationHint(VirtReg);
114   if (TargetRegisterInfo::isPhysicalRegister(Hint.second))
115     return true;
116   if (TargetRegisterInfo::isVirtualRegister(Hint.second))
117     return hasPhys(Hint.second);
118   return false;
119 }
120 
121 int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) {
122   assert(TargetRegisterInfo::isVirtualRegister(virtReg));
123   assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
124          "attempt to assign stack slot to already spilled register");
125   const TargetRegisterClass* RC = MF->getRegInfo().getRegClass(virtReg);
126   return Virt2StackSlotMap[virtReg] = createSpillSlot(RC);
127 }
128 
129 void VirtRegMap::assignVirt2StackSlot(unsigned virtReg, int SS) {
130   assert(TargetRegisterInfo::isVirtualRegister(virtReg));
131   assert(Virt2StackSlotMap[virtReg] == NO_STACK_SLOT &&
132          "attempt to assign stack slot to already spilled register");
133   assert((SS >= 0 ||
134           (SS >= MF->getFrameInfo().getObjectIndexBegin())) &&
135          "illegal fixed frame index");
136   Virt2StackSlotMap[virtReg] = SS;
137 }
138 
139 void VirtRegMap::print(raw_ostream &OS, const Module*) const {
140   OS << "********** REGISTER MAP **********\n";
141   for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
142     unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
143     if (Virt2PhysMap[Reg] != (unsigned)VirtRegMap::NO_PHYS_REG) {
144       OS << '[' << printReg(Reg, TRI) << " -> "
145          << printReg(Virt2PhysMap[Reg], TRI) << "] "
146          << TRI->getRegClassName(MRI->getRegClass(Reg)) << "\n";
147     }
148   }
149 
150   for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
151     unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
152     if (Virt2StackSlotMap[Reg] != VirtRegMap::NO_STACK_SLOT) {
153       OS << '[' << printReg(Reg, TRI) << " -> fi#" << Virt2StackSlotMap[Reg]
154          << "] " << TRI->getRegClassName(MRI->getRegClass(Reg)) << "\n";
155     }
156   }
157   OS << '\n';
158 }
159 
160 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
161 LLVM_DUMP_METHOD void VirtRegMap::dump() const {
162   print(dbgs());
163 }
164 #endif
165 
166 //===----------------------------------------------------------------------===//
167 //                              VirtRegRewriter
168 //===----------------------------------------------------------------------===//
169 //
170 // The VirtRegRewriter is the last of the register allocator passes.
171 // It rewrites virtual registers to physical registers as specified in the
172 // VirtRegMap analysis. It also updates live-in information on basic blocks
173 // according to LiveIntervals.
174 //
175 namespace {
176 
177 class VirtRegRewriter : public MachineFunctionPass {
178   MachineFunction *MF;
179   const TargetRegisterInfo *TRI;
180   const TargetInstrInfo *TII;
181   MachineRegisterInfo *MRI;
182   SlotIndexes *Indexes;
183   LiveIntervals *LIS;
184   VirtRegMap *VRM;
185 
186   void rewrite();
187   void addMBBLiveIns();
188   bool readsUndefSubreg(const MachineOperand &MO) const;
189   void addLiveInsForSubRanges(const LiveInterval &LI, unsigned PhysReg) const;
190   void handleIdentityCopy(MachineInstr &MI) const;
191   void expandCopyBundle(MachineInstr &MI) const;
192   bool subRegLiveThrough(const MachineInstr &MI, unsigned SuperPhysReg) const;
193 
194 public:
195   static char ID;
196 
197   VirtRegRewriter() : MachineFunctionPass(ID) {}
198 
199   void getAnalysisUsage(AnalysisUsage &AU) const override;
200 
201   bool runOnMachineFunction(MachineFunction&) override;
202 
203   MachineFunctionProperties getSetProperties() const override {
204     return MachineFunctionProperties().set(
205         MachineFunctionProperties::Property::NoVRegs);
206   }
207 };
208 
209 } // end anonymous namespace
210 
211 char VirtRegRewriter::ID = 0;
212 
213 char &llvm::VirtRegRewriterID = VirtRegRewriter::ID;
214 
215 INITIALIZE_PASS_BEGIN(VirtRegRewriter, "virtregrewriter",
216                       "Virtual Register Rewriter", false, false)
217 INITIALIZE_PASS_DEPENDENCY(SlotIndexes)
218 INITIALIZE_PASS_DEPENDENCY(LiveIntervals)
219 INITIALIZE_PASS_DEPENDENCY(LiveDebugVariables)
220 INITIALIZE_PASS_DEPENDENCY(LiveStacks)
221 INITIALIZE_PASS_DEPENDENCY(VirtRegMap)
222 INITIALIZE_PASS_END(VirtRegRewriter, "virtregrewriter",
223                     "Virtual Register Rewriter", false, false)
224 
225 void VirtRegRewriter::getAnalysisUsage(AnalysisUsage &AU) const {
226   AU.setPreservesCFG();
227   AU.addRequired<LiveIntervals>();
228   AU.addRequired<SlotIndexes>();
229   AU.addPreserved<SlotIndexes>();
230   AU.addRequired<LiveDebugVariables>();
231   AU.addRequired<LiveStacks>();
232   AU.addPreserved<LiveStacks>();
233   AU.addRequired<VirtRegMap>();
234   MachineFunctionPass::getAnalysisUsage(AU);
235 }
236 
237 bool VirtRegRewriter::runOnMachineFunction(MachineFunction &fn) {
238   MF = &fn;
239   TRI = MF->getSubtarget().getRegisterInfo();
240   TII = MF->getSubtarget().getInstrInfo();
241   MRI = &MF->getRegInfo();
242   Indexes = &getAnalysis<SlotIndexes>();
243   LIS = &getAnalysis<LiveIntervals>();
244   VRM = &getAnalysis<VirtRegMap>();
245   DEBUG(dbgs() << "********** REWRITE VIRTUAL REGISTERS **********\n"
246                << "********** Function: "
247                << MF->getName() << '\n');
248   DEBUG(VRM->dump());
249 
250   // Add kill flags while we still have virtual registers.
251   LIS->addKillFlags(VRM);
252 
253   // Live-in lists on basic blocks are required for physregs.
254   addMBBLiveIns();
255 
256   // Rewrite virtual registers.
257   rewrite();
258 
259   // Write out new DBG_VALUE instructions.
260   getAnalysis<LiveDebugVariables>().emitDebugValues(VRM);
261 
262   // All machine operands and other references to virtual registers have been
263   // replaced. Remove the virtual registers and release all the transient data.
264   VRM->clearAllVirt();
265   MRI->clearVirtRegs();
266   return true;
267 }
268 
269 void VirtRegRewriter::addLiveInsForSubRanges(const LiveInterval &LI,
270                                              unsigned PhysReg) const {
271   assert(!LI.empty());
272   assert(LI.hasSubRanges());
273 
274   using SubRangeIteratorPair =
275       std::pair<const LiveInterval::SubRange *, LiveInterval::const_iterator>;
276 
277   SmallVector<SubRangeIteratorPair, 4> SubRanges;
278   SlotIndex First;
279   SlotIndex Last;
280   for (const LiveInterval::SubRange &SR : LI.subranges()) {
281     SubRanges.push_back(std::make_pair(&SR, SR.begin()));
282     if (!First.isValid() || SR.segments.front().start < First)
283       First = SR.segments.front().start;
284     if (!Last.isValid() || SR.segments.back().end > Last)
285       Last = SR.segments.back().end;
286   }
287 
288   // Check all mbb start positions between First and Last while
289   // simulatenously advancing an iterator for each subrange.
290   for (SlotIndexes::MBBIndexIterator MBBI = Indexes->findMBBIndex(First);
291        MBBI != Indexes->MBBIndexEnd() && MBBI->first <= Last; ++MBBI) {
292     SlotIndex MBBBegin = MBBI->first;
293     // Advance all subrange iterators so that their end position is just
294     // behind MBBBegin (or the iterator is at the end).
295     LaneBitmask LaneMask;
296     for (auto &RangeIterPair : SubRanges) {
297       const LiveInterval::SubRange *SR = RangeIterPair.first;
298       LiveInterval::const_iterator &SRI = RangeIterPair.second;
299       while (SRI != SR->end() && SRI->end <= MBBBegin)
300         ++SRI;
301       if (SRI == SR->end())
302         continue;
303       if (SRI->start <= MBBBegin)
304         LaneMask |= SR->LaneMask;
305     }
306     if (LaneMask.none())
307       continue;
308     MachineBasicBlock *MBB = MBBI->second;
309     MBB->addLiveIn(PhysReg, LaneMask);
310   }
311 }
312 
313 // Compute MBB live-in lists from virtual register live ranges and their
314 // assignments.
315 void VirtRegRewriter::addMBBLiveIns() {
316   for (unsigned Idx = 0, IdxE = MRI->getNumVirtRegs(); Idx != IdxE; ++Idx) {
317     unsigned VirtReg = TargetRegisterInfo::index2VirtReg(Idx);
318     if (MRI->reg_nodbg_empty(VirtReg))
319       continue;
320     LiveInterval &LI = LIS->getInterval(VirtReg);
321     if (LI.empty() || LIS->intervalIsInOneMBB(LI))
322       continue;
323     // This is a virtual register that is live across basic blocks. Its
324     // assigned PhysReg must be marked as live-in to those blocks.
325     unsigned PhysReg = VRM->getPhys(VirtReg);
326     assert(PhysReg != VirtRegMap::NO_PHYS_REG && "Unmapped virtual register.");
327 
328     if (LI.hasSubRanges()) {
329       addLiveInsForSubRanges(LI, PhysReg);
330     } else {
331       // Go over MBB begin positions and see if we have segments covering them.
332       // The following works because segments and the MBBIndex list are both
333       // sorted by slot indexes.
334       SlotIndexes::MBBIndexIterator I = Indexes->MBBIndexBegin();
335       for (const auto &Seg : LI) {
336         I = Indexes->advanceMBBIndex(I, Seg.start);
337         for (; I != Indexes->MBBIndexEnd() && I->first < Seg.end; ++I) {
338           MachineBasicBlock *MBB = I->second;
339           MBB->addLiveIn(PhysReg);
340         }
341       }
342     }
343   }
344 
345   // Sort and unique MBB LiveIns as we've not checked if SubReg/PhysReg were in
346   // each MBB's LiveIns set before calling addLiveIn on them.
347   for (MachineBasicBlock &MBB : *MF)
348     MBB.sortUniqueLiveIns();
349 }
350 
351 /// Returns true if the given machine operand \p MO only reads undefined lanes.
352 /// The function only works for use operands with a subregister set.
353 bool VirtRegRewriter::readsUndefSubreg(const MachineOperand &MO) const {
354   // Shortcut if the operand is already marked undef.
355   if (MO.isUndef())
356     return true;
357 
358   unsigned Reg = MO.getReg();
359   const LiveInterval &LI = LIS->getInterval(Reg);
360   const MachineInstr &MI = *MO.getParent();
361   SlotIndex BaseIndex = LIS->getInstructionIndex(MI);
362   // This code is only meant to handle reading undefined subregisters which
363   // we couldn't properly detect before.
364   assert(LI.liveAt(BaseIndex) &&
365          "Reads of completely dead register should be marked undef already");
366   unsigned SubRegIdx = MO.getSubReg();
367   assert(SubRegIdx != 0 && LI.hasSubRanges());
368   LaneBitmask UseMask = TRI->getSubRegIndexLaneMask(SubRegIdx);
369   // See if any of the relevant subregister liveranges is defined at this point.
370   for (const LiveInterval::SubRange &SR : LI.subranges()) {
371     if ((SR.LaneMask & UseMask).any() && SR.liveAt(BaseIndex))
372       return false;
373   }
374   return true;
375 }
376 
377 void VirtRegRewriter::handleIdentityCopy(MachineInstr &MI) const {
378   if (!MI.isIdentityCopy())
379     return;
380   DEBUG(dbgs() << "Identity copy: " << MI);
381   ++NumIdCopies;
382 
383   // Copies like:
384   //    %r0 = COPY undef %r0
385   //    %al = COPY %al, implicit-def %eax
386   // give us additional liveness information: The target (super-)register
387   // must not be valid before this point. Replace the COPY with a KILL
388   // instruction to maintain this information.
389   if (MI.getOperand(0).isUndef() || MI.getNumOperands() > 2) {
390     MI.setDesc(TII->get(TargetOpcode::KILL));
391     DEBUG(dbgs() << "  replace by: " << MI);
392     return;
393   }
394 
395   if (Indexes)
396     Indexes->removeSingleMachineInstrFromMaps(MI);
397   MI.eraseFromBundle();
398   DEBUG(dbgs() << "  deleted.\n");
399 }
400 
401 /// The liverange splitting logic sometimes produces bundles of copies when
402 /// subregisters are involved. Expand these into a sequence of copy instructions
403 /// after processing the last in the bundle. Does not update LiveIntervals
404 /// which we shouldn't need for this instruction anymore.
405 void VirtRegRewriter::expandCopyBundle(MachineInstr &MI) const {
406   if (!MI.isCopy())
407     return;
408 
409   if (MI.isBundledWithPred() && !MI.isBundledWithSucc()) {
410     // Only do this when the complete bundle is made out of COPYs.
411     MachineBasicBlock &MBB = *MI.getParent();
412     for (MachineBasicBlock::reverse_instr_iterator I =
413          std::next(MI.getReverseIterator()), E = MBB.instr_rend();
414          I != E && I->isBundledWithSucc(); ++I) {
415       if (!I->isCopy())
416         return;
417     }
418 
419     for (MachineBasicBlock::reverse_instr_iterator I = MI.getReverseIterator();
420          I->isBundledWithPred(); ) {
421       MachineInstr &MI = *I;
422       ++I;
423 
424       MI.unbundleFromPred();
425       if (Indexes)
426         Indexes->insertMachineInstrInMaps(MI);
427     }
428   }
429 }
430 
431 /// Check whether (part of) \p SuperPhysReg is live through \p MI.
432 /// \pre \p MI defines a subregister of a virtual register that
433 /// has been assigned to \p SuperPhysReg.
434 bool VirtRegRewriter::subRegLiveThrough(const MachineInstr &MI,
435                                         unsigned SuperPhysReg) const {
436   SlotIndex MIIndex = LIS->getInstructionIndex(MI);
437   SlotIndex BeforeMIUses = MIIndex.getBaseIndex();
438   SlotIndex AfterMIDefs = MIIndex.getBoundaryIndex();
439   for (MCRegUnitIterator Unit(SuperPhysReg, TRI); Unit.isValid(); ++Unit) {
440     const LiveRange &UnitRange = LIS->getRegUnit(*Unit);
441     // If the regunit is live both before and after MI,
442     // we assume it is live through.
443     // Generally speaking, this is not true, because something like
444     // "RU = op RU" would match that description.
445     // However, we know that we are trying to assess whether
446     // a def of a virtual reg, vreg, is live at the same time of RU.
447     // If we are in the "RU = op RU" situation, that means that vreg
448     // is defined at the same time as RU (i.e., "vreg, RU = op RU").
449     // Thus, vreg and RU interferes and vreg cannot be assigned to
450     // SuperPhysReg. Therefore, this situation cannot happen.
451     if (UnitRange.liveAt(AfterMIDefs) && UnitRange.liveAt(BeforeMIUses))
452       return true;
453   }
454   return false;
455 }
456 
457 void VirtRegRewriter::rewrite() {
458   bool NoSubRegLiveness = !MRI->subRegLivenessEnabled();
459   SmallVector<unsigned, 8> SuperDeads;
460   SmallVector<unsigned, 8> SuperDefs;
461   SmallVector<unsigned, 8> SuperKills;
462 
463   for (MachineFunction::iterator MBBI = MF->begin(), MBBE = MF->end();
464        MBBI != MBBE; ++MBBI) {
465     DEBUG(MBBI->print(dbgs(), Indexes));
466     for (MachineBasicBlock::instr_iterator
467            MII = MBBI->instr_begin(), MIE = MBBI->instr_end(); MII != MIE;) {
468       MachineInstr *MI = &*MII;
469       ++MII;
470 
471       for (MachineInstr::mop_iterator MOI = MI->operands_begin(),
472            MOE = MI->operands_end(); MOI != MOE; ++MOI) {
473         MachineOperand &MO = *MOI;
474 
475         // Make sure MRI knows about registers clobbered by regmasks.
476         if (MO.isRegMask())
477           MRI->addPhysRegsUsedFromRegMask(MO.getRegMask());
478 
479         if (!MO.isReg() || !TargetRegisterInfo::isVirtualRegister(MO.getReg()))
480           continue;
481         unsigned VirtReg = MO.getReg();
482         unsigned PhysReg = VRM->getPhys(VirtReg);
483         assert(PhysReg != VirtRegMap::NO_PHYS_REG &&
484                "Instruction uses unmapped VirtReg");
485         assert(!MRI->isReserved(PhysReg) && "Reserved register assignment");
486 
487         // Preserve semantics of sub-register operands.
488         unsigned SubReg = MO.getSubReg();
489         if (SubReg != 0) {
490           if (NoSubRegLiveness) {
491             // A virtual register kill refers to the whole register, so we may
492             // have to add implicit killed operands for the super-register.  A
493             // partial redef always kills and redefines the super-register.
494             if ((MO.readsReg() && (MO.isDef() || MO.isKill())) ||
495                 (MO.isDef() && subRegLiveThrough(*MI, PhysReg)))
496               SuperKills.push_back(PhysReg);
497 
498             if (MO.isDef()) {
499               // Also add implicit defs for the super-register.
500               if (MO.isDead())
501                 SuperDeads.push_back(PhysReg);
502               else
503                 SuperDefs.push_back(PhysReg);
504             }
505           } else {
506             if (MO.isUse()) {
507               if (readsUndefSubreg(MO))
508                 // We need to add an <undef> flag if the subregister is
509                 // completely undefined (and we are not adding super-register
510                 // defs).
511                 MO.setIsUndef(true);
512             } else if (!MO.isDead()) {
513               assert(MO.isDef());
514             }
515           }
516 
517           // The def undef and def internal flags only make sense for
518           // sub-register defs, and we are substituting a full physreg.  An
519           // implicit killed operand from the SuperKills list will represent the
520           // partial read of the super-register.
521           if (MO.isDef()) {
522             MO.setIsUndef(false);
523             MO.setIsInternalRead(false);
524           }
525 
526           // PhysReg operands cannot have subregister indexes.
527           PhysReg = TRI->getSubReg(PhysReg, SubReg);
528           assert(PhysReg && "Invalid SubReg for physical register");
529           MO.setSubReg(0);
530         }
531         // Rewrite. Note we could have used MachineOperand::substPhysReg(), but
532         // we need the inlining here.
533         MO.setReg(PhysReg);
534         MO.setIsRenamable(true);
535       }
536 
537       // Add any missing super-register kills after rewriting the whole
538       // instruction.
539       while (!SuperKills.empty())
540         MI->addRegisterKilled(SuperKills.pop_back_val(), TRI, true);
541 
542       while (!SuperDeads.empty())
543         MI->addRegisterDead(SuperDeads.pop_back_val(), TRI, true);
544 
545       while (!SuperDefs.empty())
546         MI->addRegisterDefined(SuperDefs.pop_back_val(), TRI);
547 
548       DEBUG(dbgs() << "> " << *MI);
549 
550       expandCopyBundle(*MI);
551 
552       // We can remove identity copies right now.
553       handleIdentityCopy(*MI);
554     }
555   }
556 }
557