diff options
author | Fangrui Song <i@maskray.me> | 2025-07-04 12:06:27 -0700 |
---|---|---|
committer | Fangrui Song <i@maskray.me> | 2025-07-04 12:06:28 -0700 |
commit | 777391a2164b89d2030ca013562151ca3c3676d1 (patch) | |
tree | d811f3d5d3ff0bc36df78b415f435a695ddd8db4 /flang/lib/Frontend/CompilerInvocation.cpp | |
parent | 833839ba65fddf2aea2d8f4687c0497eff5cd180 (diff) | |
download | llvm-777391a2164b89d2030ca013562151ca3c3676d1.zip llvm-777391a2164b89d2030ca013562151ca3c3676d1.tar.gz llvm-777391a2164b89d2030ca013562151ca3c3676d1.tar.bz2 |
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
Diffstat (limited to 'flang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions