llvm-project/llvm/test/MC/VE/data-reloc-error.s
Fangrui Song 777391a216 MCFixup: Improve location accuracy and remove MCFixup::Loc
Remove the redundant MCFixup::Loc member and instead use MCExpr::Loc to
determine the location for fixups. Previously, many target MCCodeEmitter would
use the beginning of an instruction for fixup locations, which often
resulted in inaccurate column information.

```
// RISCVMCCodeEmitter::getImmOpValue
Fixups.push_back(MCFixup::create(0, Expr, FixupKind, MI.getLoc()));

// X86MCCodeEmitter::emitImmediate
Fixups.push_back(MCFixup::create(static_cast<uint32_t>(CB.size() - StartByte), Expr, FixupKind, Loc));
```

While MCExpr::Loc generally provides more meaningful location data,
tests should avoid over-relying on it. For instance, MCBinaryExpr's
location refers to its operator, and for operands with sigils (like
`$foo`), the location often omits the sigils.

https://llvm-compile-time-tracker.com/compare.php?from=8740ff822d462844506134bb7c425e1778518b95&to=831a11f75d22d64982b13dba132d656ac8567612&stat=instructions%3Au

I've also considered removing MCExpr::Loc (revert
https://reviews.llvm.org/D28861), but we'd lose too much information.
It's also difficult to carry location information to improve location
tracking in target MCCodeEmitter.

This change utilizes previous MCExpr::Loc improvement like
7e3e2e1b8c6ff21e68782a56164139cca334fcf3
7b517cf743f112f980cf6a4d6e6190c2a5b3e451
2025-07-04 12:06:28 -07:00

27 lines
1.1 KiB
ArmAsm

# RUN: not llvm-mc -filetype=obj -triple=ve %s -o /dev/null 2>&1 | \
# RUN: FileCheck %s
# RUN: not llvm-mc -filetype=obj -triple=ve -position-independent %s \
# RUN: -o /dev/null 2>&1 | FileCheck %s
.data
a:
## An undefined reference of _GLOBAL_OFFSET_TABLE_ causes .got[0] to be
## allocated to store _DYNAMIC.
.byte _GLOBAL_OFFSET_TABLE_
.byte _GLOBAL_OFFSET_TABLE_ - .
.2byte _GLOBAL_OFFSET_TABLE_
.2byte _GLOBAL_OFFSET_TABLE_ - .
.8byte _GLOBAL_OFFSET_TABLE_ - .
# CHECK: data-reloc-error.s:10:7: error: 1-byte data relocation is not supported
# CHECK-NEXT: .byte _GLOBAL_OFFSET_TABLE_
# CHECK: data-reloc-error.s:11:29: error: 1-byte pc-relative data relocation is not supported
# CHECK-NEXT: .byte _GLOBAL_OFFSET_TABLE_ - .
# CHECK: data-reloc-error.s:12:8: error: 2-byte data relocation is not supported
# CHECK-NEXT: .2byte _GLOBAL_OFFSET_TABLE_
# CHECK: data-reloc-error.s:13:30: error: 2-byte pc-relative data relocation is not supported
# CHECK-NEXT: .2byte _GLOBAL_OFFSET_TABLE_ - .
# CHECK: data-reloc-error.s:14:30: error: 8-byte pc-relative data relocation is not supported
# CHECK-NEXT: .8byte _GLOBAL_OFFSET_TABLE_ - .