Commit graph

219 commits

Author SHA1 Message Date
Nikita Popov
5e9d8a7d55 Switch to the LLVMBuildGEPWithNoWrapFlags API
This API allows us to set the nuw flag as well.
2025-02-19 11:32:32 +01:00
Daniel Paoliello
2a6b27444a Remove dead code from rustc_codegen_llvm and the LLVM wrapper 2025-02-06 16:53:52 -08:00
Zalathar
8ddd9c38f6 Use LLVMDIBuilderCreateDebugLocation
The LLVM-C binding takes an explicit context, whereas our binding obtained the
context from the scope argument.
2025-02-01 14:14:40 +11:00
Zalathar
949b4673ce Use LLVMDIBuilderCreateLexicalBlockFile 2025-02-01 14:14:40 +11:00
Zalathar
70d41bc711 Use LLVMDIBuilderCreateLexicalBlock 2025-02-01 14:14:40 +11:00
Zalathar
878ab125a1 Use LLVMDIBuilderCreateNameSpace 2025-02-01 14:14:39 +11:00
Zalathar
cd2af2dd9a Use LLVMDIBuilderFinalize 2025-02-01 13:38:12 +11:00
bors
854f22563c Auto merge of #136350 - matthiaskrgr:rollup-6eqfyvh, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #134531 ([rustdoc] Add `--extract-doctests` command-line flag)
 - #135860 (Compiler: Finalize dyn compatibility renaming)
 - #135992 (Improve documentation when adding a new target)
 - #136194 (Support clobber_abi in BPF inline assembly)
 - #136325 (Delay a bug when indexing unsized slices)
 - #136326 (Replace our `LLVMRustDIBuilderRef` with LLVM-C's `LLVMDIBuilderRef`)
 - #136330 (Remove unnecessary hooks)
 - #136336 (Overhaul `rustc_middle::util`)
 - #136341 (Remove myself from vacation)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-31 20:16:46 +00:00
Matthias Krüger
a5a005febe
Rollup merge of #136326 - Zalathar:llvm-di-builder-ref, r=nikic
Replace our `LLVMRustDIBuilderRef` with LLVM-C's `LLVMDIBuilderRef`

Inspired by trying to split #134009 into smaller steps that are easier to review individually.

This makes it possible to start incrementally replacing our debuginfo bindings with the ones in the LLVM-C API, all of which operate on `LLVMDIBuilderRef`.

There should be no change to compiler behaviour.
2025-01-31 12:28:18 +01:00
bors
7f36543a48 Auto merge of #136332 - jhpratt:rollup-aa69d0e, r=jhpratt
Rollup of 9 pull requests

Successful merges:

 - #132156 (When encountering unexpected closure return type, point at return type/expression)
 - #133429 (Autodiff Upstreaming - rustc_codegen_ssa, rustc_middle)
 - #136281 (`rustc_hir_analysis` cleanups)
 - #136297 (Fix a typo in profile-guided-optimization.md)
 - #136300 (atomic: extend compare_and_swap migration docs)
 - #136310 (normalize `*.long-type.txt` paths for compare-mode tests)
 - #136312 (Disable `overflow_delimited_expr` in edition 2024)
 - #136313 (Filter out RPITITs when suggesting unconstrained assoc type on too many generics)
 - #136323 (Fix a typo in conventions.md)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-01-31 09:42:28 +00:00
Zalathar
bf15d599ff Remove the temporary typedef for LLVMRustDIFlags
If we're already churning all of the debuginfo bindings, we might as well fix
this at the same time.
2025-01-31 13:03:03 +11:00
Zalathar
63a039a7f5 Replace our LLVMRustDIBuilderRef with LLVM-C's LLVMDIBuilderRef
This makes it possible to start incrementally replacing our debuginfo bindings
with the ones in the LLVM-C API, all of which operate on `LLVMDIBuilderRef`.
2025-01-31 13:02:42 +11:00
Hans Wennborg
6e457b88eb use Attribute::getWithCaptureInfo 2025-01-30 12:30:14 +01:00
Hans Wennborg
23fb08bb53 LLVM changed the nocapture attribute to captures(none)
This updates RustWrapper.cpp and tests after
https://github.com/llvm/llvm-project/pull/123181
2025-01-30 11:22:46 +01:00
Manuel Drehwald
1f30517d40 upstream rustc_codegen_ssa/rustc_middle changes for enzyme/autodiff 2025-01-29 21:31:13 -05:00
Zalathar
32f1c1d85e Make our DIFlags match LLVMDIFlags in the LLVM-C API 2025-01-21 14:41:44 +11:00
Zalathar
1b62645418 Use constants for DWARF opcodes, instead of FFI calls 2025-01-05 22:16:25 +11:00
bors
3dc3c524f7 Auto merge of #133990 - Walnut356:static_const, r=workingjubilee
[Debuginfo] Force enum `DISCR_*` to `static const u64` to allow for inspection via LLDB

see [here](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-04 23:56:29 +00:00
Manuel Drehwald
d753cbf779 upstream rustc_codegen_llvm changes for enzyme/autodiff 2025-01-01 21:42:45 +01:00
Walnut
a1191e30b6 force enum DISCR_* to const u64 to allow for inspection via LLDB's SBTypeStaticField::GetConstantValue() 2024-12-30 19:01:48 -06:00
Walnut
bc4266ca96 add LLVMRustDIBuilderCreateQualifiedType to ffi 2024-12-23 19:12:32 -06:00
bjorn3
c02c311d84 Remove some dead code around import library generation
This was missed when replacing the usage of LLVM for generating import
libraries.
2024-12-20 15:20:15 +00:00
beetrees
68227a3777
Pass end position of span through inline ASM cookie 2024-11-26 13:00:08 +00:00
许杰友 Jieyou Xu (Joe)
c6d36256a6
Rollup merge of #127483 - BertalanD:no_sanitize-global-var, r=rcvalle
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-23 20:19:51 +08:00
Kyle Huey
1dc106121b Add discriminators to DILocations when multiple functions are inlined into a 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-09 08:01:31 -08:00
bors
4b198d6871 Auto merge of #132584 - Zalathar:includes, r=cuviper
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-09 09:46:08 +00:00
Zalathar
730626dbd9 Don't use LLVMRustStringWriteImpl outside of RawRustStringOstream 2024-11-08 22:31:32 +11:00
Zalathar
5bfa0b106e Simplify FFI calls for -Ztime-llvm-passes and -Zprint-codegen-stats 2024-11-04 20:31:16 +11:00
Zalathar
920d2774ac Trim and tidy includes in rustc_llvm 2024-11-04 16:35:39 +11:00
Zalathar
44a056a50b Move LLVMRustAttribute[Kind] out of LLVMWrapper.h 2024-11-04 12:27:23 +11:00
Daniel Bertalan
204b2281fa 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.
2024-11-02 22:35:34 +01:00
Zalathar
c3071590ab Clean up FFI calls for operand bundles 2024-10-30 13:26:24 +11:00
Matthias Krüger
2707cd670c
Rollup merge of #132319 - Zalathar:add-module-flag, r=jieyouxu
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-29 18:38:59 +01:00
Zalathar
8d2ed4f0f3 Clean up FFI calls for setting module flags
- 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-29 21:40:34 +11:00
Zalathar
ba81dbf3c6 Don't set unnecessary module flag "LTOPostLink"
This module flag was an internal detail of LLVM's optimization passes, and all
code involving it was removed in LLVM 17.

<200cc952a2>
2024-10-29 21:17:13 +11:00
klensy
2b326e3817 correct LLVMRustDIBuilderCreateOpLLVMFragment return type 2024-10-29 00:47:20 +03:00
Zalathar
d976ca8701 Use LLVM-C APIs for getting/setting visibility 2024-10-27 11:05:33 +11:00
Zalathar
96993a9b5e Use LLVM-C APIs for getting/setting linkage 2024-10-26 20:20:20 +11:00
Zalathar
b3d65852c3 coverage: Emit MC/DC intrinsics using the normal helper method 2024-10-25 14:01:36 +11:00
Zalathar
4923e856be coverage: Emit llvm.instrprof.increment using the normal helper method 2024-10-25 13:55:44 +11:00
Jubilee Young
492760020e llvm: Delete LLVMRustSetComdat 2024-10-19 10:46:10 -07:00
Augie Fackler
19345d5c6e RustWrapper: adapt for rename of Intrinsic::getDeclaration
llvm/llvm-project@fa789dffb1 renamed
getDeclaration to getOrInsertDeclaration.

@rustbot label: +llvm-main
2024-10-11 12:29:49 -04:00
zhuyunxing
911ac56e95 coverage. Disable supporting mcdc on llvm-18 2024-10-08 10:50:18 +08:00
Josh Stone
6fd8a50680 Update the minimum external LLVM to 18 2024-09-18 13:53:31 -07:00
Trevor Gross
9c26ebe32e
Rollup merge of #126985 - Mrmaxmeier:dwarf-embed-source, r=davidtwco
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-27 01:46:49 -05:00
Andreas Jonson
cfadfabfcd Add range attribute to scalar function results and arguments 2024-08-11 19:40:44 +02:00
Krasimir Georgiev
00bfd702dc Disable MC/DC tests on LLVM 19
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-30 10:22:48 +02:00
Mrmaxmeier
0b87af9d4f Add -Z embed-source=yes to embed source code in DWARF debug info 2024-07-29 12:35:36 +02:00
Matthew Maurer
38931cd227 LLVM: LLVM-20.0 removes MMX types
See llvm/llvm-project#98505
2024-07-25 17:58:37 +00:00
Nikita Popov
8dfd3a455d Remove LLVMRustDIBuilderInsertDeclareAtEnd return value
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-07-12 22:15:10 +02:00