1
Fork 0
rust/compiler/rustc_codegen_ssa/src
Yuki Okushi 5af6385f9f
Rollup merge of #109860 - zyedidia:riscv-relax, r=petrochenkov
Add support for RISC-V relax target feature

This adds `relax` as an allowed RISC-V target feature. The relax feature in LLVM enables [linker relaxation](https://www.sifive.com/blog/all-aboard-part-3-linker-relaxation-in-riscv-toolchain), an optimization specific to RISC-V that allows global variable accesses to be resolved by the linker by using the global pointer (`gp`) register (rather than constructing the addresses from scratch for each access). Enabling `relax` will cause LLVM to emit relocations in the object file that support this. The feature can be enabled in rustc with `-C target-feature=+relax`.

Currently this feature is disabled by default, but maybe it should be enabled by default since it is an easy performance improvement (but requires the `gp` register to be set up properly). GCC/Clang enable this feature by default (for both hosted/bare-metal targets), and include the `-mno-relax` flag to disable it (see [here](466d554dca/clang/lib/Driver/ToolChains/Arch/RISCV.cpp (L145)) for the code that enables it in Clang). I think it would make sense to enable by default, at least for all hosted targets since the `gp` register should be automatically set up by the runtime. For bare-metal targets, `gp` must be set up manually, so it is probably best to leave off by default to avoid breaking existing applications that do not set up `gp`. Leaving it disabled by default for all targets is also reasonable though.

Let me know your thoughts. Thanks!

Fixes #109426.
2023-04-11 12:18:50 +09:00
..
back Migrate sess.opts.tests uses to sess.is_test_crate() 2023-04-09 21:37:31 +02:00
coverageinfo Use &IndexSlice instead of &IndexVec where possible 2023-04-02 17:35:37 -07:00
debuginfo s/eval_usize/eval_target_usize/ for clarity 2023-02-14 08:51:19 +00:00
mir Rollup merge of #110021 - scottmcm:fix-110005, r=compiler-errors 2023-04-10 14:13:14 +05:30
traits Allow transmutes to produce OperandValues instead of always using allocas 2023-04-04 18:44:29 -07:00
base.rs Use FieldIdx in various things related to aggregates 2023-04-01 20:32:50 -07:00
codegen_attrs.rs Skip no_mangle if the item has no name. 2023-03-28 18:05:12 +00:00
common.rs DELETE - fn span_invalid_monomorphization_error and localize intrinsics macros 2022-12-27 20:59:22 -05:00
errors.rs errors: generate typed identifiers in each crate 2023-02-22 09:15:53 +00:00
glue.rs Use size_of_val instead of manual calculation 2023-03-17 19:55:49 -07:00
lib.rs Stabilize a portion of 'once_cell' 2023-03-29 18:04:44 -04:00
meth.rs rustc: Remove needless lifetimes 2022-12-20 22:10:40 +01:00
mono_item.rs Store a LocalDefId in hir::AnonConst. 2022-11-13 14:06:11 +00:00
target_features.rs Add riscv relax target feature 2023-04-02 07:30:42 -07:00