[all-commits] [llvm/llvm-project] fb294c: [MC] Fold A-B when A's fragment precedes B's fragment
Fangrui Song via All-commits
all-commits at lists.llvm.org
Thu Jun 22 12:24:33 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: fb294c0612a12f2a39be90df0c3a22f66d4ab9f7
https://github.com/llvm/llvm-project/commit/fb294c0612a12f2a39be90df0c3a22f66d4ab9f7
Author: Fangrui Song <i at maskray.me>
Date: 2023-06-22 (Thu, 22 Jun 2023)
Changed paths:
M llvm/lib/MC/MCExpr.cpp
M llvm/test/MC/AArch64/arm64-small-data-fixups.s
M llvm/test/MC/ARM/directive-if-subtraction.s
M llvm/test/MC/MachO/absolutize.s
M llvm/test/MC/MachO/darwin-x86_64-reloc.s
M llvm/test/MC/MachO/reloc-diff.s
Log Message:
-----------
[MC] Fold A-B when A's fragment precedes B's fragment
When the MCAssembler is non-null and the MCAsmLayout is null, we can fold A-B
when
* A and B are in the same fragment, or
* A's fragment suceeds B's fragment, and they are not separated by non-data fragments (D69411)
This patch allows folding when A's fragment precedes B's fragment so
that `9997b - . == 0` below can be evaluated as true:
```
nop
.arch_extension sec
9997:nop
// old behavior: error: expected absolute expression
.if 9997b - . == 0
.endif
```
Add a case to llvm/test/MC/ARM/directive-if-subtraction.s.
Note: for MCAsmStreamer, we cannot evaluate `.if . - 9997b == 0` at parse
time due to MCAsmStreamer::getAssemblerPtr returning nullptr (D45164).
Some Darwin tests check that this folding does not work. Add `.p2align 2` to
block some label difference folding or adjust the tests.
Reviewed By: nickdesaulniers
Differential Revision: https://reviews.llvm.org/D153096
More information about the All-commits
mailing list