Skip to content

RISC-V LLVM feature +unaligned-scalar-mem not recognized by rustc #110883

Closed

Description

@korran

Example

// Compile with rustc --target riscv32imc-unknown-none-elf -C target-feature=+unaligned-scalar-mem --emit=obj
#![no_std]
#![no_main]

use core::panic::PanicInfo;

#[panic_handler]
fn panic(_info: &PanicInfo) -> ! {
    loop {}
}

Current output

warning: unknown feature specified for `-Ctarget-feature`: `unaligned-scalar-mem`
  |
  = note: it is still passed through to the codegen backend
  = help: consider filing a feature request

warning: 1 warning emitted

Desired output

No warning

Background / Rationale

Some RISC-V cores support unaligned access to memory without trapping. On such cores, the compiler could significantly improve code-size and performance when using functions like core::ptr::read_unaligned by emitting a single load or store instruction with an unaligned address, rather than a long sequence of byte-sized load/store/bitmanip instructions.

I need to use the unaligned-scalar-mem target feature to improve code-size and performance. When I set the flag -C target-feature=+unaligned-scalar-mem, LLVM successfully recognizes the target feature and generates the desired machine code, but rustc prints out the warning above, and I can't figure out how to disable it.

Activity

  1. added a commit that references this issue on Apr 27, 2023
    08f7e32
  2. added
    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
    O-riscvTarget: RISC-V architecture
    A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.
    on May 5, 2023
  3. added a commit that references this issue on May 18, 2023
    677da1c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.A-target-featureArea: Enabling/disabling target features like AVX, Neon, etc.O-riscvTarget: RISC-V architecture

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions