Skip to content

Commit

Permalink
[MC] Remove unneeded special cases from AttemptToFoldSymbolOffsetDiff…
Browse files Browse the repository at this point in the history
…erence
  • Loading branch information
MaskRay committed Jun 15, 2023
1 parent 63eb7c4 commit 4bdc7f7
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions llvm/lib/MC/MCExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -619,17 +619,8 @@ static void AttemptToFoldSymbolOffsetDifference(

const MCFragment *FA = SA.getFragment();
const MCFragment *FB = SB.getFragment();
// If both symbols are in the same fragment, return the difference of their
// offsets
if (FA == FB && !SA.isVariable() && !SA.isUnset() && !SB.isVariable() &&
!SB.isUnset()) {
Addend += SA.getOffset() - SB.getOffset();
return FinalizeFolding();
}

const MCSection &SecA = *FA->getParent();
const MCSection &SecB = *FB->getParent();

if ((&SecA != &SecB) && !Addrs)
return;

Expand All @@ -654,11 +645,12 @@ 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 (SA.isVariable() || SA.isUnset() || SB.isVariable() || SB.isUnset() ||
FA->getKind() != MCFragment::FT_Data ||
FB->getKind() != MCFragment::FT_Data ||
if (FA != FB && (!isa<MCDataFragment>(FA) || !isa<MCDataFragment>(FA)))
return;
if (SA.isVariable() || SB.isVariable() ||
FA->getSubsectionNumber() != FB->getSubsectionNumber())
return;

// Try to find a constant displacement from FA to FB, add the displacement
// between the offset in FA of SA and the offset in FB of SB.
int64_t Displacement = SA.getOffset() - SB.getOffset();
Expand Down

0 comments on commit 4bdc7f7

Please sign in to comment.