Skip to content

Commit 1db2879

Browse files
committed
MCAssembler: Split evaluateFixup to Number of fixups and Number of fixup evaluations for relaxation
The number of fixups is a more important metric, guiding the data structure optimization.
1 parent 0988510 commit 1db2879

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

llvm/lib/MC/MCAssembler.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ STATISTIC(EmittedFillFragments,
5959
"Number of emitted assembler fragments - fill");
6060
STATISTIC(EmittedNopsFragments, "Number of emitted assembler fragments - nops");
6161
STATISTIC(EmittedOrgFragments, "Number of emitted assembler fragments - org");
62-
STATISTIC(evaluateFixup, "Number of evaluated fixups");
62+
STATISTIC(Fixups, "Number of fixups");
63+
STATISTIC(FixupEvalForRelax, "Number of fixup evaluations for relaxation");
6364
STATISTIC(ObjectBytes, "Number of emitted object file bytes");
6465
STATISTIC(RelaxationSteps, "Number of assembler layout and relaxation steps");
6566
STATISTIC(RelaxedInstructions, "Number of relaxed instructions");
@@ -142,7 +143,8 @@ bool MCAssembler::evaluateFixup(const MCFragment &F, MCFixup &Fixup,
142143
MCValue &Target, uint64_t &Value,
143144
bool RecordReloc,
144145
MutableArrayRef<char> Contents) const {
145-
++stats::evaluateFixup;
146+
if (RecordReloc)
147+
++stats::Fixups;
146148

147149
// FIXME: This code has some duplication with recordRelocation. We should
148150
// probably merge the two into a single callback that tries to evaluate a
@@ -735,7 +737,7 @@ void MCAssembler::Finish() {
735737

736738
bool MCAssembler::fixupNeedsRelaxation(const MCFragment &F,
737739
const MCFixup &Fixup) const {
738-
assert(getBackendPtr() && "Expected assembler backend");
740+
++stats::FixupEvalForRelax;
739741
MCValue Target;
740742
uint64_t Value;
741743
bool Resolved = evaluateFixup(F, const_cast<MCFixup &>(Fixup), Target, Value,

llvm/test/MC/ELF/mc-dump.s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# REQUIRES: asserts
2-
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t -debug-only=mc-dump-pre,mc-dump 2>&1 | FileCheck %s --match-full-lines --strict-whitespace
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t -debug-only=mc-dump-pre,mc-dump -stats 2>&1 | FileCheck %s --match-full-lines --strict-whitespace
33

44
#CHECK-LABEL:assembler backend - pre-layout
55
# CHECK:MCSection Name:.text
@@ -30,6 +30,9 @@
3030
# CHECK-NEXT:5 LEB Size:0+1 [15] Value:.Ltmp0-_start Signed:0
3131
# CHECK:]
3232

33+
# CHECK: 2 assembler - Number of fixup evaluations for relaxation
34+
# CHECK: 8 assembler - Number of fixups
35+
3336
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t -debug-only=mc-dump -save-temp-labels -g 2>&1 | FileCheck %s --check-prefix=CHECK2
3437

3538
# CHECK2:5 Data Size:16 [48,8b,04,25,00,00,00,00,48,8b,04,25,00,00,00,00]

0 commit comments

Comments
 (0)