diff options
Diffstat (limited to 'llvm/lib/MC/MCMachOStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCMachOStreamer.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCMachOStreamer.cpp b/llvm/lib/MC/MCMachOStreamer.cpp index 2a1aa273014..9141a903dd9 100644 --- a/llvm/lib/MC/MCMachOStreamer.cpp +++ b/llvm/lib/MC/MCMachOStreamer.cpp @@ -18,6 +18,8 @@ #include "llvm/MC/MCSymbol.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" +#include "llvm/Target/TargetAsmBackend.h" + using namespace llvm; namespace { @@ -391,6 +393,32 @@ void MCMachOStreamer::EmitInstruction(const MCInst &Inst) { F.getKind())); } + // 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, AsmFixups)) { + MCInstFragment *IF = new MCInstFragment(Inst, CurSectionData); + + // Add the fixups and data. + // + // FIXME: Revisit this design decision when relaxation is done, we may be + // able to get away with not storing any extra data in the MCInst. + IF->getCode() = Code; + IF->getFixups() = AsmFixups; + + return; + } + // Add the fixups and data. MCDataFragment *DF = getOrCreateDataFragment(); for (unsigned i = 0, e = AsmFixups.size(); i != e; ++i) { |