about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/LLVMWrapper.h
AgeCommit message (Collapse)AuthorLines
2024-11-09Auto merge of #132584 - Zalathar:includes, r=cuviperbors-89/+9
Trim and tidy includes in `rustc_llvm` These includes tend to accumulate over time, and are usually only removed when something breaks in a new LLVM version, so it's nice to clean them up manually once in a while. General strategy used for this PR: - Remove all includes from `LLVMWrapper.h` that aren't needed by the header itself, transplanting them to individual source files as necessary. - For each source file, temporarily remove each include if doing so doesn't cause a compile error. - If a “required” include looks like it shouldn't be needed, try replacing it with its sub-includes, then trim that list. - After doing all of the above, go back and re-add any removed include if the file does actually use things defined in that header, even if the header happens to also be included by something else.
2024-11-09Make `RustString` an extern type to avoid `improper_ctypes` warningsZalathar-2/+3
2024-11-04Trim and tidy includes in `rustc_llvm`Zalathar-44/+9
2024-11-04Move `LLVMRustAttribute[Kind]` out of `LLVMWrapper.h`Zalathar-45/+0
2024-09-16rustc_llvm: update for ↵Augie Fackler-1/+6
llvm/llvm-project@2ae968a0d9fb61606b020e898d884c82dd0ed8b5 Just a simple header move. @rustbot label: +llvm-main
2024-04-25Set writable and dead_on_unwind attributes for sret argumentsNikita Popov-0/+2
2024-01-30Remove `ffi_returns_twice` featureclubby789-1/+0
2023-12-06Rollup merge of #118177 - sivadeilra:suppress-llvm-warnings, r=cuviperMatthias Krüger-0/+2
Suppress warnings in LLVM wrapper when targeting MSVC The LLVM header files generate many warnings when compiled using MSVC. This makes it difficult to work on the LLVM wrapper code, because the warnings and errors that are relevant to local edits are obscured by the hundreds of lines of warnings from the LLVM Headers.
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-0/+1
This is intended to be used for Linux kernel RETHUNK builds. With this commit (optionally backported to Rust 1.73.0), plus a patched Linux kernel to pass the flag, I get a RETHUNK build with Rust enabled that is `objtool`-warning-free and is able to boot in QEMU and load a sample Rust kernel module. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2023-11-22suppress warnings on msvcArlie Davis-0/+2
2023-11-21Update the minimum external LLVM to 16.Dario Nieuwenhuis-4/+0
2023-11-07llvm-wrapper: Remove include of non-existant Vectorize.hHans Wennborg-1/+0
2023-08-08remove llvm-wrapper include to silence deprecation warningRémy Rakic-1/+0
Includes of `include/llvm/Support/Host.h` now emit a deprecated warning: `warning: This header is deprecated, please use llvm/TargetParser/Host.h`.
2023-07-27Update the minimum external LLVM to 15Josh Stone-2/+0
2023-05-26Add SafeStack support to rustcWesley Wiser-0/+1
Adds support for LLVM [SafeStack] which provides backward edge control flow protection by separating the stack into two parts: data which is only accessed in provable safe ways is allocated on the normal stack (the "safe stack") and all other data is placed in a separate allocation (the "unsafe stack"). SafeStack support is enabled by passing `-Zsanitizer=safestack`. [SafeStack]: https://clang.llvm.org/docs/SafeStack.html
2023-02-25record llvm cgu instruction statscsmoe-0/+1
2023-02-07llvm-16: Use Triple.h from new header location.Matthew Maurer-1/+6
LLVM 16 has moved Triple.h from ADT and into TargetParser
2022-11-04LLVM 16: Switch to using MemoryEffectsTim Neumann-1/+0
2022-07-30Also gate AllocatedPointer and AllocAlign definitions by LLVM_VERSION_GEest31-0/+2
Fixes a warning: warning: llvm-wrapper/RustWrapper.cpp:159:11: warning: enumeration values 'AllocatedPointer' and 'AllocAlign' not handled in switch [-Wswitch] warning: switch (Kind) { warning: ^ Which was fall out from 130a1df71ea73ab9d66d3cb8fc9cdb43155d514b.
2022-07-26codegen: use new {re,de,}allocator annotations in llvmAugie Fackler-0/+3
This obviates the patch that teaches LLVM internals about _rust_{re,de}alloc functions by putting annotations directly in the IR for the optimizer. The sole test change is required to anchor FileCheck to the body of the `box_uninitialized` method, so it doesn't see the `allocalign` on `__rust_alloc` and get mad about the string `alloca` showing up. Since I was there anyway, I added some checks on the attributes to prove the right attributes got set. While we're here, we also emit allocator attributes on __rust_alloc_zeroed. This should allow LLVM to perform more optimizations for zeroed blocks, and probably fixes #90032. [This comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157) mentions "weird UB-like behaviour with bitvec iterators in rustc_data_structures" so we may need to back this change out if things go wrong. The new test cases require LLVM 15, so we copy them into LLVM 14-supporting versions, which we can delete when we drop LLVM 14.
2022-07-20Add ShadowCallStack SupportIvan Lozano-0/+1
Adds support for the LLVM ShadowCallStack sanitizer.
2022-07-06Stop emitting CET prologues for naked functionsJubilee Young-0/+1
We can apply nocf_check as a hack for now.
2022-02-16MemTagSanitizer SupportIvan Lozano-0/+1
Adds support for the LLVM MemTagSanitizer.
2022-02-05Apply noundef attribute to &T, &mut T, Box<T>, boolErik Desjardins-0/+1
This doesn't handle `char` because it's a bit awkward to distinguish it from u32 at this point in codegen. Note that for some types (like `&Struct` and `&mut Struct`), we already apply `dereferenceable`, which implies `noundef`, so the IR does not change.
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-0/+3
LLVM has built-in heuristics for adding stack canaries to functions. These heuristics can be selected with LLVM function attributes. This patch adds a rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use of these attributes. This gives rustc the same stack smash protection support as clang offers through options `-fno-stack-protector`, `-fstack-protector`, `-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the current list of rustc exploit mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html), originally discussed in #15179. Stack smash protection adds runtime overhead and is therefore still off by default, but now users have the option to trade performance for security as they see fit. An example use case is adding Rust code in an existing C/C++ code base compiled with stack smash protection. Without the ability to add stack smash protection to the Rust code, the code base artifacts could be exploitable in ways not possible if the code base remained pure C/C++. Stack smash protection support is present in LLVM for almost all the current tier 1/tier 2 targets: see test/assembly/stack-protector/stack-protector-target-support.rs. The one exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a warning message printed if stack smash protection is used with this target (see test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3 targets has not been checked. Since the heuristics are applied at the LLVM level, the heuristics are expected to add stack smash protection to a fraction of functions comparable to C/C++. Some experiments demonstrating how Rust code is affected by the different heuristics can be found in test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is potential for better heuristics using Rust-specific safety information. For example it might be reasonable to skip stack smash protection in functions which transitively only use safe Rust code, or which uses only a subset of functions the user declares safe (such as anything under `std.*`). Such alternative heuristics could be added at a later point. LLVM also offers a "safestack" sanitizer as an alternative way to guard against stack smashing (see #26612). This could possibly also be included as a stack-protection heuristic. An alternative is to add it as a sanitizer (#39699). This is what clang does: safestack is exposed with option `-fsanitize=safe-stack`. The options are only supported by the LLVM backend, but as with other codegen options it is visible in the main codegen option help menu. The heuristic names "basic", "strong", and "all" are hopefully sufficiently generic to be usable in other backends as well. Reviewed-by: Nikita Popov <nikic@php.net> Extra commits during review: - [address-review] make the stack-protector option unstable - [address-review] reduce detail level of stack-protector option help text - [address-review] correct grammar in comment - [address-review] use compiler flag to avoid merging functions in test - [address-review] specify min LLVM version in fortanix stack-protector test Only for Fortanix test, since this target specifically requests the `--x86-experimental-lvi-inline-asm-hardening` flag. - [address-review] specify required LLVM components in stack-protector tests - move stack protector option enum closer to other similar option enums - rustc_interface/tests: sort debug option list in tracking hash test - add an explicit `none` stack-protector option Revert "set LLVM requirements for all stack protector support test revisions" This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.
2021-10-18RustWrapper: adapt for an LLVM API changeKrasimir Georgiev-1/+0
No functional changes intended. The LLVM commit https://github.com/llvm/llvm-project/commit/89b57061f7b769e9ea9bf6ed686e284f3e55affe moved TargetRegistry.(h|cpp) from Support to MC. This adapts RustWrapper accordingly.
2021-03-24LLVMWrapper: attractive nuisance macrosAugie Fackler-7/+0
THis came up in the review of #83425: it's hard to imagine a use of LLVM_VERSION_LE() or LLVM_VERSION_EQ() that's not asking for trouble when a point release gets created, so let's just discard them to prevent the issue.
2021-03-01Mark pure asm as willreturnNikita Popov-0/+1
2021-02-07HWASan supportTri Vo-0/+1
2020-09-09Move `rustllvm` into `rustc_llvm`Vadim Petrochenkov-0/+115