From: Daniel Dunbar Date: Tue, 23 Mar 2010 23:47:14 +0000 (+0000) Subject: MC: Sprinkle in some more interesting statistics. X-Git-Tag: android-x86-6.0-r1~1003^2~8265 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=ff54784683591b2cdbdc18690aeac12c8d87f97b;p=android-x86%2Fexternal-llvm.git MC: Sprinkle in some more interesting statistics. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@99350 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/MC/MCAssembler.cpp b/lib/MC/MCAssembler.cpp index b665cdff83e..a168abc02ec 100644 --- a/lib/MC/MCAssembler.cpp +++ b/lib/MC/MCAssembler.cpp @@ -28,7 +28,15 @@ #include 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(ObjectBytes, "Number of emitted object file bytes"); +} +} // FIXME FIXME FIXME: There are number of places in this file where we convert // what is a 64-bit assembler value used for computation into a value in the @@ -234,6 +242,8 @@ const MCSymbolData *MCAssembler::getAtom(const MCSymbolData *SD) const { bool MCAssembler::EvaluateFixup(const MCAsmLayout &Layout, const MCAsmFixup &Fixup, const MCFragment *DF, MCValue &Target, uint64_t &Value) const { + ++stats::EvaluateFixup; + if (!Fixup.Value->EvaluateAsRelocatable(Target, &Layout)) llvm_report_error("expected relocatable expression"); @@ -376,7 +386,7 @@ static void WriteFragmentData(const MCAssembler &Asm, const MCFragment &F, uint64_t Start = OW->getStream().tell(); (void) Start; - ++EmittedFragments; + ++stats::EmittedFragments; // FIXME: Embed in fragments instead? switch (F.getKind()) { @@ -505,6 +515,7 @@ void MCAssembler::Finish() { llvm::errs() << "assembler backend - final-layout\n--\n"; dump(); }); + uint64_t StartOffset = OS.tell(); llvm::OwningPtr Writer(getBackend().createObjectWriter(OS)); if (!Writer) llvm_report_error("unable to create object writer!"); @@ -543,6 +554,8 @@ void MCAssembler::Finish() { // Write the object file. Writer->WriteObject(*this); OS.flush(); + + stats::ObjectBytes += OS.tell() - StartOffset; } bool MCAssembler::FixupNeedsRelaxation(const MCAsmFixup &Fixup, @@ -575,6 +588,8 @@ bool MCAssembler::FragmentNeedsRelaxation(const MCInstFragment *IF, } bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) { + ++stats::RelaxationSteps; + // Layout the concrete sections and fragments. uint64_t Address = 0; MCSectionData *Prev = 0; @@ -629,6 +644,8 @@ bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) { if (!IF || !FragmentNeedsRelaxation(IF, Layout)) continue; + ++stats::RelaxedInstructions; + // FIXME-PERF: We could immediately lower out instructions if we can tell // they are fully resolved, to avoid retesting on later passes. diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index d0025f3f3f6..a9256b632e2 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -7,7 +7,9 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "mcexpr" #include "llvm/MC/MCExpr.h" +#include "llvm/ADT/Statistic.h" #include "llvm/ADT/StringSwitch.h" #include "llvm/MC/MCAsmLayout.h" #include "llvm/MC/MCAssembler.h" @@ -19,6 +21,12 @@ #include "llvm/Target/TargetAsmBackend.h" using namespace llvm; +namespace { +namespace stats { +STATISTIC(MCExprEvaluate, "Number of MCExpr evaluations"); +} +} + void MCExpr::print(raw_ostream &OS) const { switch (getKind()) { case MCExpr::Target: @@ -231,6 +239,8 @@ static bool EvaluateSymbolicAdd(const MCValue &LHS,const MCSymbolRefExpr *RHS_A, bool MCExpr::EvaluateAsRelocatable(MCValue &Res, const MCAsmLayout *Layout) const { + ++stats::MCExprEvaluate; + switch (getKind()) { case Target: return cast(this)->EvaluateAsRelocatableImpl(Res, Layout);