diff options
author | Daniel Dunbar <daniel@zuster.org> | 2010-03-25 22:49:09 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2010-03-25 22:49:09 +0000 |
commit | ac2884a717daf3ad2aa8425320795d661e8a980b (patch) | |
tree | f04ee17becb8ac8f77d5f76f433164be88344756 /lib/MC | |
parent | 2d2898e6e99a5a4a16352b86070fa0986b7d1efd (diff) | |
download | external_llvm-ac2884a717daf3ad2aa8425320795d661e8a980b.zip external_llvm-ac2884a717daf3ad2aa8425320795d661e8a980b.tar.gz external_llvm-ac2884a717daf3ad2aa8425320795d661e8a980b.tar.bz2 |
llvm-mc: Add a -mc-relax-all option, which relaxes every fixup. We always need
exactly two passes in that case, and don't ever need to recompute any layout,
so this is a nice baseline for relaxation performance.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99563 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC')
-rw-r--r-- | lib/MC/MCAssembler.cpp | 24 | ||||
-rw-r--r-- | lib/MC/MCMachOStreamer.cpp | 10 |
2 files changed, 26 insertions, 8 deletions
diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index 79a8436..03b8bd3 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -19,9 +19,9 @@ #include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/Twine.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/raw_ostream.h" -#include "llvm/Support/Debug.h" #include "llvm/Target/TargetRegistry.h" #include "llvm/Target/TargetAsmBackend.h" @@ -30,11 +30,13 @@ using namespace llvm; namespace { namespace stats { -STATISTIC(RelaxedInstructions, "Number of relaxed instructions"); -STATISTIC(RelaxationSteps, "Number of assembler layout and relaxation steps"); STATISTIC(EmittedFragments, "Number of emitted assembler fragments"); STATISTIC(EvaluateFixup, "Number of evaluated fixups"); +STATISTIC(FragmentLayouts, "Number of fragment layouts"); STATISTIC(ObjectBytes, "Number of emitted object file bytes"); +STATISTIC(RelaxationSteps, "Number of assembler layout and relaxation steps"); +STATISTIC(RelaxedInstructions, "Number of relaxed instructions"); +STATISTIC(SectionLayouts, "Number of section layouts"); } } @@ -185,7 +187,7 @@ MCSymbolData::MCSymbolData(const MCSymbol &_Symbol, MCFragment *_Fragment, MCAssembler::MCAssembler(MCContext &_Context, TargetAsmBackend &_Backend, MCCodeEmitter &_Emitter, raw_ostream &_OS) : Context(_Context), Backend(_Backend), Emitter(_Emitter), - OS(_OS), SubsectionsViaSymbols(false) + OS(_OS), RelaxAll(false), SubsectionsViaSymbols(false) { } @@ -402,6 +404,8 @@ uint64_t MCAssembler::LayoutSection(MCSectionData &SD, uint64_t StartAddress) { bool IsVirtual = getBackend().isVirtualSection(SD.getSection()); + ++stats::SectionLayouts; + // Align this section if necessary by adding padding bytes to the previous // section. It is safe to adjust this out-of-band, because no symbol or // fragment is allowed to point past the end of the section at any time. @@ -426,6 +430,8 @@ uint64_t MCAssembler::LayoutSection(MCSectionData &SD, for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) { MCFragment &F = *it; + ++stats::FragmentLayouts; + uint64_t FragmentOffset = Address - StartAddress; Layout.setFragmentOffset(&F, FragmentOffset); @@ -699,6 +705,9 @@ void MCAssembler::Finish() { bool MCAssembler::FixupNeedsRelaxation(const MCAsmFixup &Fixup, const MCFragment *DF, const MCAsmLayout &Layout) const { + if (getRelaxAll()) + return true; + // If we cannot resolve the fixup value, it requires relaxation. MCValue Target; uint64_t Value; @@ -791,8 +800,11 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) { F.getKind())); } - // Update the layout, and remember that we relaxed. - Layout.UpdateForSlide(IF, SlideAmount); + // 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); WasRelaxed = true; } } diff --git a/lib/MC/MCMachOStreamer.cpp b/lib/MC/MCMachOStreamer.cpp index 9141a90..120f837 100644 --- a/lib/MC/MCMachOStreamer.cpp +++ b/lib/MC/MCMachOStreamer.cpp @@ -75,6 +75,8 @@ public: CurSectionData(0) {} ~MCMachOStreamer() {} + MCAssembler &getAssembler() { return Assembler; } + const MCExpr *AddValueSymbols(const MCExpr *Value) { switch (Value->getKind()) { case MCExpr::Target: assert(0 && "Can't handle target exprs yet!"); @@ -433,6 +435,10 @@ void MCMachOStreamer::Finish() { } MCStreamer *llvm::createMachOStreamer(MCContext &Context, TargetAsmBackend &TAB, - raw_ostream &OS, MCCodeEmitter *CE) { - return new MCMachOStreamer(Context, TAB, OS, CE); + raw_ostream &OS, MCCodeEmitter *CE, + bool RelaxAll) { + MCMachOStreamer *S = new MCMachOStreamer(Context, TAB, OS, CE); + if (RelaxAll) + S->getAssembler().setRelaxAll(true); + return S; } |