summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper
AgeCommit message (Collapse)AuthorLines
2024-11-14PassWrapper: disable UseOdrIndicator for Asan Win32Jakob Koschel-4/+11
As described here UseOdrIndicator should be disabled on Windows since link.exe does not support duplicate weak definitions (https://reviews.llvm.org/D137227). Co-Authored-By: Bastian Kersting <bkersting@google.com>
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-163/+144
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-08Don't use `LLVMRustStringWriteImpl` outside of `RawRustStringOstream`Zalathar-3/+4
2024-11-08Rollup merge of #132590 - Zalathar:z-timings-stats, r=jieyouxuStuart Cook-20/+8
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-08Rollup merge of #132452 - Zalathar:llvm-cov-wrappers, r=jieyouxuStuart Cook-26/+28
coverage: Extract safe FFI wrapper functions to `llvm_cov` This PR takes all of the inline `unsafe` calls in coverage codegen, and all the safe wrapper functions in `coverageinfo/mod.rs`, and moves them to a new `llvm_cov` submodule that is dedicated to safe FFI wrapper functions. This reduces the mixing of abstraction levels in the rest of coverage codegen. As a follow-up, this PR also tidies up the names and signatures of several of the coverage FFI functions.
2024-11-05PassWrapper: adapt for new parameter in LLVMAugie Fackler-5/+41
llvm/llvm-project@390300d9f41df6ad71f0f4196ef4885d4bd5dc48 added a new parameter to some callbacks, so we have to handle them. @rustbot label: +llvm-main
2024-11-05coverage: Tidy up coverage-specific FFI functionsZalathar-26/+28
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-73/+53
2024-11-04Move `LLVMRustAttribute[Kind]` out of `LLVMWrapper.h`Zalathar-90/+91
2024-11-03Auto merge of #132555 - matthiaskrgr:rollup-2d79661, r=matthiaskrgrbors-7/+6
Rollup of 15 pull requests Successful merges: - #129329 (Implement `From<&mut {slice}>` for `Box/Rc/Arc<{slice}>`) - #131377 (Add LowerExp and UpperExp implementations to NonZero) - #132393 (Docs: added brief colon explanation) - #132437 (coverage: Regression test for inlining into an uninstrumented crate) - #132499 (unicode_data.rs: show command for generating file) - #132503 (better test for const HashMap; remove const_hash leftovers) - #132511 (stabilize const_arguments_as_str) - #132520 (NFC add known bug nr to test) - #132522 (make codegen help output more consistent) - #132523 (Added regression test for generics index out of bounds) - #132528 (Use `*_opt` typeck results fns to not ICE in fallback suggestion) - #132537 (PassWrapper: adapt for llvm/llvm-project@5445edb5d) - #132540 (Do not format generic consts) - #132543 (add and update some crashtests) - #132550 (compiler: Continue introducing rustc_abi to the compiler) r? `@ghost` `@rustbot` modify labels: rollup
2024-11-03Auto merge of #132514 - Zalathar:print-target-cpus, r=jieyouxubors-41/+9
Port most of `--print=target-cpus` to Rust The logic and formatting needed by `--print=target-cpus` has historically been carried out in C++ code. Originally it used `printf` to write directly to the console, but later it switched over to writing to a `std::ostringstream` and then passing its buffer to a callback function pointer. This PR replaces that C++ code with a very simple function that writes a list of CPU names to a `&RustString`, with the rest of the logic and formatting being handled by ordinary safe Rust code.
2024-11-03Rollup merge of #132537 - durin42:llvm-20-prelinklto, r=DianQKMatthias Krüger-7/+6
PassWrapper: adapt for llvm/llvm-project@5445edb5d As with ab5583ed1e75869b765a90386dac9119992f8ed7, we had been explicitly passing defaults whose type have changed. Rather than do an ifdef, we simply rely on the defaults. ````@rustbot```` label: +llvm-main
2024-11-03Auto merge of #132419 - durin42:llvm-20-type-test-thing, r=cuviperbors-3/+3
PassWrapper: adapt for llvm/llvm-project@b01e2a8b5620466c3b A boolean turned into an enum. None matches the old behavior of false, so we pass that. `@rustbot` label: +llvm-main
2024-11-02PassWrapper: adapt for llvm/llvm-project@5445edb5dAugie Fackler-7/+6
As with ab5583ed1e75869b765a90386dac9119992f8ed7, we had been explicitly passing defaults whose type have changed. Rather than do an ifdef, we simply rely on the defaults. @rustbot label: +llvm-main
2024-11-02PassWrapper: adapt for ↵Augie Fackler-3/+3
llvm/llvm-project@b01e2a8b5620466c3b80cc6f049efbc90b9d103a We don't see a reason to explicitly pass the default here, so just use the default instead of explicitly passing it and needing an ifdef. @rustbot label: +llvm-main
2024-11-02Port most of `LLVMRustPrintTargetCPUs` to RustZalathar-39/+7
2024-11-02Use a dedicated safe wrapper for `LLVMRustGetHostCPUName`Zalathar-2/+2
2024-10-31Remove support for `-Zprofile` (gcov-style coverage instrumentation)Zalathar-11/+2
2024-10-30Rollup merge of #132342 - Zalathar:operand-bundle, r=workingjubileeMatthias Krüger-64/+14
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-64/+14
2024-10-30Consistently use safe wrapper function `set_section`Zalathar-2/+4
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-29correct LLVMRustCreateThinLTOData arg typesklensy-4/+4
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-24Rollup merge of #131956 - Zalathar:llvm-counters, r=compiler-errors,SwatinemStuart Cook-91/+91
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-20Rollup merge of #131876 - workingjubilee:llvm-c-c-c-comdat, r=ZalatharStuart Cook-10/+0
compiler: Use LLVM's Comdat support Acting on these long-ago issues: - https://github.com/rust-lang/rust/issues/46437 - https://github.com/rust-lang/rust/issues/68955
2024-10-20Pass coverage mappings to LLVM as separate structsZalathar-91/+91
2024-10-19llvm: Delete LLVMRustSetComdatJubilee Young-10/+0
2024-10-16clang-formatArthur Eubanks-2/+2
2024-10-16rustc_llvm: Fix flattened CLI argsArthur Eubanks-2/+2
Fixes string manipulation errors introduced in #130446.
2024-10-11Rollup merge of #131552 - durin42:llvm-20-getOrInsertDeclaration, r=cuviperTrevor Gross-6/+19
RustWrapper: adapt for rename of Intrinsic::getDeclaration llvm/llvm-project@fa789dffb1e12c2aece0187aeacc48dfb1768340 renamed getDeclaration to getOrInsertDeclaration. `@rustbot` label: +llvm-main
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-11coverage: Remove code related to LLVM 17Zalathar-1/+1
2024-10-08coverage. Disable supporting mcdc on llvm-18zhuyunxing-44/+15
2024-09-25Pass Module Analysis Manager to Standard InstrumentationsAleksei Romanov-5/+6
2024-09-22Auto merge of #130446 - durin42:llvm-20-fix-CommandLineArgs, r=workingjubileebors-1/+19
rustc_llvm: adapt to flattened CLI args in LLVM This changed in llvm/llvm-project@e190d074a0a77c9f8a7d7938a8187a7e2076e290. I decided to stick with more duplication between the ifdef blocks to make the code easier to read for the next two years before we can plausibly drop LLVM 19. `@rustbot` label: +llvm-main try-job: x86_64-msvc
2024-09-18Update the minimum external LLVM to 18Josh Stone-78/+10
2024-09-18llvm-wrapper: adapt for LLVM API changes, second tryKrasimir Georgiev-0/+4
2024-09-17Rollup merge of #130477 - tmandry:revert-llvm-20-lto, r=tmandryMatthias Krüger-7/+3
Revert #129749 to fix segfault in LLVM This reverts commit 8c7a7e346be4cdf13e77ab4acbfb5ade819a4e60, reversing changes made to a00bd75b6c5c96d0a35afa2dc07ce3155112d278. Reported in https://github.com/rust-lang/rust/pull/129749#issuecomment-2354417960. `@nikic's` theory is that the LLVM API changed in a way that makes it impossible to use concurrently from multiple threads (https://github.com/llvm/llvm-project/pull/106427#issuecomment-2354783802). I pinged `@krasimirgg` who was fine with reverting. r? `@rust-lang/wg-llvm`
2024-09-16Revert "Rollup merge of #129749 - krasimirgg:llvm-20-lto, r=nikic"Tyler Mandry-7/+3
This reverts commit 8c7a7e346be4cdf13e77ab4acbfb5ade819a4e60, reversing changes made to a00bd75b6c5c96d0a35afa2dc07ce3155112d278.
2024-09-16PassWrapper: clang-format has spokenAugie Fackler-1/+2