From 2f000a78bf615b35c4837f920fb6adcad4848351 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sun, 28 Mar 2021 00:11:24 +0200 Subject: Manually set dso_local when its valid to do so This should have no real effect in most cases, as e.g. `hidden` visibility already implies `dso_local` (or at least LLVM IR does not preserve the `dso_local` setting if the item is already `hidden`), but it should fix `-Crelocation-model=static` and improve codegen in executables. Note that this PR does not exhaustively port the logic in [clang]. Only the obviously correct portion and what is necessary to fix a regression from LLVM 12 that relates to `-Crelocation_model=static`. Fixes #83335 [clang]: https://github.com/llvm/llvm-project/blob/3001d080c813da20b329303bf8f45451480e5905/clang/lib/CodeGen/CodeGenModule.cpp#L945-L1039 --- src/test/codegen/cdylib-external-inline-fns.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/test/codegen/cdylib-external-inline-fns.rs') diff --git a/src/test/codegen/cdylib-external-inline-fns.rs b/src/test/codegen/cdylib-external-inline-fns.rs index 519be6b6a99..9118afd43d8 100644 --- a/src/test/codegen/cdylib-external-inline-fns.rs +++ b/src/test/codegen/cdylib-external-inline-fns.rs @@ -2,42 +2,42 @@ #![crate_type = "cdylib"] -// CHECK: define void @a() +// CHECK: define{{( dso_local)?}} void @a() #[no_mangle] #[inline] pub extern "C" fn a() {} -// CHECK: define void @b() +// CHECK: define{{( dso_local)?}} void @b() #[export_name = "b"] #[inline] pub extern "C" fn b() {} -// CHECK: define void @c() +// CHECK: define{{( dso_local)?}} void @c() #[no_mangle] #[inline] extern "C" fn c() {} -// CHECK: define void @d() +// CHECK: define{{( dso_local)?}} void @d() #[export_name = "d"] #[inline] extern "C" fn d() {} -// CHECK: define void @e() +// CHECK: define{{( dso_local)?}} void @e() #[no_mangle] #[inline(always)] pub extern "C" fn e() {} -// CHECK: define void @f() +// CHECK: define{{( dso_local)?}} void @f() #[export_name = "f"] #[inline(always)] pub extern "C" fn f() {} -// CHECK: define void @g() +// CHECK: define{{( dso_local)?}} void @g() #[no_mangle] #[inline(always)] extern "C" fn g() {} -// CHECK: define void @h() +// CHECK: define{{( dso_local)?}} void @h() #[export_name = "h"] #[inline(always)] extern "C" fn h() {} -- cgit 1.4.1-3-g733a5