Add missing module flags for function-return=thunk-extern · rust-lang/rust@540e41f (original) (raw)

Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
19 19 use rustc_middle::{bug, span_bug};
20 20 use rustc_session::Session;
21 21 use rustc_session::config::{
22 -BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, PAuthKey, PacRet,
22 +BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet,
23 23 };
24 24 use rustc_span::source_map::Spanned;
25 25 use rustc_span::{DUMMY_SP, Span};
@@ -378,6 +378,18 @@ pub(crate) unsafe fn create_module<'ll>(
378 378 }
379 379 }
380 380
381 +match sess.opts.unstable_opts.function_return {
382 +FunctionReturn::Keep => {}
383 +FunctionReturn::ThunkExtern => unsafe {
384 + llvm::LLVMRustAddModuleFlagU32(
385 + llmod,
386 + llvm::LLVMModFlagBehavior::Override,
387 +c"function_return_thunk_extern".as_ptr(),
388 +1,
389 +)
390 +},
391 +}
392 +
381 393 match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support())
382 394 {
383 395 // Set up the small-data optimization limit for architectures that use