about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/context.rs
diff options
context:
space:
mode:
author许杰友 Jieyou Xu (Joe) <39484203+jieyouxu@users.noreply.github.com>2025-08-19 19:42:01 +0800
committerGitHub <noreply@github.com>2025-08-19 19:42:01 +0800
commitdf01a87de2f9cf936e380a3fca637e552f34a31b (patch)
treedbfe8d87097084d253ad89a4a0042067c842c38a /compiler/rustc_codegen_llvm/src/context.rs
parentc1a1222ece507bbf5e931da35c17457be9c5b81e (diff)
parent1a29d9c23ff8df46197f5ebd3df15fe99904d312 (diff)
downloadrust-df01a87de2f9cf936e380a3fca637e552f34a31b.tar.gz
rust-df01a87de2f9cf936e380a3fca637e552f34a31b.zip
Rollup merge of #140740 - ojeda:indirect-branch-cs-prefix, r=davidtwco
Add `-Zindirect-branch-cs-prefix`

Cc: ``@azhogin`` ``@Darksonn``

This goes on top of https://github.com/rust-lang/rust/pull/135927, i.e. please skip the first commit here. Please feel free to inherit it there.

In fact, I am not sure if there is any use case for the flag without `-Zretpoline*`. GCC and Clang allow it, though.

There is a `FIXME` for two `ignore`s in the test that I took from another test I did in the past -- they may be needed or not here since I didn't run the full CI. Either way, it is not critical.

Tracking issue: https://github.com/rust-lang/rust/issues/116852.
MCP: https://github.com/rust-lang/compiler-team/issues/868.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
-rw-r--r--compiler/rustc_codegen_llvm/src/context.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs
index 2d91ae64e2d..4a7de7d2e69 100644
--- a/compiler/rustc_codegen_llvm/src/context.rs
+++ b/compiler/rustc_codegen_llvm/src/context.rs
@@ -471,6 +471,15 @@ pub(crate) unsafe fn create_module<'ll>(
         }
     }
 
+    if sess.opts.unstable_opts.indirect_branch_cs_prefix {
+        llvm::add_module_flag_u32(
+            llmod,
+            llvm::ModuleFlagMergeBehavior::Override,
+            "indirect_branch_cs_prefix",
+            1,
+        );
+    }
+
     match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support())
     {
         // Set up the small-data optimization limit for architectures that use