[all-commits] [llvm/llvm-project] fe6fb9: [RISCV] Replace @plt/@gotpcrel in data directives ...

Fangrui Song via All-commits all-commits at lists.llvm.org
Sat Mar 29 11:08:35 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: fe6fb910df9d1b9a9e2e7a6e8228d020668e0129
      https://github.com/llvm/llvm-project/commit/fe6fb910df9d1b9a9e2e7a6e8228d020668e0129
  Author: Fangrui Song <i at maskray.me>
  Date:   2025-03-29 (Sat, 29 Mar 2025)

  Changed paths:
    M lld/test/ELF/riscv-reloc-plt32.s
    M lld/test/ELF/riscv-undefined-weak.s
    M lld/test/ELF/riscv64-reloc-got32-pcrel.s
    M llvm/include/llvm/CodeGen/AsmPrinter.h
    M llvm/include/llvm/CodeGen/TargetLoweringObjectFileImpl.h
    M llvm/include/llvm/MC/MCParser/MCTargetAsmParser.h
    M llvm/include/llvm/Target/TargetLoweringObjectFile.h
    M llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
    M llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
    M llvm/lib/MC/MCAssembler.cpp
    M llvm/lib/MC/MCParser/AsmParser.cpp
    M llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
    M llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.h
    M llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
    M llvm/lib/Target/AMDGPU/R600AsmPrinter.h
    M llvm/lib/Target/AMDGPU/R600MCInstLower.cpp
    M llvm/lib/Target/AVR/AVRAsmPrinter.cpp
    M llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCAsmInfo.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
    M llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h
    M llvm/lib/Target/RISCV/RISCVTargetObjectFile.cpp
    M llvm/lib/Target/RISCV/RISCVTargetObjectFile.h
    M llvm/test/CodeGen/RISCV/dso_local_equivalent.ll
    A llvm/test/CodeGen/RISCV/plt-relative-reloc.ll
    M llvm/test/MC/ELF/rtti-proxy-gotpcrel.ll
    M llvm/test/MC/RISCV/data-directive-specifier.s
    M llvm/test/MC/RISCV/pseudo-jump-invalid.s
    M llvm/test/MC/RISCV/rv32i-invalid.s

  Log Message:
  -----------
  [RISCV] Replace @plt/@gotpcrel in data directives with %pltpcrel %gotpcrel

clang -fexperimental-relative-c++-abi-vtables might generate `@plt` and
`@gotpcrel` specifiers in data directives. The syntax is not used in
humand-written assembly code, and is not supported by GNU assembler.
Note: the `@plt` in `.word foo at plt` is different from
the legacy `call func at plt` (where `@plt` is simply ignored).

The `@plt` syntax was selected was simply due to a quirk of AsmParser:
the syntax was supported by all targets until I updated it
to be an opt-in feature in a0671758eb6e52a758bd1b096a9b421eec60204c

RISC-V favors the `%specifier(expr)` syntax following MIPS and Sparc,
and we should follow this convention.

This PR adds support for `.word %pltpcrel(foo+offset)` and
`.word %gotpcrel(foo)`, and drops `@plt` and `@gotpcrel`.

* MCValue::SymA can no longer have a SymbolVariant. Add an assert
  similar to that of AArch64ELFObjectWriter.cpp before
  https://reviews.llvm.org/D81446 (see my analysis at
  https://maskray.me/blog/2025-03-16-relocation-generation-in-assemblers
  if intrigued)
* `jump foo at plt, x31` now has a different diagnostic.

Pull Request: https://github.com/llvm/llvm-project/pull/132569



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