diff options
author | Jinyang He <hejinyang@loongson.cn> | 2024-01-03 09:28:25 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-03 09:28:25 +0800 |
commit | 0731567a31e4ade97c27801045156a88c4589704 (patch) | |
tree | bc84e8083bcc5d88d219a41ef1e65f14102aeafd /llvm/lib/MC/MCExpr.cpp | |
parent | 7d81e072712f4e6a150561b5538ccebda289aa13 (diff) | |
download | llvm-0731567a31e4ade97c27801045156a88c4589704.zip llvm-0731567a31e4ade97c27801045156a88c4589704.tar.gz llvm-0731567a31e4ade97c27801045156a88c4589704.tar.bz2 |
[MC][RISCV][LoongArch] Add AlignFragment size if layout is available and not need insert nops (#76552)
Due to delayed decision for ADD/SUB relocations, RISCV and LoongArch may
go slow fragment walk path with available layout. When RISCV (or
LoongArch in the future) don't need insert nops, that means relax is
disabled. With available layout and not needing insert nops, the size of
AlignFragment should be a constant. So we can add it to Displacement for
folding A-B.
Diffstat (limited to 'llvm/lib/MC/MCExpr.cpp')
-rw-r--r-- | llvm/lib/MC/MCExpr.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/MC/MCExpr.cpp b/llvm/lib/MC/MCExpr.cpp index a85182a..9dae026 100644 --- a/llvm/lib/MC/MCExpr.cpp +++ b/llvm/lib/MC/MCExpr.cpp @@ -704,8 +704,14 @@ static void AttemptToFoldSymbolOffsetDifference( } int64_t Num; + unsigned Count; if (DF) { Displacement += DF->getContents().size(); + } else if (auto *AF = dyn_cast<MCAlignFragment>(FI); + AF && Layout && + !Asm->getBackend().shouldInsertExtraNopBytesForCodeAlign( + *AF, Count)) { + Displacement += Asm->computeFragmentSize(*Layout, *AF); } else if (auto *FF = dyn_cast<MCFillFragment>(FI); FF && FF->getNumValues().evaluateAsAbsolute(Num)) { Displacement += Num * FF->getValueSize(); |