Skip to content

Commit 6f146f5

Browse files
committed
Revert "CFI: Skip non-passed arguments"
This reverts commit f2f0d25.
1 parent 53ed526 commit 6f146f5

5 files changed

+33
-41
lines changed

compiler/rustc_symbol_mangling/src/typeid/typeid_itanium_cxx_abi.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_middle::ty::{
1818
use rustc_middle::ty::{GenericArg, GenericArgKind, GenericArgsRef};
1919
use rustc_span::def_id::DefId;
2020
use rustc_span::sym;
21-
use rustc_target::abi::call::{Conv, FnAbi, PassMode};
21+
use rustc_target::abi::call::{Conv, FnAbi};
2222
use rustc_target::abi::Integer;
2323
use rustc_target::spec::abi::Abi;
2424
use std::fmt::Write as _;
@@ -1537,27 +1537,19 @@ pub fn typeid_for_fnabi<'tcx>(
15371537
typeid.push_str(&encode_ty(tcx, ty, &mut dict, encode_ty_options));
15381538

15391539
// Encode the parameter types
1540-
1541-
// We erase ZSTs as we go if the argument is skipped. This is an implementation detail of how
1542-
// MIR is currently treated by rustc, and subject to change in the future. Specifically, MIR
1543-
// interpretation today will allow skipped arguments to simply not be passed at a call-site.
15441540
if !fn_abi.c_variadic {
1545-
let mut pushed_arg = false;
1546-
for arg in fn_abi.args.iter().filter(|arg| arg.mode != PassMode::Ignore) {
1547-
pushed_arg = true;
1548-
let ty = transform_ty(tcx, arg.layout.ty, transform_ty_options);
1549-
typeid.push_str(&encode_ty(tcx, ty, &mut dict, encode_ty_options));
1550-
}
1551-
if !pushed_arg {
1541+
if !fn_abi.args.is_empty() {
1542+
for arg in fn_abi.args.iter() {
1543+
let ty = transform_ty(tcx, arg.layout.ty, transform_ty_options);
1544+
typeid.push_str(&encode_ty(tcx, ty, &mut dict, encode_ty_options));
1545+
}
1546+
} else {
15521547
// Empty parameter lists, whether declared as () or conventionally as (void), are
15531548
// encoded with a void parameter specifier "v".
15541549
typeid.push('v');
15551550
}
15561551
} else {
15571552
for n in 0..fn_abi.fixed_count as usize {
1558-
if fn_abi.args[n].mode == PassMode::Ignore {
1559-
continue;
1560-
}
15611553
let ty = transform_ty(tcx, fn_abi.args[n].layout.ty, transform_ty_options);
15621554
typeid.push_str(&encode_ty(tcx, ty, &mut dict, encode_ty_options));
15631555
}

tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs

+18-20
Original file line numberDiff line numberDiff line change
@@ -47,42 +47,40 @@ pub fn foo() where
4747
let _: Type4 = <Foo>::bar;
4848
}
4949

50-
// Force arguments to be passed by using a reference. Otherwise, they may end up PassMode::Ignore
51-
52-
pub fn foo1(_: &Type1) { }
50+
pub fn foo1(_: Type1) { }
5351
// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
54-
pub fn foo2(_: &Type1, _: &Type1) { }
52+
pub fn foo2(_: Type1, _: Type1) { }
5553
// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
56-
pub fn foo3(_: &Type1, _: &Type1, _: &Type1) { }
54+
pub fn foo3(_: Type1, _: Type1, _: Type1) { }
5755
// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
58-
pub fn foo4(_: &Type2) { }
56+
pub fn foo4(_: Type2) { }
5957
// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
60-
pub fn foo5(_: &Type2, _: &Type2) { }
58+
pub fn foo5(_: Type2, _: Type2) { }
6159
// CHECK: define{{.*}}4foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
62-
pub fn foo6(_: &Type2, _: &Type2, _: &Type2) { }
60+
pub fn foo6(_: Type2, _: Type2, _: Type2) { }
6361
// CHECK: define{{.*}}4foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
64-
pub fn foo7(_: &Type3) { }
62+
pub fn foo7(_: Type3) { }
6563
// CHECK: define{{.*}}4foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
66-
pub fn foo8(_: &Type3, _: &Type3) { }
64+
pub fn foo8(_: Type3, _: Type3) { }
6765
// CHECK: define{{.*}}4foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
68-
pub fn foo9(_: &Type3, _: &Type3, _: &Type3) { }
66+
pub fn foo9(_: Type3, _: Type3, _: Type3) { }
6967
// CHECK: define{{.*}}4foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
70-
pub fn foo10(_: &Type4) { }
68+
pub fn foo10(_: Type4) { }
7169
// CHECK: define{{.*}}5foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
72-
pub fn foo11(_: &Type4, _: &Type4) { }
70+
pub fn foo11(_: Type4, _: Type4) { }
7371
// CHECK: define{{.*}}5foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
74-
pub fn foo12(_: &Type4, _: &Type4, _: &Type4) { }
72+
pub fn foo12(_: Type4, _: Type4, _: Type4) { }
7573
// CHECK: define{{.*}}5foo12{{.*}}!type ![[TYPE12:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
7674

7775
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPFvvEE"}
7876
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvPFvvES_E"}
7977
// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPFvvES_S_E"}
80-
// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooEE"}
81-
// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooES0_E"}
82-
// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooES0_S0_E"}
83-
// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooEE"}
84-
// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooES0_E"}
85-
// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu3refIu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooES0_S0_E"}
78+
// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooE"}
79+
// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooS_E"}
80+
// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNCNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo11{{[{}][{}]}}closure{{[}][}]}}3FooS_S_E"}
81+
// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooE"}
82+
// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooS_E"}
83+
// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvu{{[0-9]+}}NtNkNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo12{{[{}][{}]}}constant{{[}][}]}}3FooS_S_E"}
8684
// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvPFvu3refIu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooEEE"}
8785
// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvPFvu3refIu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooEES1_E"}
8886
// CHECK: ![[TYPE12]] = !{i64 0, !"_ZTSFvPFvu3refIu{{[0-9]+}}NtNvC{{[[:print:]]+}}_{{[[:print:]]+}}3foo3FooEES1_S1_E"}

tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ use core::ffi::*;
1212
pub fn foo1(_: ()) { }
1313
// CHECK: define{{.*}}4foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
1414
pub fn foo2(_: (), _: c_void) { }
15-
// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
15+
// CHECK: define{{.*}}4foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
1616
pub fn foo3(_: (), _: c_void, _: c_void) { }
17-
// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
17+
// CHECK: define{{.*}}4foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
1818
pub fn foo4(_: *mut ()) { }
1919
// CHECK: define{{.*}}4foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
2020
pub fn foo5(_: *mut (), _: *mut c_void) { }
@@ -131,6 +131,8 @@ pub fn foo60(_: &str, _: &str, _: &str) { }
131131
// CHECK: define{{.*}}5foo60{{.*}}!type ![[TYPE60:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}}
132132

133133
// CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvvE"}
134+
// CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvvvE"}
135+
// CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvvvvE"}
134136
// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvPvE"}
135137
// CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvPvS_E"}
136138
// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPvS_S_E"}

tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub struct Type2<'a> {
2828
member3: &'a Type2<'a>,
2929
}
3030

31-
pub struct Bar(i32);
31+
pub struct Bar;
3232

3333
// repr(transparent) user-defined generic type
3434
#[repr(transparent)]

tests/codegen/sanitizer/cfi/normalize-integers.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,6 @@ pub fn foo11(_: (), _: usize, _: usize, _: usize) { }
4141
// CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64|u4i128}}E.normalized"}
4242
// CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64|u4i128}}S_E.normalized"}
4343
// CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFv{{u3i16|u3i32|u3i64|u4i128}}S_S_E.normalized"}
44-
// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64|u4u128}}E.normalized"}
45-
// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64|u4u128}}S_E.normalized"}
46-
// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFv{{u3u16|u3u32|u3u64|u4u128}}S_S_E.normalized"}
44+
// CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvv{{u3u16|u3u32|u3u64|u4u128}}E.normalized"}
45+
// CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvv{{u3u16|u3u32|u3u64|u4u128}}S_E.normalized"}
46+
// CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvv{{u3u16|u3u32|u3u64|u4u128}}S_S_E.normalized"}

0 commit comments

Comments
 (0)