about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
AgeCommit message (Collapse)AuthorLines
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
2024-03-15Register LLVM handlers for bad-alloc / OOMJosh Stone-1/+24
LLVM's default bad-alloc handler may throw if exceptions are enabled, and `operator new` isn't hooked at all by default. Now we register our own handler that prints a message similar to fatal errors, then aborts. We also call the function that registers the C++ `std::new_handler`.
2024-03-12llvm-wrapper: adapt for LLVM API changesKrasimir Georgiev-2/+7
Adapts rust for https://github.com/llvm/llvm-project/commit/9997e0397156ff7e01aecbd17bdeb7bfe5fb15b0.
2024-03-10Fix 32-bit overflows in LLVM composite constantserer1243-8/+34
2024-03-08Rollup merge of #119365 - nbdd0121:asm-goto, r=AmanieuMatthias Krüger-0/+25
Add asm goto support to `asm!` Tracking issue: #119364 This PR implements asm-goto support, using the syntax described in "future possibilities" section of [RFC2873](https://rust-lang.github.io/rfcs/2873-inline-asm.html#asm-goto). Currently I have only implemented the `label` part, not the `fallthrough` part (i.e. fallthrough is implicit). This doesn't reduce the expressive though, since you can use label-break to get arbitrary control flow or simply set a value and rely on jump threading optimisation to get the desired control flow. I can add that later if deemed necessary. r? ``@Amanieu`` cc ``@ojeda``
2024-03-07Rollup merge of #122062 - workingjubilee:initialize-my-fist, r=cuviperMatthias Krüger-20/+20
Explicitly assign constructed C++ classes C++ style guides I am aware of recommend specifically preferring = syntax for any classes with fairly obvious constructors[^0] that do not perform any complicated logic in their constructor. I contend that all constructors that the `rustc_llvm` code uses qualify. This has only become more common since C++ 17 guaranteed many cases of copy initialization elision. The other detail is that I tried to ask another contributor with infinitely more C++ experience than me (i.e. any) what this constructor syntax was, and they thought it was a macro. I know of no other language that has adopted this same syntax. As the rustc codebase features many contributors experienced in many other languages, using a less... unique... style has many other benefits in making this code more lucid and maintainable, which is something it direly needs. [^0]: e.g. https://abseil.io/tips/88
2024-03-05Explicitly assign constructed C++ classesJubilee Young-20/+20
C++ style guides I am aware of recommend specifically preferring = syntax for any classes with fairly obvious constructors[^0] that do not perform any complicated logic in their constructor. I contend that all constructors that the `rustc_llvm` code uses qualify. This has only become more common since C++ 17 guaranteed many cases of copy initialization elision. The other detail is that I tried to ask another contributor with infinitely more C++ experience than me (i.e. any) what this constructor syntax was, and they thought it was a macro. I know of no other language that has adopted this same syntax. As the rustc codebase features many contributors experienced in many other languages, using a less... unique... style has many other benefits in making this code more lucid and maintainable, which is something it direly needs. [^0]: e.g. https://abseil.io/tips/88
2024-03-05Clarify FatalErrorHandlerJubilee Young-2/+12
Clarify the FatalErrorHandler API that we use: - Identify rustc's LLVM ERRORs by prefixing them - Comment heavily on its interior, while we are here
2024-02-26Rollup merge of #121389 - klensy:llvm-warn-fix, r=nikicMatthias Krüger-1/+1
llvm-wrapper: fix few warnings Two fixes: first one is simple unsigned -> uint64_t, but how second one is more subtile, see commit description.
2024-02-24Add callbr support to LLVM wrapperGary Guo-0/+25
2024-02-21remove simd_reduce_{min,max}_nanlessRalf Jung-7/+6
2024-02-21make simd_reduce_{mul,add}_unordered use only the 'reassoc' flag, not all ↵Ralf Jung-0/+15
fast-math flags
2024-02-21llvm-wrapper: fix warning C4244klensy-1/+1
llvm-wrapper/RustWrapper.cpp(1234): warning C4244: '=': conversion from 'uint64_t' to 'unsigned int', possible loss of data nice consistency: uint64_t https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/include/llvm/IR/DiagnosticInfo.h#L172 but unsigned https://github.com/llvm/llvm-project/blob/6009708b4367171ccdbf4b5905cb6a803753fe18/llvm/include/llvm/IR/DiagnosticInfo.h#L1091
2024-02-20Add "algebraic" versions of the fast-math intrinsicsBen Kimock-1/+24
2024-02-12llvm-wrapper: adapt for LLVM API change: Add support for EXPORTAS name typesHans Wennborg-0/+3
Adapt for llvm/llvm-project@8f23464.
2024-01-30Remove `ffi_returns_twice` featureclubby789-2/+0
2023-12-11fix: stop emitting `.debug_pubnames` and `.debug_pubtypes`Weihang Lo-2/+23
`.debug_pubnames` and `.debug_pubtypes` are poorly designed and people seldom use them. However, they take a considerable portion of size in the final binary. This tells LLVM stop emitting those sections on DWARFv4 or lower. DWARFv5 use `.debug_names` which is more concise in size and performant for name lookup.