Skip to content

Commit 3aa41e0

Browse files
committed
[X86,MC] Remove two getPrevNode
Make it more feasible to replace the fragment reprsentation, which might yield a large peak RSS win.
1 parent 1fe4f2d commit 3aa41e0

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -406,16 +406,10 @@ static bool
406406
isRightAfterData(MCFragment *CurrentFragment,
407407
const std::pair<MCFragment *, size_t> &PrevInstPosition) {
408408
MCFragment *F = CurrentFragment;
409-
// Empty data fragments may be created to prevent further data being
410-
// added into the previous fragment, we need to skip them since they
411-
// have no contents.
412-
for (; isa_and_nonnull<MCDataFragment>(F); F = F->getPrevNode())
413-
if (cast<MCDataFragment>(F)->getContents().size() != 0)
414-
break;
415-
416409
// Since data is always emitted into a DataFragment, our check strategy is
417410
// simple here.
418411
// - If the fragment is a DataFragment
412+
// - If it's empty (section start or data after align), return false.
419413
// - If it's not the fragment where the previous instruction is,
420414
// returns true.
421415
// - If it's the fragment holding the previous instruction but its
@@ -424,8 +418,9 @@ isRightAfterData(MCFragment *CurrentFragment,
424418
// - Otherwise returns false.
425419
// - If the fragment is not a DataFragment, returns false.
426420
if (auto *DF = dyn_cast_or_null<MCDataFragment>(F))
427-
return DF != PrevInstPosition.first ||
428-
DF->getContents().size() != PrevInstPosition.second;
421+
return DF->getContents().size() &&
422+
(DF != PrevInstPosition.first ||
423+
DF->getContents().size() != PrevInstPosition.second);
429424

430425
return false;
431426
}
@@ -526,7 +521,7 @@ void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
526521
if (!CanPadInst)
527522
return;
528523

529-
if (PendingBA && OS.getCurrentFragment()->getPrevNode() == PendingBA) {
524+
if (PendingBA && PendingBA->getNextNode() == OS.getCurrentFragment()) {
530525
// Macro fusion actually happens and there is no other fragment inserted
531526
// after the previous instruction.
532527
//

0 commit comments

Comments
 (0)