[all-commits] [llvm/llvm-project] 777391: MCFixup: Improve location accuracy and remove MCFi...

Fangrui Song via All-commits all-commits at lists.llvm.org
Fri Jul 4 12:06:51 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 777391a2164b89d2030ca013562151ca3c3676d1
      https://github.com/llvm/llvm-project/commit/777391a2164b89d2030ca013562151ca3c3676d1
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-07-04 (Fri, 04 Jul 2025)

  Changed paths:
    M llvm/include/llvm/MC/MCFixup.h
    M llvm/lib/MC/MCAssembler.cpp
    M llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
    M llvm/test/MC/AArch64/coff-relocations-branch26.s
    M llvm/test/MC/AArch64/coff-relocations-diags.s
    M llvm/test/MC/AArch64/ilp32-diagnostics.s
    M llvm/test/MC/AMDGPU/max-branch-distance.s
    M llvm/test/MC/ARM/Windows/branch-reloc-offset.s
    M llvm/test/MC/ARM/Windows/invalid-relocation.s
    M llvm/test/MC/ARM/arm-memory-instructions-immediate.s
    M llvm/test/MC/ARM/lower-upper-errors-2.s
    M llvm/test/MC/ARM/pcrel-ldrd-diff-section.s
    M llvm/test/MC/ARM/pcrel-vldr-diff-section.s
    M llvm/test/MC/ARM/quad-relocation.s
    M llvm/test/MC/ARM/t2-modified-immediate-fixup-error1.s
    M llvm/test/MC/ARM/thumb1-relax-adr.s
    M llvm/test/MC/ARM/thumb1-relax-bcc.s
    M llvm/test/MC/ARM/thumb1-relax-br.s
    M llvm/test/MC/ARM/thumb1-relax-ldrlit.s
    M llvm/test/MC/ELF/bad-expr.s
    M llvm/test/MC/ELF/relocation-alias.s
    M llvm/test/MC/ELF/weakref.s
    M llvm/test/MC/LoongArch/Relocations/fixups-diagnostics.s
    M llvm/test/MC/Mips/reloc-directive-bad-obj.s
    M llvm/test/MC/Mips/unsupported-relocation.s
    M llvm/test/MC/RISCV/Relocations/data-directive-specifier.s
    M llvm/test/MC/RISCV/Relocations/expr-err.s
    M llvm/test/MC/RISCV/fixups-diagnostics.s
    M llvm/test/MC/RISCV/option-exact-long-jump-disable.s
    M llvm/test/MC/RISCV/pcrel-lo12-invalid.s
    M llvm/test/MC/RISCV/rv32-relaxation-xqci.s
    M llvm/test/MC/RISCV/xandesperf-fixups-diagnostics.s
    M llvm/test/MC/VE/data-reloc-error.s
    M llvm/test/MC/X86/macho-reloc-errors-x86.s
    M llvm/test/MC/X86/macho-reloc-errors-x86_64.s
    M llvm/test/MC/X86/pltoff.s
    M llvm/test/MC/Xtensa/Relocations/fixups-diagnostics.s

  Log Message:
  -----------
  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



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list