Skip to content

Commit

Permalink
[MC] Remove unneeded MCDataFragment check from AttemptToFoldSymbolOff…
Browse files Browse the repository at this point in the history
…setDifference

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.
  • Loading branch information
MaskRay committed Jun 18, 2023
1 parent c26c5e4 commit ada137a
Showing 1 changed file with 0 additions and 2 deletions.
2 changes: 0 additions & 2 deletions llvm/lib/MC/MCExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,8 +651,6 @@ static void AttemptToFoldSymbolOffsetDifference(
// this is important when the Subtarget is changed and a new MCDataFragment
// is created in the case of foo: instr; .arch_extension ext; instr .if . -
// foo.
if (FA != FB && (!isa<MCDataFragment>(FA) || !isa<MCDataFragment>(FA)))
return;
if (SA.isVariable() || SB.isVariable() ||
FA->getSubsectionNumber() != FB->getSubsectionNumber())
return;
Expand Down

0 comments on commit ada137a

Please sign in to comment.