Skip to content

Commit 8fa4fe1

Browse files
committed
[MC] AttemptToFoldSymbolOffsetDifference: remove MCDummyFragment check. NFC
This was added by 507efbc ([MC] Fold A-B when A is a pending label or A/B are separated by a MCFillFragment) to account for pending labels and is now unneeded after the removal of pending labels (7500646).
1 parent 170c194 commit 8fa4fe1

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

llvm/lib/MC/MCExpr.cpp

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -669,7 +669,7 @@ static void AttemptToFoldSymbolOffsetDifference(
669669
bool Reverse = false;
670670
if (FA == FB)
671671
Reverse = SA.getOffset() < SB.getOffset();
672-
else if (!isa<MCDummyFragment>(FA))
672+
else
673673
Reverse = FA->getLayoutOrder() < FB->getLayoutOrder();
674674

675675
uint64_t SAOffset = SA.getOffset(), SBOffset = SB.getOffset();
@@ -680,7 +680,6 @@ static void AttemptToFoldSymbolOffsetDifference(
680680
Displacement *= -1;
681681
}
682682

683-
[[maybe_unused]] bool Found = false;
684683
// Track whether B is before a relaxable instruction and whether A is after
685684
// a relaxable instruction. If SA and SB are separated by a linker-relaxable
686685
// instruction, the difference cannot be resolved as it may be changed by
@@ -697,8 +696,11 @@ static void AttemptToFoldSymbolOffsetDifference(
697696
return;
698697
}
699698
if (&*FI == FA) {
700-
Found = true;
701-
break;
699+
// If FA and FB belong to the same subsection, the loop will find FA and
700+
// we can resolve the difference.
701+
Addend += Reverse ? -Displacement : Displacement;
702+
FinalizeFolding();
703+
return;
702704
}
703705

704706
int64_t Num;
@@ -717,14 +719,6 @@ static void AttemptToFoldSymbolOffsetDifference(
717719
return;
718720
}
719721
}
720-
// If FA and FB belong to the same subsection, either the previous loop
721-
// found FA, or FA is a dummy fragment not in the fragment list (which means
722-
// SA is a pending label (see flushPendingLabels)) or FA and FB belong to
723-
// different subsections. In either case, we can resolve the difference.
724-
if (Found || isa<MCDummyFragment>(FA)) {
725-
Addend += Reverse ? -Displacement : Displacement;
726-
FinalizeFolding();
727-
}
728722
}
729723
}
730724

0 commit comments

Comments
 (0)