summaryrefslogtreecommitdiff
path: root/compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Commit message (Collapse)AuthorAgeFilesLines
* debuginfo: split method declaration and definitionJosh Stone2023-05-031-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.
* Auto merge of #109862 - klensy:llvm-dd, r=nikicbors2023-04-081-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.
| * reviewklensy2023-04-051-1/+1
| |
| * replaceklensy2023-04-041-12/+1
| | | | | | | | | | LLVMRustBuildIntCast -> LLVMBuildIntCast2 LLVMRustAddHandler -> LLVMAddHandler
| * Use existing llvm methods, instead of rust wrappers for:klensy2023-04-041-49/+0
| | | | | | | | | | | | | | | | LLVMRustBuildCleanupPad -> LLVMBuildCleanupPad LLVMRustBuildCleanupRet -> LLVMBuildCleanupRet LLVMRustBuildCatchPad -> LLVMBuildCatchPad LLVMRustBuildCatchRet -> LLVMBuildCatchRet LLVMRustBuildCatchSwitch -> LLVMBuildCatchSwitch
| * replace LLVMRustAppendModuleInlineAsm with LLVMAppendModuleInlineAsm, ↵klensy2023-04-041-9/+0
| | | | | | | | LLVMRustMetadataTypeInContext with LLVMMetadataTypeInContext
| * replace LLVMRustMetadataAsValue with LLVMMetadataAsValueklensy2023-04-041-4/+0
| |
| * add bunch of fixmes: currently there exist some functions that accept ↵klensy2023-04-041-0/+2
| | | | | | | | LLVMValueRef, some that accept LLVMMetadataRef, and replacing one with another not always possible without explicit convertion
* | Preserve, clarify, and extend debug informationJulia Tatz2023-03-311-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.
* record llvm cgu instruction statscsmoe2023-02-251-0/+13
|
* Update the minimum external LLVM to 14Josh Stone2023-02-101-13/+1
|
* Rollup merge of #106113 - krasimirgg:llvm-16-ext-tyid, r=nikicMichael Goulet2023-01-211-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.
| * llvm-wrapper: adapt for LLVM API changeKrasimir Georgiev2023-01-021-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.
* | rustc_llvm: replace llvm::makeArrayRef with ArrayRef constructors.Dmitri Gribenko2023-01-111-7/+7
|/ | | | LLVM upstream has deprecated llvm::makeArrayRef and will remove it.
* llvm-wrapper: adapt for LLVM API changesKrasimir Georgiev2022-12-111-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
* Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3Matthias Krüger2022-12-101-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!
| * Add LLVM KCFI support to the Rust compilerRamon de C Valle2022-12-081-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>
* | Rollup merge of #105298 - krasimirgg:llvm-16-dec-1, r=cuviperMatthias Krüger2022-12-061-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
| * | llvm-wrapper: adapt for and LLVM API changeKrasimir Georgiev2022-12-061-0/+16
| |/
* | Rewrite LLVM's archive writer in Rustbjorn32022-11-261-0/+4
|/ | | | This allows it to be used by other codegen backends
* Auto merge of #102717 - beetrees:repr128-c-style-debuginfo, r=nagisabors2022-11-211-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
| * Pass 128-bit C-style enum enumerator values to LLVMbeetrees2022-10-091-2/+3
| |
* | Introduce composite debuginfo.Camille GILLOT2022-11-151-0/+4
| |
* | [llvm-wrapper] adapt for LLVM API changeKrasimir Georgiev2022-11-141-1/+1
| |
* | LLVM 16: Switch to using MemoryEffectsTim Neumann2022-11-041-2/+40
|/
* Rollup merge of #101997 - cuviper:drop-legacy-pm, r=nikicfee1-dead2022-09-251-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``
| * Never use legacy PM for writing bitcodeJosh Stone2022-09-181-6/+2
| |
* | Use LLVM C-API to build atomic cmpxchg and fenceJosh Stone2022-09-181-39/+0
|/
* Introduce a fallible variant of LLVMConstIntGetZExtValueTomasz Miąsko2022-09-091-0/+8
| | | | which verifies that a constant bit width is within 64 bits or fails.
* Rollup merge of #100460 - cuviper:drop-llvm-12, r=nagisaMatthias Krüger2022-08-161-35/+0
|\ | | | | | | | | | | | | | | | | Update the minimum external LLVM to 13 With this change, we'll have stable support for LLVM 13 through 15 (pending release). For reference, the previous increase to LLVM 12 was #90175. r? `@nagisa`
| * Update the minimum external LLVM to 13Josh Stone2022-08-141-35/+0
| |
* | debuginfo: Change C++-like encoding for enums.Michael Woerister2022-08-121-0/+24
|/ | | | | The updated encoding should be able to handle niche layouts where more than one variant has fields.
* RustWrapper: update for TypedPointerType in LLVMAugie Fackler2022-08-041-1/+6
| | | | This is a result of https://reviews.llvm.org/D130592.
* Add elementtype attributes for llvm.arm.ldrex/strex intrinsicsNikita Popov2022-07-271-0/+22
| | | | | These intrinsics (and a few more, but there are the only ones exposed by stdarch) require an elementtype attribute in LLVM 15.
* Rollup merge of #99759 - bjorn3:remove_llvm_dead_code, r=nikicYuki Okushi2022-07-271-9/+0
|\ | | | | | | | | | | Remove dead code from cg_llvm Found while working on https://github.com/rust-lang/rust/pull/97485
| * Remove dead code from cg_llvmbjorn32022-07-261-9/+0
| |
* | codegen: use new {re,de,}allocator annotations in llvmAugie Fackler2022-07-261-0/+69
|/ | | | | | | | | | | | | | | | | | | | | | | This obviates the patch that teaches LLVM internals about _rust_{re,de}alloc functions by putting annotations directly in the IR for the optimizer. The sole test change is required to anchor FileCheck to the body of the `box_uninitialized` method, so it doesn't see the `allocalign` on `__rust_alloc` and get mad about the string `alloca` showing up. Since I was there anyway, I added some checks on the attributes to prove the right attributes got set. While we're here, we also emit allocator attributes on __rust_alloc_zeroed. This should allow LLVM to perform more optimizations for zeroed blocks, and probably fixes #90032. [This comment](https://github.com/rust-lang/rust/issues/24194#issuecomment-308791157) mentions "weird UB-like behaviour with bitvec iterators in rustc_data_structures" so we may need to back this change out if things go wrong. The new test cases require LLVM 15, so we copy them into LLVM 14-supporting versions, which we can delete when we drop LLVM 14.
* Add ShadowCallStack SupportIvan Lozano2022-07-201-0/+2
| | | | Adds support for the LLVM ShadowCallStack sanitizer.
* Rollup merge of #98998 - ↵Dylan DPC2022-07-181-0/+2
|\ | | | | | | | | | | | | | | workingjubilee:naked-means-no-clothes-enforcement-technology, r=Amanieu Remove branch target prologues from `#[naked] fn` This patch hacks around rust-lang/rust#98768 for now via injecting appropriate attributes into the LLVMIR we emit for naked functions. I intend to pursue this upstream so that these attributes can be removed in general, but it's slow going wading through C++ for me.
| * Stop emitting CET prologues for naked functionsJubilee Young2022-07-061-0/+2
| | | | | | | | We can apply nocf_check as a hack for now.
* | llvm-wrapper: adapt for LLVM API changeKrasimir Georgiev2022-07-121-0/+6
|/
* llvm-wrapper: adapt for LLVMConstExtractValue removalKrasimir Georgiev2022-06-301-0/+8
|
* Add metadata generation for vtables when using VFEflip19952022-06-141-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the typeid and `vcall_visibility` metadata to vtables when the -Cvirtual-function-elimination flag is set. The typeid is generated in the same way as for the `llvm.type.checked.load` intrinsic from the trait_ref. The offset that is added to the typeid is always 0. This is because LLVM assumes that vtables are constructed according to the definition in the Itanium ABI. This includes an "address point" of the vtable. In C++ this is the offset in the vtable where information for RTTI is placed. Since there is no RTTI information in Rust's vtables, this "address point" is always 0. This "address point" in combination with the offset passed to the `llvm.type.checked.load` intrinsic determines the final function that should be loaded from the vtable in the `WholeProgramDevirtualization` pass in LLVM. That's why the `llvm.type.checked.load` intrinsics are generated with the typeid of the trait, rather than with that of the function that is called. This matches what `clang` does for C++. The vcall_visibility metadata depends on three factors: 1. LTO level: Currently this is always fat LTO, because LLVM only supports this optimization with fat LTO. 2. Visibility of the trait: If the trait is publicly visible, VFE can only act on its vtables after linking. 3. Number of CGUs: if there is more than one CGU, also vtables with restricted visibility could be seen outside of the CGU, so VFE can only act on them after linking. To reflect this, there are three visibility levels: Public, LinkageUnit, and TranslationUnit.
* Add LLVM module flags required for the VFE optflip19952022-06-141-0/+5
| | | | | | To apply the optimization the `Virtual Function Elim` module flag has to be set. To apply this optimization post-link the `LTOPostLink` module flag has to be set.
* RustWrapper: adapt to APInt API changes in LLVM 15Augie Fackler2022-06-071-0/+8
| | | | | | | | | | | | | In https://reviews.llvm.org/D125556 upstream changed sext() and zext() to allow some no-op cases, which previously required use of the *OrSelf() methods, which I assume is what was going on here. The *OrSelf() methods got removed in https://reviews.llvm.org/D125559 after two weeks of deprecation because they came with some bonus (probably-undesired) behavior. Since the behavior of sext() and zext() changed slightly, I kept the old *OrSelf() calls in LLVM 14 and earlier, and only use the new version in LLVM 15. r? @nikic
* RustWrapper: explicitly don't handle DXILPointerTyIDAugie Fackler2022-04-281-0/+5
| | | | | | | This new enum entry was introduced in https://reviews.llvm.org/D122268, and if I'm reading correctly there's no case where we'd ever encounter it in our uses of LLVM. To preserve the ability to compile this file with -Werror -Wswitch we add an explicit case for this entry.
* Add missing includeNikita Popov2022-04-201-0/+1
|
* Add codegen for global_asm! sym operandsAmanieu d'Antras2022-04-151-0/+6
|
* RustWrapper: add missing includeAugie Fackler2022-03-101-0/+1
| | | | | This is required after LLVM change 3c4410dfcaaf (aka https://reviews.llvm.org/D121168) did some includes cleanup.
* Pass LLVM string attributes as string slicesTomasz Miąsko2022-03-031-6/+0
|