Skip to content

Commit 24f42b4

Browse files
committed
modified: compiler/rustc_codegen_llvm/src/attributes.rs modified: compiler/rustc_middle/src/ty/context.rs modified: compiler/rustc_mir_transform/src/lib.rs new file: compiler/rustc_mir_transform/src/stack_protector.rs modified: compiler/rustc_target/src/spec/mod.rs modified: tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs modified: tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect.rs
1 parent c6ea71a commit 24f42b4

File tree

2 files changed

+7
-13
lines changed

2 files changed

+7
-13
lines changed

compiler/rustc_mir_transform/src/stack_protector.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ impl<'tcx> crate::MirPass<'tcx> for StackProtectorFinder {
4141
}
4242

4343
let instance = Instance::mono(tcx, def_id);
44-
let Ok(fn_abi) = tcx.fn_abi_of_instance(ty::TypingEnv::fully_monomorphized().as_query_input((instance, ty::List::empty())),) else { return;};
44+
let Ok(fn_abi) = tcx.fn_abi_of_instance(ty::TypingEnv::fully_monomorphized().as_query_input((instance, ty::List::empty())),)
45+
else {
46+
// FIXME: Finding when an Err() message is returned.
47+
return;
48+
};
4549

4650
// for arg in fn_abi.args.iter() {
4751
// if matches!(&arg.mode, PassMode::Indirect { attrs: _, meta_attrs: _, on_stack: false }) {

tests/assembly-llvm/stack-protector/stack-protector-heuristics-effect-windows-64bit.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,6 @@ pub fn local_large_var_cloned(f: fn(Gigastruct)) {
280280
// ```
281281

282282
// all: __security_check_cookie
283-
284-
// FIXME: How does the rust compiler handle moves of large structures?
285-
// rusty-NOT: __security_check_cookie
286-
287283
// strong: __security_check_cookie
288284
// basic: __security_check_cookie
289285
// none-NOT: __security_check_cookie
@@ -322,14 +318,8 @@ extern "C" {
322318
#[no_mangle]
323319
pub fn alloca_small_compile_time_constant_arg(f: fn(*mut ())) {
324320
f(unsafe { alloca(8) });
325-
326-
// all: __security_check_cookie
327-
328-
// FIXME: Rusty thinks a function that returns a mutable raw pointer may
329-
// be a stack memory allocation function, so it performs stack smash protection.
330-
// Is it possible to optimize the heuristics?
331-
// rusty: __security_check_cookie
332321

322+
// all: __security_check_cookie
333323
// strong-NOT: __security_check_cookie
334324
// basic-NOT: __security_check_cookie
335325
// none-NOT: __security_check_cookie
@@ -386,10 +376,10 @@ pub fn unsized_fn_param(s: [u8], l: bool, f: fn([u8])) {
386376
// LLVM does not support generating stack protectors in functions with funclet
387377
// based EH personalities.
388378
// https://github.com/llvm/llvm-project/blob/37fd3c96b917096d8a550038f6e61cdf0fc4174f/llvm/lib/CodeGen/StackProtector.cpp#L103C1-L109C4
389-
390379
// all-NOT: __security_check_cookie
391380
// rusty-NOT: __security_check_cookie
392381
// strong-NOT: __security_check_cookie
382+
393383
// basic-NOT: __security_check_cookie
394384
// none-NOT: __security_check_cookie
395385
// missing-NOT: __security_check_cookie

0 commit comments

Comments
 (0)