#include <vector>
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
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");
uint64_t Start = OW->getStream().tell();
(void) Start;
- ++EmittedFragments;
+ ++stats::EmittedFragments;
// FIXME: Embed in fragments instead?
switch (F.getKind()) {
llvm::errs() << "assembler backend - final-layout\n--\n";
dump(); });
+ uint64_t StartOffset = OS.tell();
llvm::OwningPtr<MCObjectWriter> Writer(getBackend().createObjectWriter(OS));
if (!Writer)
llvm_report_error("unable to create object writer!");
// Write the object file.
Writer->WriteObject(*this);
OS.flush();
+
+ stats::ObjectBytes += OS.tell() - StartOffset;
}
bool MCAssembler::FixupNeedsRelaxation(const MCAsmFixup &Fixup,
}
bool MCAssembler::LayoutOnce(MCAsmLayout &Layout) {
+ ++stats::RelaxationSteps;
+
// Layout the concrete sections and fragments.
uint64_t Address = 0;
MCSectionData *Prev = 0;
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.
//
//===----------------------------------------------------------------------===//
+#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"
#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:
bool MCExpr::EvaluateAsRelocatable(MCValue &Res,
const MCAsmLayout *Layout) const {
+ ++stats::MCExprEvaluate;
+
switch (getKind()) {
case Target:
return cast<MCTargetExpr>(this)->EvaluateAsRelocatableImpl(Res, Layout);