[llvm] r342405 - [MachineOutliner][NFC] Don't map more illegal instrs than you have to

Jessica Paquette via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 17 11:40:21 PDT 2018


Author: paquette
Date: Mon Sep 17 11:40:21 2018
New Revision: 342405

URL: http://llvm.org/viewvc/llvm-project?rev=342405&view=rev
Log:
[MachineOutliner][NFC] Don't map more illegal instrs than you have to

We were mapping an instruction every time we saw something we couldn't map
before this. Since each illegal mapping is unique, we only have to do this once.

This makes it so that we don't map illegal instructions when the previous
mapped instruction was illegal.

In CTMark (AArch64), this results in 240 fewer instruction mappings on
average over 619 files in total. The largest improvement is 12576 fewer
mappings in one file, and the smallest is 0. The median improvement is 101
fewer mappings.

Modified:
    llvm/trunk/lib/CodeGen/MachineOutliner.cpp

Modified: llvm/trunk/lib/CodeGen/MachineOutliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineOutliner.cpp?rev=342405&r1=342404&r2=342405&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineOutliner.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineOutliner.cpp Mon Sep 17 11:40:21 2018
@@ -625,27 +625,38 @@ struct InstructionMapper {
                             const TargetInstrInfo &TII) {
     unsigned Flags = TII.getMachineOutlinerMBBFlags(MBB);
 
+    // Set to true whenever we map an illegal number.
+    bool AddedIllegalLastTime = false;
     for (MachineBasicBlock::iterator It = MBB.begin(), Et = MBB.end(); It != Et;
          It++) {
 
       // Keep track of where this instruction is in the module.
       switch (TII.getOutliningType(It, Flags)) {
       case InstrType::Illegal:
+        // If we added an illegal number last time, then don't add more of them.
+        // One number is all that is necessary to prevent matches on illegal
+        // instructions.
+        if (AddedIllegalLastTime)
+          break;
+        AddedIllegalLastTime = true;
         mapToIllegalUnsigned(It);
         break;
 
       case InstrType::Legal:
+        AddedIllegalLastTime = false;
         mapToLegalUnsigned(It);
         break;
 
       case InstrType::LegalTerminator:
         mapToLegalUnsigned(It);
         InstrList.push_back(It);
+        AddedIllegalLastTime = true;
         UnsignedVec.push_back(IllegalInstrNumber);
         IllegalInstrNumber--;
         break;
 
       case InstrType::Invisible:
+        AddedIllegalLastTime = false;
         break;
       }
     }




More information about the llvm-commits mailing list