diff options
author | Jessica Paquette <jpaquette@apple.com> | 2023-02-03 21:59:16 -0800 |
---|---|---|
committer | Jessica Paquette <jpaquette@apple.com> | 2023-02-03 22:00:45 -0800 |
commit | d1359acb9a4adba2dc872be017eab09a6a88058c (patch) | |
tree | dbd97ce7a40d78f09632b0814c168153e42215a6 /llvm/lib/CodeGen/MachineOutliner.cpp | |
parent | f453589039129d90c46930245129d313f0b38714 (diff) | |
download | llvm-d1359acb9a4adba2dc872be017eab09a6a88058c.zip llvm-d1359acb9a4adba2dc872be017eab09a6a88058c.tar.gz llvm-d1359acb9a4adba2dc872be017eab09a6a88058c.tar.bz2 |
[MachineOutliner] NFC: Add debug output to populateMapper
Adding debug output to improve outliner debuggability + testability.
Move `nooutline` attribute test into the new debug output test.
Diffstat (limited to 'llvm/lib/CodeGen/MachineOutliner.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineOutliner.cpp | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp index a64295c..ef606925 100644 --- a/llvm/lib/CodeGen/MachineOutliner.cpp +++ b/llvm/lib/CodeGen/MachineOutliner.cpp @@ -941,13 +941,12 @@ void MachineOutliner::populateMapper(InstructionMapper &Mapper, Module &M, MachineModuleInfo &MMI) { // Build instruction mappings for each function in the module. Start by // iterating over each Function in M. + LLVM_DEBUG(dbgs() << "*** Populating mapper ***\n"); for (Function &F : M) { + LLVM_DEBUG(dbgs() << "MAPPING FUNCTION: " << F.getName() << "\n"); if (F.hasFnAttribute("nooutline")) { - LLVM_DEBUG({ - dbgs() << "... Skipping function with nooutline attribute: " - << F.getName() << "\n"; - }); + LLVM_DEBUG(dbgs() << "SKIP: Function has nooutline attribute\n"); continue; } @@ -957,36 +956,51 @@ void MachineOutliner::populateMapper(InstructionMapper &Mapper, Module &M, // If it doesn't, then there's nothing to outline from. Move to the next // Function. - if (!MF) + if (!MF) { + LLVM_DEBUG(dbgs() << "SKIP: Function does not have a MachineFunction\n"); continue; + } const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo(); - - if (!RunOnAllFunctions && !TII->shouldOutlineFromFunctionByDefault(*MF)) + if (!RunOnAllFunctions && !TII->shouldOutlineFromFunctionByDefault(*MF)) { + LLVM_DEBUG(dbgs() << "SKIP: Target does not want to outline from " + "function by default\n"); continue; + } // We have a MachineFunction. Ask the target if it's suitable for outlining. // If it isn't, then move on to the next Function in the module. - if (!TII->isFunctionSafeToOutlineFrom(*MF, OutlineFromLinkOnceODRs)) + if (!TII->isFunctionSafeToOutlineFrom(*MF, OutlineFromLinkOnceODRs)) { + LLVM_DEBUG(dbgs() << "SKIP: " << MF->getName() + << ": unsafe to outline from\n"); continue; + } // We have a function suitable for outlining. Iterate over every // MachineBasicBlock in MF and try to map its instructions to a list of // unsigned integers. + const unsigned MinMBBSize = 2; + for (MachineBasicBlock &MBB : *MF) { + LLVM_DEBUG(dbgs() << " MAPPING MBB: '" << MBB.getName() << "'\n"); // If there isn't anything in MBB, then there's no point in outlining from // it. // If there are fewer than 2 instructions in the MBB, then it can't ever // contain something worth outlining. // FIXME: This should be based off of the maximum size in B of an outlined // call versus the size in B of the MBB. - if (MBB.size() < 2) + if (MBB.size() < MinMBBSize) { + LLVM_DEBUG(dbgs() << " SKIP: MBB size less than minimum size of " + << MinMBBSize << "\n"); continue; + } // Check if MBB could be the target of an indirect branch. If it is, then // we don't want to outline from it. - if (MBB.hasAddressTaken()) + if (MBB.hasAddressTaken()) { + LLVM_DEBUG(dbgs() << " SKIP: MBB's address is taken\n"); continue; + } // MBB is suitable for outlining. Map it to a list of unsigneds. Mapper.convertToUnsignedVec(MBB, *TII); |