about summary refs log tree commit diff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
AgeCommit message (Collapse)AuthorLines
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.
2023-11-30Add `-Zfunction-return={keep,thunk-extern}` optionMiguel Ojeda-0/+2
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-21Update the minimum external LLVM to 16.Dario Nieuwenhuis-50/+1
2023-11-16Auto merge of #117948 - aeubanks:dibuilder, r=durin42bors-0/+3
llvm-wrapper: Pass newly added param to DIBuilder::createStaticMemberType() This was added in https://github.com/llvm/llvm-project/pull/72234. DW_TAG_member was the implicit default before. The LLVM change is quite sinister since due to weakly typed ints and default params, this was still successfully compiling against LLVM but was passing the wrong parameters.
2023-11-15llvm-wrapper: Pass newly added param to DIBuilder::createEnumerationType()Arthur Eubanks-1/+5
Added in LLVM in https://github.com/llvm/llvm-project/pull/72011.
2023-11-1517 -> 18Arthur Eubanks-1/+1
2023-11-15[llvm-wrapper] Pass newly added param to DIBuilder::createStaticMemberType()Arthur Eubanks-0/+3
This was added in https://github.com/llvm/llvm-project/pull/72234. DW_TAG_member was the implicit default before.
2023-09-08debuginfo: add compiler option to allow compressed debuginfo sectionsAugie Fackler-0/+16
LLVM already supports emitting compressed debuginfo. In debuginfo=full builds, the debug section is often a large amount of data, and it typically compresses very well (3x is not unreasonable.) We add a new knob to allow debuginfo to be compressed when the matching LLVM functionality is present. Like clang, if a known-but-disabled compression mechanism is requested, we disable compression and emit uncompressed debuginfo sections. The API is different enough on older LLVMs we just pretend the support is missing on LLVM older than 16.
2023-08-08Rollup merge of #113593 - rcvalle:rust-cfi-fix-90546, r=wesleywiserMatthias Krüger-0/+11
CFI: Fix error compiling core with LLVM CFI enabled Fix #90546 by filtering out global value function pointer types from the type tests, and adding the LowerTypeTests pass to the rustc LTO optimization pipelines.
2023-08-08Only enable hotness information when PGO is availableJakub Beránek-3/+6
2023-08-07CFI: Fix error compiling core with LLVM CFI enabledRamon de C Valle-0/+11
Fix #90546 by filtering out global value function pointer types from the type tests, and adding the LowerTypeTests pass to the rustc LTO optimization pipelines.
2023-08-04Add hotness data to LLVM remarksJakub Beránek-0/+3
This makes sure that if PGO is used, remarks generated using `-Zremark-dir` will include the `Hotness` attribute.
2023-08-01Auto merge of #113339 - lqd:respect-filters, r=tmiaskobors-3/+10
Filter out short-lived LLVM diagnostics before they reach the rustc handler During profiling I saw remark passes being unconditionally enabled: for example `Machine Optimization Remark Emitter`. The diagnostic remarks enabled by default are [from missed optimizations and opt analyses](https://github.com/rust-lang/rust/pull/113339#discussion_r1259480303). They are created by LLVM, passed to the diagnostic handler on the C++ side, emitted to rust, where they are unpacked, C++ strings are converted to rust, etc. Then they are discarded in the vast majority of the time (i.e. unless some kind of `-Cremark` has enabled some of these passes' output to be printed). These unneeded allocations are very short-lived, basically only lasting between the LLVM pass emitting them and the rust handler where they are discarded. So it doesn't hugely impact max-rss, and is only a slight reduction in instruction count (cachegrind reports a reduction between 0.3% and 0.5%) _on linux_. It's possible that targets without `jemalloc` or with a worse allocator, may optimize these less. It is however significant in the aggregate, looking at the total number of allocated bytes: - it's the biggest source of allocations according to dhat, on the benchmarks I've tried e.g. `syn` or `cargo` - allocations on `syn` are reduced by 440MB, 17% (from 2440722647 bytes total, to 2030461328 bytes) - allocations on `cargo` are reduced by 6.6GB, 19% (from 35371886402 bytes total, to 28723987743 bytes) Some of these diagnostics objects [are allocated in LLVM](https://github.com/rust-lang/rust/pull/113339#discussion_r1252387484) *before* they're emitted to our diagnostic handler, where they'll be filtered out. So we could remove those in the future, but that will require changing a few LLVM call-sites upstream, so I left a FIXME.
2023-08-01filter LLVM diagnostics before crossing the rust bridgeRémy Rakic-3/+10
this will eliminate many short-lived allocations (e.g. 20% of the memory used building cargo) when unpacking the diagnostic and converting its various C++ strings into rust strings, just to be filtered out most of the time.
2023-07-27Update the minimum external LLVM to 15Josh Stone-41/+0
2023-07-20address feedback from nikic and oli-obk ↵khei4-6/+8
https://github.com/rust-lang/rust/pull/113723/files use slice memcpy rather than strcpy and write it on stdout use println on failure Co-authored-by: Oli Scherer <github35764891676564198441@oli-obk.de>
2023-07-17print on rustc_codegen_llvm and rename malloc and cpy c_charkhei4-8/+18
2023-07-16rustc_llvm: Add a `-Z print-llvm-stats` option to expose LLVM statistics.Patrick Walton-0/+6
LLVM has a neat [statistics] feature that tracks how often optimizations kick in. It's very handy for optimization work. Since we expose the LLVM pass timings, I thought it made sense to expose the LLVM statistics too. [statistics]: https://llvm.org/docs/ProgrammersManual.html#the-statistic-class-stats-option
2023-07-10Reuse LLVMConstInBoundsGEP2Jubilee Young-11/+0
We have had LLVM 14 as our minimum for a bit now.
2023-07-06Rollup merge of #112791 - WaffleLapkin:wag_the_llvm, r=cuviperfee1-dead-0/+26
llvm ffi: Expose `CallInst->setTailCallKind` This is needed for the explicit tail calls experiment.
2023-07-02Add `rustc` option to output LLVM optimization remarks to YAML filesJakub Beránek-7/+83
2023-06-30llvm ffi: Expose `CallInst->setTailCallKind`Maybe Waffle-0/+26
2023-05-26Add SafeStack support to rustcWesley Wiser-0/+2
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-05-03debuginfo: split method declaration and definitionJosh Stone-0/+22
When we're adding a method to a type DIE, we only want a DW_AT_declaration there, because LLVM LTO can't unify type definitions when a child DIE is a full subprogram definition. Now the subprogram definition gets added at the CU level with a specification link back to the abstract declaration.
2023-04-08Auto merge of #109862 - klensy:llvm-dd, r=nikicbors-74/+3
llvm: replace some deprecated functions, add fixmes Replace some deprecated llvm functions, add FIXME's (for simpler future work), replace some rust custom functions with llvm ones.
2023-04-05reviewklensy-1/+1
2023-04-04replaceklensy-12/+1
LLVMRustBuildIntCast -> LLVMBuildIntCast2 LLVMRustAddHandler -> LLVMAddHandler
2023-04-04Use existing llvm methods, instead of rust wrappers for:klensy-49/+0
LLVMRustBuildCleanupPad -> LLVMBuildCleanupPad LLVMRustBuildCleanupRet -> LLVMBuildCleanupRet LLVMRustBuildCatchPad -> LLVMBuildCatchPad LLVMRustBuildCatchRet -> LLVMBuildCatchRet LLVMRustBuildCatchSwitch -> LLVMBuildCatchSwitch
2023-04-04replace LLVMRustAppendModuleInlineAsm with LLVMAppendModuleInlineAsm, ↵klensy-9/+0
LLVMRustMetadataTypeInContext with LLVMMetadataTypeInContext
2023-04-04replace LLVMRustMetadataAsValue with LLVMMetadataAsValueklensy-4/+0
2023-04-04add bunch of fixmes: currently there exist some functions that accept ↵klensy-0/+2
LLVMValueRef, some that accept LLVMMetadataRef, and replacing one with another not always possible without explicit convertion
2023-03-31Preserve, clarify, and extend debug informationJulia Tatz-0/+3
`-Cdebuginfo=1` was never line tables only and can't be due to backwards compatibility issues. This was clarified and an option for line tables only was added. Additionally an option for line info directives only was added, which is well needed for some targets. The debug info options should now behave the same as clang's debug info options.
2023-02-25record llvm cgu instruction statscsmoe-0/+13
2023-02-10Update the minimum external LLVM to 14Josh Stone-13/+1
2023-01-21Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikicMichael Goulet-11/+9
llvm-wrapper: adapt for LLVM API change No functional changes intended. The LLVM commit https://github.com/llvm/llvm-project/commit/e6b02214c68df2c9f826e02310c9352ac652e456 added `TargetExtTyID` to the `TypeID` enum. This adapts `RustWrapper` accordingly.
2023-01-11rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.Dmitri Gribenko-7/+7
LLVM upstream has deprecated llvm::makeArrayRef and will remove it.
2023-01-02llvm-wrapper: adapt for LLVM API changeKrasimir Georgiev-11/+9
No functional changes intended. The LLVM commit https://github.com/llvm/llvm-project/commit/e6b02214c68df2c9f826e02310c9352ac652e456 added `TargetExtTyID` to the `TypeID` enum. This adapts `RustWrapper` accordingly.
2022-12-11llvm-wrapper: adapt for LLVM API changesKrasimir Georgiev-1/+11
This is a follow-up of https://github.com/rust-lang/rust/commit/75aec4703dea7ef8e13924ccfa3a3d2e8c5c7cff. There, I updated the wrapper to only include llvm/ADT/Optional.h for LLVM version below 16. But I missed updating some of the None references. Found by our experimental rust + llvm at HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15587#0185006b-e0af-49e5-8b06-280ed125ff0d/200-539
2022-12-10Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3Matthias Krüger-8/+8
Add LLVM KCFI support to the Rust compiler This PR adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.) Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM KCFI can be enabled with -Zsanitizer=kcfi. Thank you again, `@bjorn3,` `@eddyb,` `@nagisa,` and `@ojeda,` for all the help!
2022-12-08Add LLVM KCFI support to the Rust compilerRamon de C Valle-8/+8
This commit adds LLVM Kernel Control Flow Integrity (KCFI) support to the Rust compiler. It initially provides forward-edge control flow protection for operating systems kernels for Rust-compiled code only by aggregating function pointers in groups identified by their return and parameter types. (See llvm/llvm-project@cff5bef.) Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by identifying C char and integer type uses at the time types are encoded (see Type metadata in the design document in the tracking issue #89653). LLVM KCFI can be enabled with -Zsanitizer=kcfi. Co-authored-by: bjorn3 <17426603+bjorn3@users.noreply.github.com>
2022-12-06Rollup merge of #105298 - krasimirgg:llvm-16-dec-1, r=cuviperMatthias Krüger-0/+16
llvm-wrapper: adapt for an LLVM API change Adapts llvm-wrapper for https://github.com/llvm/llvm-project/commit/8c7c20f033c7036a8bf231ca6f9e02172cb581f0. No functional changes intended. Found via our experimental rust + llvm @ HEAD bot: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/15404#0184d95d-5a68-4db6-ad32-51ddbc3ab543/202-571
2022-12-06llvm-wrapper: adapt for and LLVM API changeKrasimir Georgiev-0/+16
2022-11-26Rewrite LLVM's archive writer in Rustbjorn3-0/+4
This allows it to be used by other codegen backends
2022-11-21Auto merge of #102717 - beetrees:repr128-c-style-debuginfo, r=nagisabors-2/+3
Pass 128-bit C-style enum enumerator values to LLVM Pass the full 128 bits of C-style enum enumerators through to LLVM. This means that debuginfo for C-style repr128 enums is now emitted correctly for DWARF platforms (as compared to not being correctly emitted on any platform). Tracking issue: #56071
2022-11-15Introduce composite debuginfo.Camille GILLOT-0/+4
2022-11-14[llvm-wrapper] adapt for LLVM API changeKrasimir Georgiev-1/+1
2022-11-04LLVM 16: Switch to using MemoryEffectsTim Neumann-2/+40
2022-10-09Pass 128-bit C-style enum enumerator values to LLVMbeetrees-2/+3
2022-09-25Rollup merge of #101997 - cuviper:drop-legacy-pm, r=nikicfee1-dead-6/+2
Remove support for legacy PM This removes support for optimizing with LLVM's legacy pass manager, as well as the unstable `-Znew-llvm-pass-manager` option. We have been defaulting to the new PM since LLVM 13 (except for s390x that waited for 14), and LLVM 15 removed support altogether. The only place we still use the legacy PM is for writing the output file, just like `llc` does. cc #74705 r? ``@nikic``