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
32 lines
1010 B
ArmAsm
32 lines
1010 B
ArmAsm
// RUN: llvm-mc -triple i386-apple-darwin9 %s -filetype=obj -o - | llvm-readobj -r - | FileCheck %s
|
|
|
|
_local_def:
|
|
.p2align 2
|
|
.globl _external_def
|
|
_external_def:
|
|
Ltemp:
|
|
ret
|
|
|
|
.data
|
|
.long _external_def - _local_def
|
|
.long Ltemp - _local_def
|
|
|
|
.long _local_def - _external_def
|
|
.long Ltemp - _external_def
|
|
|
|
.long _local_def - Ltemp
|
|
.long _external_def - Ltemp
|
|
|
|
// CHECK: Relocations [
|
|
// CHECK-NEXT: Section __data {
|
|
// CHECK-NEXT: 0x10 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x0
|
|
// CHECK-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x0
|
|
// CHECK-NEXT: 0x8 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x0
|
|
// CHECK-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x0
|
|
// CHECK-NEXT: 0x4 0 2 n/a GENERIC_RELOC_LOCAL_SECTDIFF 1 0x0
|
|
// CHECK-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x0
|
|
// CHECK-NEXT: 0x0 0 2 n/a GENERIC_RELOC_SECTDIFF 1 0x0
|
|
// CHECK-NEXT: 0x0 0 2 n/a GENERIC_RELOC_PAIR 1 0x0
|
|
// CHECK-NEXT: }
|
|
// CHECK-NEXT: ]
|