about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
AgeCommit message (Collapse)AuthorLines
2025-01-21Make our `DIFlags` match `LLVMDIFlags` in the LLVM-C APIZalathar-114/+68
2025-01-05Use constants for DWARF opcodes, instead of FFI callsZalathar-12/+4
2025-01-04Auto merge of #133990 - Walnut356:static_const, r=workingjubileebors-0/+7
[Debuginfo] Force enum `DISCR_*` to `static const u64` to allow for inspection via LLDB see [here](https://rust-lang.zulipchat.com/#narrow/channel/317568-t-compiler.2Fwg-debugging/topic/Revamping.20Debuginfo/near/486614878) for more info. This change mainly helps `*-msvc` debugged with LLDB. Currently, LLDB cannot inspect `static` struct fields, so the intended visualization for enums is only borderline functional, and niche enums with ranges of discriminant cannot be determined at all . LLDB *can* inspect `static const` values (though for whatever reason, non-enum/non-u64 consts don't work). This change adds the `LLVMRustDIBuilderCreateQualifiedType` to the rust FFI layer to wrap the discr type with a `const` modifier, as well as forcing all generated integer enum `DISCR_*` values to be u64's. Those values will only ever be used by debugger visualizers anyway, so it shouldn't be a huge deal, but I left a fixme comment for it just in case.. The `tag` also still properly reflects the discriminant type, so no information is lost.
2025-01-01upstream rustc_codegen_llvm changes for enzyme/autodiffManuel Drehwald-0/+77
2024-12-30force enum `DISCR_*` to `const u64` to allow for inspection via LLDB's ↵Walnut-3/+3
`SBTypeStaticField::GetConstantValue()`
2024-12-23add LLVMRustDIBuilderCreateQualifiedType to ffiWalnut-0/+7
2024-12-20Remove some dead code around import library generationbjorn3-50/+0
This was missed when replacing the usage of LLVM for generating import libraries.
2024-11-26Pass end position of span through inline ASM cookiebeetrees-1/+1
2024-11-23Rollup merge of #127483 - BertalanD:no_sanitize-global-var, r=rcvalle许杰友 Jieyou Xu (Joe)-0/+19
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-09Add discriminators to DILocations when multiple functions are inlined into a ↵Kyle Huey-0/+8
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-50/+106
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-08Don't use `LLVMRustStringWriteImpl` outside of `RawRustStringOstream`Zalathar-2/+2
2024-11-04Simplify FFI calls for `-Ztime-llvm-passes` and `-Zprint-codegen-stats`Zalathar-20/+8
2024-11-04Trim and tidy includes in `rustc_llvm`Zalathar-5/+15
2024-11-04Move `LLVMRustAttribute[Kind]` out of `LLVMWrapper.h`Zalathar-45/+91
2024-11-02Allow disabling ASan instrumentation for globalsDaniel Bertalan-0/+19
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-10-30Clean up FFI calls for operand bundlesZalathar-64/+14
2024-10-29Rollup merge of #132319 - Zalathar:add-module-flag, r=jieyouxuMatthias Krüger-12/+50
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-7/+50
- 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-5/+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-29correct LLVMRustDIBuilderCreateOpLLVMFragment return typeklensy-1/+1
2024-10-27Use LLVM-C APIs for getting/setting visibilityZalathar-39/+0
2024-10-26Use LLVM-C APIs for getting/setting linkageZalathar-80/+0
2024-10-25coverage: Emit MC/DC intrinsics using the normal helper methodZalathar-28/+0
2024-10-25coverage: Emit `llvm.instrprof.increment` using the normal helper methodZalathar-11/+0
2024-10-19llvm: Delete LLVMRustSetComdatJubilee Young-10/+0
2024-10-11RustWrapper: adapt for rename of Intrinsic::getDeclarationAugie Fackler-6/+19
llvm/llvm-project@fa789dffb1e12c2aece0187aeacc48dfb1768340 renamed getDeclaration to getOrInsertDeclaration. @rustbot label: +llvm-main
2024-10-08coverage. Disable supporting mcdc on llvm-18zhuyunxing-8/+6
2024-09-18Update the minimum external LLVM to 18Josh Stone-24/+3
2024-08-27Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwcoTrevor Gross-2/+7
Implement `-Z embed-source` (DWARFv5 source code embedding extension) Implement https://github.com/rust-lang/compiler-team/issues/764 MCP which adds an unstable flag that exposes LLVM's [DWARFv5 source code embedding](https://dwarfstd.org/issues/180201.1.html) support.
2024-08-11Add range attribute to scalar function results and argumentsAndreas Jonson-0/+12
2024-07-30Disable MC/DC tests on LLVM 19Krasimir Georgiev-1/+1
Disable the tests and generate an error if MC/DC is used on LLVM 19. The support will be ported separately, as it is substantially different on LLVM 19, and there are no plans to support both versions.
2024-07-29Add `-Z embed-source=yes` to embed source code in DWARF debug infoMrmaxmeier-2/+7
2024-07-25LLVM: LLVM-20.0 removes MMX typesMatthew Maurer-2/+0
See llvm/llvm-project#98505
2024-07-12Remove LLVMRustDIBuilderInsertDeclareAtEnd return valueNikita Popov-11/+6
The return value changed from an Instruction to a DbgRecord in LLVM 19. As we don't actually use the result, drop the return value entirely to support both.
2024-06-26Format C++ files in `llvm-wrapper`DianQK-530/+497
2024-04-25Auto merge of #121298 - nikic:writable, r=cuviperbors-0/+10
Set writable and dead_on_unwind attributes for sret arguments Set the `writable` and `dead_on_unwind` attributes for `sret` arguments. This allows call slot optimization to remove more memcpy's. See https://llvm.org/docs/LangRef.html#parameter-attributes for the specification of these attributes. In short, the statement we're making here is that: * The return slot is writable. * The return slot will not be read if the function unwinds. Fixes https://github.com/rust-lang/rust/issues/90595.
2024-04-25Set writable and dead_on_unwind attributes for sret argumentsNikita Popov-0/+10
2024-04-20Rollup merge of #124132 - RalfJung:OpBundlesIndirect, r=Mark-Simulacrum许杰友 Jieyou Xu (Joe)-0/+3
llvm RustWrapper: explain OpBundlesIndirect argument type Follow-up to https://github.com/rust-lang/rust/pull/123941 r? ``@Mark-Simulacrum``
2024-04-20coverage. Lowering MC/DC statements to llvm-irzhuyunxing-0/+27
2024-04-18llvm RustWrapper: explain OpBundlesIndirect argument typeRalf Jung-0/+3
2024-04-14Fix UB in LLVM FFI when passing zero or >1 bundleMark Rousskov-6/+29
Rust passes a *const &OperandBundleDef to these APIs, usually from a Vec<&OperandBundleDef> or so. Previously we were dereferencing that pointer and passing it to the ArrayRef constructor with some length (N). This meant that if the length was 0, we were dereferencing a pointer to nowhere, and if the length was >1 then loading the *second* element somewhere in LLVM would've been reading past the end. Since Rust can't hold OperandBundleDef by-value we're forced to indirect through a vector that copies out the OperandBundleDefs from the by-reference list on the Rust side in order to match the LLVM expected API.
2024-04-10Rollup merge of #123612 - kxxt:riscv-target-abi, r=jieyouxu,nikic,DianQKMatthias Krüger-1/+11
Set target-abi module flag for RISC-V targets Fixes cross-language LTO on RISC-V targets (Fixes #121924)
2024-04-09Pass value and valueLen to create a StringRefLevi Zim-3/+4
Instead of creating a cstring. Co-authored-by: LoveSy <shana@zju.edu.cn>
2024-04-09Set target-abi module flag for RISC-V targetskxxt-1/+10
Fixes cross-language LTO on RISC-V targets (Fixes #121924)
2024-04-07Remove unnecessary cast from `LLVMRustGetInstrProfIncrementIntrinsic`Zalathar-2/+2
This particular cast appears to have been copied over from clang, but there are plenty of other call sites in clang that don't bother with a cast here, and it works fine without one. For context, `llvm::Intrinsic::ID` is a typedef for `unsigned`, and `llvm::Intrinsic::instrprof_increment` is a member of `enum IndependentIntrinsics : unsigned`.
2024-03-26RustWrapper: update call for ↵Augie Fackler-0/+4
llvm/llvm-project@44d037cc258dcf179d2c48c93996bb406ecd0fae Easy change. @rustbot label: +llvm-main
2024-03-17Update the minimum external LLVM to 17Josh Stone-16/+0
2024-03-15Install the bad-alloc handler before fatal errorsJosh Stone-1/+1
The bad-alloc installer was incorrectly asserting that the other handler isn't set yet, instead of checking its own, but we can avoid that by changing the order we install them. Ref: https://github.com/llvm/llvm-project/issues/83040
2024-03-15Aggressively ignore write errors during bad-allocJosh Stone-3/+3