@@ -406,16 +406,10 @@ static bool
406
406
isRightAfterData (MCFragment *CurrentFragment,
407
407
const std::pair<MCFragment *, size_t > &PrevInstPosition) {
408
408
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
-
416
409
// Since data is always emitted into a DataFragment, our check strategy is
417
410
// simple here.
418
411
// - If the fragment is a DataFragment
412
+ // - If it's empty (section start or data after align), return false.
419
413
// - If it's not the fragment where the previous instruction is,
420
414
// returns true.
421
415
// - If it's the fragment holding the previous instruction but its
@@ -424,8 +418,9 @@ isRightAfterData(MCFragment *CurrentFragment,
424
418
// - Otherwise returns false.
425
419
// - If the fragment is not a DataFragment, returns false.
426
420
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 );
429
424
430
425
return false ;
431
426
}
@@ -526,7 +521,7 @@ void X86AsmBackend::emitInstructionBegin(MCObjectStreamer &OS,
526
521
if (!CanPadInst)
527
522
return ;
528
523
529
- if (PendingBA && OS. getCurrentFragment ()-> getPrevNode () == PendingBA ) {
524
+ if (PendingBA && PendingBA-> getNextNode () == OS. getCurrentFragment () ) {
530
525
// Macro fusion actually happens and there is no other fragment inserted
531
526
// after the previous instruction.
532
527
//
0 commit comments