diff options
author | Fangrui Song <i@maskray.me> | 2024-06-22 10:14:44 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2024-06-22 10:14:44 -0700 |
commit | 8fa4fe1f995a9bc85666d63e84c094f9a09686b5 (patch) | |
tree | 0f993792802571a031a672a5014c5152c3024311 /llvm | |
parent | 170c194ec19c76deee33d8aa8b288368c574f7a0 (diff) | |
download | llvm-8fa4fe1f995a9bc85666d63e84c094f9a09686b5.zip llvm-8fa4fe1f995a9bc85666d63e84c094f9a09686b5.tar.gz llvm-8fa4fe1f995a9bc85666d63e84c094f9a09686b5.tar.bz2 |
[MC] AttemptToFoldSymbolOffsetDifference: remove MCDummyFragment check. NFC
This was added by 507efbcce03d8c2c5dbea3028bc39f02c88fea79
([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 (75006466296ed4b0f845cbbec4bf77c21de43b40).
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index 2eecdb8..5cfb7b9 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -669,7 +669,7 @@ static void AttemptToFoldSymbolOffsetDifference( bool Reverse = false; if (FA == FB) Reverse = SA.getOffset() < SB.getOffset(); - else if (!isa<MCDummyFragment>(FA)) + else Reverse = FA->getLayoutOrder() < FB->getLayoutOrder(); uint64_t SAOffset = SA.getOffset(), SBOffset = SB.getOffset(); @@ -680,7 +680,6 @@ static void AttemptToFoldSymbolOffsetDifference( Displacement *= -1; } - [[maybe_unused]] bool Found = false; // Track whether B is before a relaxable instruction and whether A is after // a relaxable instruction. If SA and SB are separated by a linker-relaxable // instruction, the difference cannot be resolved as it may be changed by @@ -697,8 +696,11 @@ static void AttemptToFoldSymbolOffsetDifference( return; } if (&*FI == FA) { - Found = true; - break; + // If FA and FB belong to the same subsection, the loop will find FA and + // we can resolve the difference. + Addend += Reverse ? -Displacement : Displacement; + FinalizeFolding(); + return; } int64_t Num; @@ -717,14 +719,6 @@ static void AttemptToFoldSymbolOffsetDifference( return; } } - // If FA and FB belong to the same subsection, either the previous loop - // found FA, or FA is a dummy fragment not in the fragment list (which means - // SA is a pending label (see flushPendingLabels)) or FA and FB belong to - // different subsections. In either case, we can resolve the difference. - if (Found || isa<MCDummyFragment>(FA)) { - Addend += Reverse ? -Displacement : Displacement; - FinalizeFolding(); - } } } |