Skip to content

Commit ada137a

Browse files
committed
[MC] Remove unneeded MCDataFragment check from AttemptToFoldSymbolOffsetDifference
If FA == FB, we can use SA.getOffset() - SB.getOffset() even if FA is not a MCDataFragment, as the only case this can be problematic (different offsets for a variable-size fragment) is invalid/unreachable. If FA != FB, the `if (FI->getKind() != MCFragment::FT_Data)` check below can bail out correctly. This change will help Mach-O fold more expressions. For ELF this is NFC, unless evaluateFixup has a bug that would evaluate an expression differently.
1 parent c26c5e4 commit ada137a

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

llvm/lib/MC/MCExpr.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,6 @@ static void AttemptToFoldSymbolOffsetDifference(
651651
// this is important when the Subtarget is changed and a new MCDataFragment
652652
// is created in the case of foo: instr; .arch_extension ext; instr .if . -
653653
// foo.
654-
if (FA != FB && (!isa<MCDataFragment>(FA) || !isa<MCDataFragment>(FA)))
655-
return;
656654
if (SA.isVariable() || SB.isVariable() ||
657655
FA->getSubsectionNumber() != FB->getSubsectionNumber())
658656
return;

0 commit comments

Comments
 (0)