[PATCH] D127972: [AsmPrinter] Further restrict expressions supported in global initializers

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 28 00:22:47 PDT 2022


MaskRay added a comment.

In D127972#3613450 <https://reviews.llvm.org/D127972#3613450>, @lattner wrote:

> Oh no it isn't a magic relocation, it is because the assembler knows the offset between the L labels and so can constant fold it, that seems fine.

Right. For `(LBB0 - (LCPI0_0 + 4))`, when `MCAsmLayout` is available, MC knows that LHS and RHS are defined relative to the same section. The expression folds to a constant. (In RISC-V with linker relaxation, this can't).
Then, `(LBB0 - (LCPI0_0 + 4)) / 2` can be folded to a constant.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127972/new/

https://reviews.llvm.org/D127972



More information about the llvm-commits mailing list