rust/compiler/rustc_codegen_llvm/src
bors 48d8100543 Auto merge of #117930 - thomcc:const_str-unnamed, r=nikic
Ensure strings created with `const_str` get the `unnamed_addr` attribute

This function (`const_str`) is only used when we need to invent a string during codegen -- for example, for a panic message to pass when codegening some of the assert/panic/etc terminators (for stuff like divide by zero).

AFAICT all other consts, such as the user-defined ones from const eval, should already be getting this attribute (things that come from a ConstAllocation do, for example). Which means that the "unnamed" part is even more true than usual here, these aren't strings that even exist as far as the user can tell.

~~Setting this attribute allows LLVM to merge these constants, leading to significant binary size savings (much more than I would expect). On x86_64-unknown-linux-gnu, t takes a build of ripgrep (release without debug info) from 9.7MiB to 6.0MiB (a savings of over 30%!?), and a build of rustc_driver's shared object from 123MiB to 112MiB (less drastic, but still over 10% reduced).~~

~~The effect on ripgrep is substantially reduced on macOS for reasons beyond me (I may have fucked up the test), only saving around 0.2MiB, although rustc_driver is still around 10MB or smaller than it had been previously.~~

~~This raises some questions, such as "does that mean 1/3 of ripgrep was made of division by zero complaints?" I'm not sure, that may be the case. The output of `strings path/to/rg` is \~2MB smaller, so it seems like a lot of it was. Allowing these to be merged presumably also allow functions that contain them to be merged (if the addresses had semantic meaning, then it stands).~~

~~I intend to do some more analysis here, but I got this up as soon as I realized that this attribute was only missing for internal const strings, and all other ones already get it.~~

Edit: The wins are much more marginal, but there's some argument to do this for the sake of consistency.
2023-11-16 08:43:05 +00:00
..
back [RFC 3127 - Trim Paths]: Condition remapped filepath on remap scopes 2023-10-17 10:11:30 +02:00
coverageinfo coverage: Consistently remove unused counter IDs from expressions/mappings 2023-10-28 09:33:48 +11:00
debuginfo use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
llvm consts: remove dead code around i1 constant values 2023-11-03 15:40:17 -04:00
abi.rs Link to correct issue in PassMode::Direct ptx-kernel exception 2023-10-27 11:39:20 +02:00
allocator.rs Auto merge of #113722 - bjorn3:allocator_shim_refactor, r=jackh726 2023-08-13 16:49:49 +00:00
asm.rs Auto merge of #114467 - Amanieu:asm-unstable-features, r=davidtwco 2023-08-15 11:59:02 +00:00
attributes.rs Auto merge of #113814 - ChoKyuWon:master, r=davidtwco 2023-08-18 13:20:37 +00:00
base.rs cg_llvm: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:17 -04:00
builder.rs Format all the let chains in compiler 2023-10-13 08:59:36 +00:00
callee.rs Fix some typos 2023-11-14 23:06:50 +08:00
common.rs Ensure strings created with const_str get the unnamed_addr attribute 2023-11-15 07:56:40 +00:00
consts.rs consts: remove dead code around i1 constant values 2023-11-03 15:40:17 -04:00
context.rs Add -Z llvm_module_flag 2023-11-11 19:48:47 -08:00
declare.rs CFI: Fix SIGILL reached via trait objects 2023-05-09 20:04:19 +00:00
errors.rs warn when using an unstable feature with -Ctarget-feature 2023-11-06 09:44:00 +01:00
intrinsic.rs Merge simd size and type extraction into checking whether a type is simd, as these always go together. 2023-10-31 11:23:39 +00:00
lib.rs coverage: Encode function mappings without re-sorting them 2023-10-22 20:37:39 +11:00
llvm_util.rs target_feature: make it more clear what that 'Option' means 2023-11-12 12:46:05 +01:00
mono_item.rs use visibility to check unused imports and delete some stmts 2023-10-22 21:27:46 +08:00
type_.rs Fix misuses of a vs an 2023-10-04 08:01:11 +08:00
type_of.rs s/Generator/Coroutine/ 2023-10-20 21:10:38 +00:00
va_arg.rs cg_llvm: remove pointee types and pointercast/bitcast-of-ptr 2023-07-29 13:18:17 -04:00
value.rs mv compiler to compiler/ 2020-08-30 18:45:07 +03:00