summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/llvm
AgeCommit message (Collapse)AuthorLines
2025-01-01upstream rustc_codegen_llvm changes for enzyme/autodiffManuel Drehwald-1/+33
2024-12-30rustc_llvm: expose FloatABIType target machine parameterRalf Jung-2/+11
2024-12-20Remove some dead code around import library generationbjorn3-28/+0
This was missed when replacing the usage of LLVM for generating import libraries.
2024-12-12Fix our `llvm::Bool` typedef to be signed, to match `LLVMBool`Zalathar-1/+3
In the LLVM-C API, boolean values are passed as `typedef int LLVMBool`, but our Rust-side typedef was using `c_uint` instead. Signed and unsigned integers have the same ABI on most platforms, but that isn't universally true, so we should prefer to be consistent with LLVM.
2024-12-12Auto merge of #129181 - beetrees:asm-spans, r=pnkfelix,compiler-errorsbors-2/+2
Pass end position of span through inline ASM cookie Before this PR, only the start position of the span was passed though the inline ASM cookie to diagnostics. LLVM 19 has full support for 64-bit inline ASM cookies; this PR uses that to pass the end position of the span in the upper 32 bits, meaning inline ASM diagnostics now point at the entire line the error occurred on, not just the first character of it.
2024-11-26Respect verify-llvm-ir option in the backendNikita Popov-0/+1
We are currently unconditionally verifying the LLVM IR in the backend (twice), ignoring the value of the verify-llvm-ir option.
2024-11-26Pass end position of span through inline ASM cookiebeetrees-2/+2
2024-11-23Rollup merge of #127483 - BertalanD:no_sanitize-global-var, r=rcvalle许杰友 Jieyou Xu (Joe)-0/+3
Allow disabling ASan instrumentation for globals AddressSanitizer adds instrumentation to global variables unless the [`no_sanitize_address`](https://llvm.org/docs/LangRef.html#global-attributes) attribute is set on them. This commit extends the existing `#[no_sanitize(address)]` attribute to set this; previously it only had the desired effect on functions. (cc https://github.com/rust-lang/rust/issues/39699)
2024-11-12Rollup merge of #132702 - 1c3t3a:issue-132615, r=rcvalleMatthias Krüger-0/+1
CFI: Append debug location to CFI blocks Currently we're not appending debug locations to the inserted CFI blocks. This shows up in #132615 and #100783. This change fixes that by passing down the debug location to the CFI type-test generation and appending it to the blocks. Credits also belong to `@jakos-sec` who worked with me on this.
2024-11-11CFI: Append debug location to CFI blocksBastian Kersting-0/+1
2024-11-09Add discriminators to DILocations when multiple functions are inlined into a ↵Kyle Huey-0/+4
single point. LLVM does not expect to ever see multiple dbg_declares for the same variable at the same location with different values. proc-macros make it possible for arbitrary code, including multiple calls that get inlined, to happen at any given location in the source code. Add discriminators when that happens so these locations are different to LLVM. This may interfere with the AddDiscriminators pass in LLVM, which is added by the unstable flag -Zdebug-info-for-profiling. Fixes #131944
2024-11-09Auto merge of #132584 - Zalathar:includes, r=cuviperbors-1/+1
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-24/+2
2024-11-08Rollup merge of #132590 - Zalathar:z-timings-stats, r=jieyouxuStuart Cook-4/+6
Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats` The existing code for these unstable LLVM-infodump flags was jumping through hoops to pass an allocated C string across the FFI boundary, when it's much simpler to just write to a `&RustString` instead.
2024-11-05coverage: Tidy up coverage-specific FFI functionsZalathar-12/+12
2024-11-04Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats`Zalathar-4/+6
2024-11-04Move `LLVMRustAttribute[Kind]` out of `LLVMWrapper.h`Zalathar-1/+1
2024-11-03compiler: Directly use rustc_abi in codegenJubilee Young-1/+1
2024-11-02Allow disabling ASan instrumentation for globalsDaniel Bertalan-0/+3
AddressSanitizer adds instrumentation to global variables unless the [`no_sanitize_address`](https://llvm.org/docs/LangRef.html#global-attributes) attribute is set on them. This commit extends the existing `#[no_sanitize(address)]` attribute to set this; previously it only had the desired effect on functions.
2024-11-02Port most of `LLVMRustPrintTargetCPUs` to RustZalathar-6/+2
2024-11-02Use a dedicated safe wrapper for `LLVMRustGetHostCPUName`Zalathar-1/+1
2024-10-31Remove support for `-Zprofile` (gcov-style coverage instrumentation)Zalathar-1/+0
2024-10-30Rollup merge of #132342 - Zalathar:operand-bundle, r=workingjubileeMatthias Krüger-55/+74
cg_llvm: Clean up FFI calls for operand bundles All of these FFI functions have equivalents in the stable LLVM-C API, though `LLVMBuildCallBr` requires a temporary polyfill on LLVM 18. This PR also creates a clear split between `OperandBundleOwned` and `OperandBundle`, and updates the internals of the owner to be a little less terrifying.
2024-10-30Clean up FFI calls for operand bundlesZalathar-55/+74
2024-10-30Consistently use safe wrapper function `set_section`Zalathar-0/+1
2024-10-29Rollup merge of #132319 - Zalathar:add-module-flag, r=jieyouxuMatthias Krüger-11/+44
cg_llvm: Clean up FFI calls for setting module flags This is a combination of several inter-related changes to how module flags are set: - Remove some unnecessary code for setting an `"LTOPostLink"` flag, which has been obsolete since LLVM 17. - Define our own enum instead of relying on enum values defined by LLVM's unstable C++ API. - Use safe wrapper functions to set module flags, instead of direct `unsafe` calls. - Consistently pass pointer/length strings instead of C strings. - Remove or shrink some `unsafe` blocks.
2024-10-29Clean up FFI calls for setting module flagsZalathar-9/+44
- Don't rely on enum values defined by LLVM's C++ API - Use safe wrapper functions instead of direct `unsafe` calls - Consistently pass pointer/length strings instead of C strings
2024-10-29Don't set unnecessary module flag "LTOPostLink"Zalathar-2/+0
This module flag was an internal detail of LLVM's optimization passes, and all code involving it was removed in LLVM 17. <https://github.com/llvm/llvm-project/commit/200cc952a28a73687ba24d5334415df6332f2d5b>
2024-10-29Rollup merge of #132216 - klensy:c_uint, r=cuviperJubilee-2/+2
correct LLVMRustCreateThinLTOData arg types `LLVMRustCreateThinLTOData` defined in rust as ```rust pub fn LLVMRustCreateThinLTOData( Modules: *const ThinLTOModule, NumModules: c_uint, PreservedSymbols: *const *const c_char, PreservedSymbolsLen: c_uint, ) -> Option<&'static mut ThinLTOData>; ``` but in cpp as ```cpp extern "C" LLVMRustThinLTOData * LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules, const char **preserved_symbols, int num_symbols) { ``` (note `c_unit` vs `int` types). Let it be actually `size_t`. Also fixes return type of `LLVMRustDIBuilderCreateOpLLVMFragment` to uint64_t as other similar functions around, which should be correct, i assume.
2024-10-29correct LLVMRustCreateThinLTOData arg typesklensy-2/+2
2024-10-28Use a type-safe helper to cast `&str` and `&[u8]` to `*const c_char`Zalathar-6/+6
2024-10-27Use LLVM-C APIs for getting/setting visibilityZalathar-6/+6
2024-10-26Use LLVM-C APIs for getting/setting linkageZalathar-13/+24
2024-10-26Add a wrapper type for raw enum values returned by LLVMZalathar-0/+25
2024-10-26Use safe wrappers `get_visibility` and `set_visibility`Zalathar-0/+4
2024-10-26Use safe wrappers `get_linkage` and `set_linkage`Zalathar-0/+4
2024-10-25coverage: Emit MC/DC intrinsics using the normal helper methodZalathar-3/+0
2024-10-25coverage: Emit `llvm.instrprof.increment` using the normal helper methodZalathar-1/+0
2024-10-24Rollup merge of #131956 - Zalathar:llvm-counters, r=compiler-errors,SwatinemStuart Cook-10/+16
coverage: Pass coverage mappings to LLVM as separate structs Instead of trying to cram *N* different kinds of coverage mapping data into a single list for FFI, pass *N* different lists of simpler structs. This avoids the need to fill unused fields with dummy values, and avoids the need to tag structs with their underlying kind. It also lets us call the dedicated LLVM constructors for each different mapping type, instead of having to go through the complex general-purpose constructor. Even though this adds multiple new structs to the FFI surface area, the resulting C++ code is simpler and shorter. --- I've structured this mostly as a single atomic patch, rather than a series of incremental changes, because that avoids the need to make fiddly fixes to code that is about to be deleted anyway.
2024-10-20Make `llvm::set_section` take a `&CStr`Zalathar-3/+2
2024-10-20Pass coverage mappings to LLVM as separate structsZalathar-2/+8
2024-10-20Reduce visibility of coverage FFI functions/typesZalathar-8/+8
2024-10-19cg_llvm: Reuse LLVM-C Comdat supportJubilee Young-7/+15
Migrate `llvm::set_comdat` and `llvm::SetUniqueComdat` to LLVM-C FFI. Note, now we can call `llvm::set_comdat` only when the target actually supports adding comdat. As this has no convenient LLVM-C API, we implement this as `TargetOptions::supports_comdat`. Co-authored-by: Stuart Cook <Zalathar@users.noreply.github.com>
2024-10-18cg_llvm: Switch `llvm::add_global` to `&CStr`Jubilee Young-2/+1
2024-10-08coverage. Adapt to mcdc mapping formats introduced by llvm 19zhuyunxing-1/+0
2024-10-01Replace -Z default-hidden-visibility with -Z default-visibilityDavid Lattimore-0/+11
MCP: https://github.com/rust-lang/compiler-team/issues/782 Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2024-09-24Auto merge of #130389 - Luv-Ray:LLVMMDNodeInContext2, r=nikicbors-10/+0
llvm: replace some deprecated functions `LLVMMDStringInContext` and `LLVMMDNodeInContext` are deprecated, replace them with `LLVMMDStringInContext2` and `LLVMMDNodeInContext2`. Also replace `Value` with `Metadata` in some function signatures for better consistency.
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-19Reformat some comments.Nicholas Nethercote-1/+2
So they are less than 100 chars.
2024-09-19Merge adjacent `unsafe extern "C"` blocks.Nicholas Nethercote-26/+2