Set NumRegisterParameters LLVM module flag to N when -Zregparm=N is

set

* Enforce the `-Zregparm=N` flag by setting the NumRegisterParameters
LLVM module flag * Add assembly tests verifying that the parameters are
passed in registers for reparm values 1, 2, and 3, for both LLVM
intrinsics and non-builtin functions * Add c_void type to minicore
This commit is contained in:
winstonallo
2025-08-13 08:51:58 +02:00
parent a1531335fe
commit 04ff1444bb
3 changed files with 86 additions and 0 deletions

View File

@@ -372,6 +372,15 @@ pub(crate) unsafe fn create_module<'ll>(
}
}
if let Some(regparm_count) = sess.opts.unstable_opts.regparm {
llvm::add_module_flag_u32(
llmod,
llvm::ModuleFlagMergeBehavior::Error,
"NumRegisterParameters",
regparm_count,
);
}
if let Some(BranchProtection { bti, pac_ret }) = sess.opts.unstable_opts.branch_protection {
if sess.target.arch == "aarch64" {
llvm::add_module_flag_u32(