[llvm] 8fa4fe1 - [MC] AttemptToFoldSymbolOffsetDifference: remove MCDummyFragment check. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Jun 22 10:14:49 PDT 2024
Author: Fangrui Song
Date: 2024-06-22T10:14:44-07:00
New Revision: 8fa4fe1f995a9bc85666d63e84c094f9a09686b5
URL: https://github.com/llvm/llvm-project/commit/8fa4fe1f995a9bc85666d63e84c094f9a09686b5
DIFF: https://github.com/llvm/llvm-project/commit/8fa4fe1f995a9bc85666d63e84c094f9a09686b5.diff
LOG: [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).
Added:
Modified:
llvm/lib/MC/MCExpr.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index 2eecdb82d30bb..5cfb7b9becd1d 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
diff erence 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
diff erence.
+ 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
- //
diff erent subsections. In either case, we can resolve the
diff erence.
- if (Found || isa<MCDummyFragment>(FA)) {
- Addend += Reverse ? -Displacement : Displacement;
- FinalizeFolding();
- }
}
}
More information about the llvm-commits
mailing list