rust/compiler/rustc_codegen_llvm/src
bors 3b022d8cee Auto merge of #133852 - x17jiri:cold_path, r=saethlin
improve cold_path()

#120370 added a new instrinsic `cold_path()` and used it to fix `likely` and `unlikely`

However, in order to limit scope, the information about cold code paths is only used in 2-target switch instructions. This is sufficient for `likely` and `unlikely`, but limits usefulness of `cold_path` for idiomatic rust. For example, code like this:

```
if let Some(x) = y { ... }
```

may generate 3-target switch:

```
switch y.discriminator:
0 => true branch
1 = > false branch
_ => unreachable
```

and therefore marking a branch as cold will have no effect.

This PR improves `cold_path()` to work with arbitrary switch instructions.

Note that for 2-target switches, we can use `llvm.expect`, but for multiple targets we need to manually emit branch weights. I checked Clang and it also emits weights in this situation. The Clang's weight calculation is more complex that this PR, which I believe is mainly because `switch` in `C/C++` can have multiple cases going to the same target.
2025-02-18 07:49:09 +00:00
..
back Make -O mean -C opt-level=3 2025-02-13 19:47:55 +00:00
builder Rollup merge of #136419 - EnzymeAD:autodiff-tests, r=onur-ozkan,jieyouxu 2025-02-10 16:38:23 +01:00
coverageinfo coverage: Remove the old code for simplifying counters after MIR opts 2025-02-06 21:44:31 +11:00
debuginfo Move methods from Map to TyCtxt, part 2. 2025-02-18 10:17:44 +11:00
llvm Set both nuw and nsw in slice size calculation 2025-02-13 21:26:48 -08:00
abi.rs Rollup merge of #136807 - workingjubilee:merge-gpus-to-get-the-arcradeongeforce, r=bjorn3 2025-02-12 20:10:00 -05:00
allocator.rs Document some safety constraints and use more safe wrappers 2025-02-11 09:47:13 +00:00
asm.rs Mark condition/carry bit as clobbered in C-SKY inline assembly 2025-01-29 06:46:05 +09:00
attributes.rs Rename OptimizeAttr::None to Default 2025-01-24 19:34:01 +00:00
base.rs Remove Linkage::Appending 2025-02-07 16:02:19 +00:00
builder.rs Auto merge of #133852 - x17jiri:cold_path, r=saethlin 2025-02-18 07:49:09 +00:00
callee.rs rename rustc_attr to rustc_attr_parsing and create rustc_attr_data_structures 2024-12-16 19:08:19 +01:00
common.rs Move hashes from rustc_data_structure to rustc_hashes so they can be shared with rust-analyzer 2025-02-16 16:18:30 -05:00
consts.rs Document some safety constraints and use more safe wrappers 2025-02-11 09:47:13 +00:00
context.rs Rollup merge of #136545 - durin42:nvptx64-align, r=nikic 2025-02-16 00:51:24 -05:00
declare.rs Document some safety constraints and use more safe wrappers 2025-02-11 09:47:13 +00:00
errors.rs [cg_llvm] Remove dead error message 2025-02-13 15:04:39 -08:00
intrinsic.rs Document some safety constraints and use more safe wrappers 2025-02-11 09:47:13 +00:00
lib.rs Rollup merge of #136858 - safinaskar:parallel-cleanup-2025-02-11-07-54, r=SparrowLii 2025-02-13 03:53:31 -05:00
llvm_util.rs Rollup merge of #136813 - mrkajetanp:aarch32-fp16-target-feature, r=davidtwco 2025-02-11 01:02:41 -05:00
mono_item.rs Remove Linkage::Private 2025-02-07 16:02:19 +00:00
type_.rs Rollup merge of #136721 - dpaoliello:cleanllvm2, r=Zalathar 2025-02-11 01:02:40 -05:00
type_of.rs make no-variant types a dedicated Variants variant 2024-12-18 11:01:54 +01:00
va_arg.rs Teach rust core about Xtensa VaListImpl and add a custom lowering of vaarg for xtensa. 2024-12-03 10:54:08 +00:00
value.rs Add warn(unreachable_pub) to rustc_codegen_llvm. 2024-08-16 08:46:57 +10:00