diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-05-26 20:37:03 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-05-26 20:37:03 +0000 |
commit | 2e0ec26ae45a6c00f6cc726ba4d42201b1c4b20e (patch) | |
tree | f5590f6433645f8c642157290eddafdd2c4c4cd3 | |
parent | 6b198ab40240bf7381c430ace076aad636953438 (diff) | |
download | external_llvm-2e0ec26ae45a6c00f6cc726ba4d42201b1c4b20e.zip external_llvm-2e0ec26ae45a6c00f6cc726ba4d42201b1c4b20e.tar.gz external_llvm-2e0ec26ae45a6c00f6cc726ba4d42201b1c4b20e.tar.bz2 |
MC: When running with -mc-relax-all, we can eagerly relax instructions and avoid creating unnecessary MCInstFragments.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104736 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/MCAssembler.cpp | 7 | ||||
-rw-r--r-- | lib/MC/MCMachOStreamer.cpp | 34 |
2 files changed, 20 insertions, 21 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 9c8268d..5936656 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -845,11 +845,8 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) { for (unsigned i = 0, e = Fixups.size(); i != e; ++i) IF->getFixups().push_back(Fixups[i]); - // Update the layout, and remember that we relaxed. If we are relaxing - // everything, we can skip this step since nothing will depend on updating - // the values. - if (!getRelaxAll()) - Layout.UpdateForSlide(IF, SlideAmount); + // Update the layout, and remember that we relaxed. + Layout.UpdateForSlide(IF, SlideAmount); WasRelaxed = true; } } diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 2f23ae3..27e4e98 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -463,23 +463,25 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { CurSectionData->setHasInstructions(true); - // See if we might need to relax this instruction, if so it needs its own - // fragment. - // - // FIXME-PERF: Support target hook to do a fast path that avoids the encoder, - // when we can immediately tell that we will get something which might need - // relaxation (and compute its size). - // - // FIXME-PERF: We should also be smart about immediately relaxing instructions - // which we can already show will never possibly fit (we can also do a very - // good job of this before we do the first relaxation pass, because we have - // total knowledge about undefined symbols at that point). Even now, though, - // we can do a decent job, especially on Darwin where scattering means that we - // are going to often know that we can never fully resolve a fixup. - if (Assembler.getBackend().MayNeedRelaxation(Inst)) - EmitInstToFragment(Inst); - else + // If this instruction doesn't need relaxation, just emit it as data. + if (!Assembler.getBackend().MayNeedRelaxation(Inst)) { EmitInstToData(Inst); + return; + } + + // Otherwise, if we are relaxing everything, relax the instruction as much as + // possible and emit it as data. + if (Assembler.getRelaxAll()) { + MCInst Relaxed; + Assembler.getBackend().RelaxInstruction(Inst, Relaxed); + while (Assembler.getBackend().MayNeedRelaxation(Relaxed)) + Assembler.getBackend().RelaxInstruction(Relaxed, Relaxed); + EmitInstToData(Relaxed); + return; + } + + // Otherwise emit to a separate fragment. + EmitInstToFragment(Inst); } void MCMachOStreamer::Finish() { |