Skip to content

Commit 58d16db

Browse files
committed
MCAssembler: Simplify relaxation of FT_Fill and FT_Org
1 parent b1d58f0 commit 58d16db

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

llvm/include/llvm/MC/MCSection.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ class MCFillFragment : public MCFragment {
307307
uint64_t Value;
308308
/// The number of bytes to insert.
309309
const MCExpr &NumValues;
310-
uint64_t Size = 0;
311310

312311
/// Source location of the directive that this fragment was created for.
313312
SMLoc Loc;
@@ -321,8 +320,6 @@ class MCFillFragment : public MCFragment {
321320
uint64_t getValue() const { return Value; }
322321
uint8_t getValueSize() const { return ValueSize; }
323322
const MCExpr &getNumValues() const { return NumValues; }
324-
uint64_t getSize() const { return Size; }
325-
void setSize(uint64_t Value) { Size = Value; }
326323

327324
SMLoc getLoc() const { return Loc; }
328325

@@ -371,16 +368,12 @@ class MCOrgFragment : public MCFragment {
371368
/// Source location of the directive that this fragment was created for.
372369
SMLoc Loc;
373370

374-
uint64_t Size = 0;
375-
376371
public:
377372
MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
378373
: MCFragment(FT_Org), Value(Value), Offset(&Offset), Loc(Loc) {}
379374

380375
const MCExpr &getOffset() const { return *Offset; }
381376
uint8_t getValue() const { return Value; }
382-
uint64_t getSize() const { return Size; }
383-
void setSize(uint64_t Value) { Size = Value; }
384377

385378
SMLoc getLoc() const { return Loc; }
386379

llvm/lib/MC/MCAssembler.cpp

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ void MCAssembler::relaxDwarfCallFrameFragment(MCFragment &F) {
915915
}
916916

917917
bool MCAssembler::relaxFragment(MCFragment &F) {
918-
size_t Size = computeFragmentSize(F);
918+
auto Size = computeFragmentSize(F);
919919
switch (F.getKind()) {
920920
default:
921921
return false;
@@ -943,20 +943,9 @@ bool MCAssembler::relaxFragment(MCFragment &F) {
943943
getContext().getCVContext().encodeDefRange(
944944
*this, static_cast<MCCVDefRangeFragment &>(F));
945945
break;
946-
case MCFragment::FT_Fill: {
947-
auto &FF = static_cast<MCFillFragment &>(F);
948-
if (FF.getSize() == Size)
949-
return false;
950-
FF.setSize(Size);
951-
return true;
952-
}
953-
case MCFragment::FT_Org: {
954-
auto &FF = static_cast<MCOrgFragment &>(F);
955-
if (FF.getSize() == Size)
956-
return false;
957-
FF.setSize(Size);
958-
return true;
959-
}
946+
case MCFragment::FT_Fill:
947+
case MCFragment::FT_Org:
948+
return F.getNext()->Offset - F.Offset != Size;
960949
}
961950
return computeFragmentSize(F) != Size;
962951
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# CHECK-NEXT:5 LEB Size:0+1 [15] Value:.Ltmp0-_start Signed:0
3131
# CHECK:]
3232

33-
# CHECK: 3 assembler - Number of fixup evaluations for relaxation
33+
# CHECK: 2 assembler - Number of fixup evaluations for relaxation
3434
# CHECK: 8 assembler - Number of fixups
3535

3636
# 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

0 commit comments

Comments
 (0)