[llvm] ada137a - [MC] Remove unneeded MCDataFragment check from AttemptToFoldSymbolOffsetDifference
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 18 16:00:22 PDT 2023
Author: Fangrui Song
Date: 2023-06-18T16:00:18-07:00
New Revision: ada137a4c2a292c34927f0f22bd4c6fba4d3df87
URL: https://github.com/llvm/llvm-project/commit/ada137a4c2a292c34927f0f22bd4c6fba4d3df87
DIFF: https://github.com/llvm/llvm-project/commit/ada137a4c2a292c34927f0f22bd4c6fba4d3df87.diff
LOG: [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.
Added:
Modified:
llvm/lib/MC/MCExpr.cpp
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp
index df305c843047d..3d47a52d8a3b1 100644
--- a/llvm/lib/MC/MCExpr.cpp
+++ b/llvm/lib/MC/MCExpr.cpp
@@ -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;
More information about the llvm-commits
mailing list