diff options
author | Fangrui Song <i@maskray.me> | 2023-06-15 16:12:10 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2023-06-15 16:12:10 -0700 |
commit | 4bdc7f7a331f82cca1637388cf68bdc5b32ab43b (patch) | |
tree | e60e9e115092f38c4794ca61b91fa42f882b45b2 /llvm/lib/MC/MCExpr.cpp | |
parent | 63eb7c4e6620279c63bd42d13177a94928cabb3c (diff) | |
download | llvm-4bdc7f7a331f82cca1637388cf68bdc5b32ab43b.zip llvm-4bdc7f7a331f82cca1637388cf68bdc5b32ab43b.tar.gz llvm-4bdc7f7a331f82cca1637388cf68bdc5b32ab43b.tar.bz2 |
[MC] Remove unneeded special cases from AttemptToFoldSymbolOffsetDifference
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index fc2c3ee..46a0367 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -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; @@ -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(); |