Skip to content

Commit bdad2c5

Browse files
committed
codegen: use "_N" (like for other locals) instead of "argN", for argument names.
1 parent e9214a1 commit bdad2c5

File tree

9 files changed

+56
-55
lines changed

9 files changed

+56
-55
lines changed

src/librustc_codegen_ssa/mir/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -453,10 +453,11 @@ fn arg_local_refs<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
453453
mir.args_iter().enumerate().map(|(arg_index, local)| {
454454
let arg_decl = &mir.local_decls[local];
455455

456+
// FIXME(eddyb) don't allocate a `String` unless it gets used.
456457
let name = if let Some(name) = arg_decl.name {
457458
name.as_str().to_string()
458459
} else {
459-
format!("arg{}", arg_index)
460+
format!("{:?}", local)
460461
};
461462

462463
if Some(local) == mir.spread_arg {

src/test/codegen/adjustments.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![crate_type = "lib"]
44

55
// Hack to get the correct size for the length part in slices
6-
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
6+
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
77
#[no_mangle]
88
pub fn helper(_: usize) {
99
}

src/test/codegen/fastcall-inreg.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -49,27 +49,27 @@
4949
#![crate_type = "lib"]
5050

5151
pub mod tests {
52-
// CHECK: @f1(i32 inreg %arg0, i32 inreg %arg1, i32 %arg2)
52+
// CHECK: @f1(i32 inreg %_1, i32 inreg %_2, i32 %_3)
5353
#[no_mangle]
5454
pub extern "fastcall" fn f1(_: i32, _: i32, _: i32) {}
5555

56-
// CHECK: @f2(i32* inreg %arg0, i32* inreg %arg1, i32* %arg2)
56+
// CHECK: @f2(i32* inreg %_1, i32* inreg %_2, i32* %_3)
5757
#[no_mangle]
5858
pub extern "fastcall" fn f2(_: *const i32, _: *const i32, _: *const i32) {}
5959

60-
// CHECK: @f3(float %arg0, i32 inreg %arg1, i32 inreg %arg2, i32 %arg3)
60+
// CHECK: @f3(float %_1, i32 inreg %_2, i32 inreg %_3, i32 %_4)
6161
#[no_mangle]
6262
pub extern "fastcall" fn f3(_: f32, _: i32, _: i32, _: i32) {}
6363

64-
// CHECK: @f4(i32 inreg %arg0, float %arg1, i32 inreg %arg2, i32 %arg3)
64+
// CHECK: @f4(i32 inreg %_1, float %_2, i32 inreg %_3, i32 %_4)
6565
#[no_mangle]
6666
pub extern "fastcall" fn f4(_: i32, _: f32, _: i32, _: i32) {}
6767

68-
// CHECK: @f5(i64 %arg0, i32 %arg1)
68+
// CHECK: @f5(i64 %_1, i32 %_2)
6969
#[no_mangle]
7070
pub extern "fastcall" fn f5(_: i64, _: i32) {}
7171

72-
// CHECK: @f6(i1 inreg zeroext %arg0, i32 inreg %arg1, i32 %arg2)
72+
// CHECK: @f6(i1 inreg zeroext %_1, i32 inreg %_2, i32 %_3)
7373
#[no_mangle]
7474
pub extern "fastcall" fn f6(_: bool, _: i32, _: i32) {}
7575
}

src/test/codegen/function-arguments.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -18,48 +18,48 @@ pub fn boolean(x: bool) -> bool {
1818
x
1919
}
2020

21-
// CHECK: @readonly_borrow(i32* noalias readonly align 4 dereferenceable(4) %arg0)
21+
// CHECK: @readonly_borrow(i32* noalias readonly align 4 dereferenceable(4) %_1)
2222
// FIXME #25759 This should also have `nocapture`
2323
#[no_mangle]
2424
pub fn readonly_borrow(_: &i32) {
2525
}
2626

27-
// CHECK: @static_borrow(i32* noalias readonly align 4 dereferenceable(4) %arg0)
27+
// CHECK: @static_borrow(i32* noalias readonly align 4 dereferenceable(4) %_1)
2828
// static borrow may be captured
2929
#[no_mangle]
3030
pub fn static_borrow(_: &'static i32) {
3131
}
3232

33-
// CHECK: @named_borrow(i32* noalias readonly align 4 dereferenceable(4) %arg0)
33+
// CHECK: @named_borrow(i32* noalias readonly align 4 dereferenceable(4) %_1)
3434
// borrow with named lifetime may be captured
3535
#[no_mangle]
3636
pub fn named_borrow<'r>(_: &'r i32) {
3737
}
3838

39-
// CHECK: @unsafe_borrow(i16* align 2 dereferenceable(2) %arg0)
39+
// CHECK: @unsafe_borrow(i16* align 2 dereferenceable(2) %_1)
4040
// unsafe interior means this isn't actually readonly and there may be aliases ...
4141
#[no_mangle]
4242
pub fn unsafe_borrow(_: &UnsafeInner) {
4343
}
4444

45-
// CHECK: @mutable_unsafe_borrow(i16* align 2 dereferenceable(2) %arg0)
45+
// CHECK: @mutable_unsafe_borrow(i16* align 2 dereferenceable(2) %_1)
4646
// ... unless this is a mutable borrow, those never alias
4747
#[no_mangle]
4848
pub fn mutable_unsafe_borrow(_: &mut UnsafeInner) {
4949
}
5050

51-
// CHECK: @mutable_borrow(i32* align 4 dereferenceable(4) %arg0)
51+
// CHECK: @mutable_borrow(i32* align 4 dereferenceable(4) %_1)
5252
// FIXME #25759 This should also have `nocapture`
5353
#[no_mangle]
5454
pub fn mutable_borrow(_: &mut i32) {
5555
}
5656

57-
// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32) %arg0)
57+
// CHECK: @indirect_struct(%S* noalias nocapture dereferenceable(32) %_1)
5858
#[no_mangle]
5959
pub fn indirect_struct(_: S) {
6060
}
6161

62-
// CHECK: @borrowed_struct(%S* noalias readonly align 4 dereferenceable(32) %arg0)
62+
// CHECK: @borrowed_struct(%S* noalias readonly align 4 dereferenceable(32) %_1)
6363
// FIXME #25759 This should also have `nocapture`
6464
#[no_mangle]
6565
pub fn borrowed_struct(_: &S) {
@@ -80,36 +80,36 @@ pub fn struct_return() -> S {
8080
}
8181

8282
// Hack to get the correct size for the length part in slices
83-
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
83+
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
8484
#[no_mangle]
8585
pub fn helper(_: usize) {
8686
}
8787

88-
// CHECK: @slice([0 x i8]* noalias nonnull readonly align 1 %arg0.0, [[USIZE]] %arg0.1)
88+
// CHECK: @slice([0 x i8]* noalias nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
8989
// FIXME #25759 This should also have `nocapture`
9090
#[no_mangle]
9191
pub fn slice(_: &[u8]) {
9292
}
9393

94-
// CHECK: @mutable_slice([0 x i8]* nonnull align 1 %arg0.0, [[USIZE]] %arg0.1)
94+
// CHECK: @mutable_slice([0 x i8]* nonnull align 1 %_1.0, [[USIZE]] %_1.1)
9595
// FIXME #25759 This should also have `nocapture`
9696
#[no_mangle]
9797
pub fn mutable_slice(_: &mut [u8]) {
9898
}
9999

100-
// CHECK: @unsafe_slice([0 x i16]* nonnull align 2 %arg0.0, [[USIZE]] %arg0.1)
100+
// CHECK: @unsafe_slice([0 x i16]* nonnull align 2 %_1.0, [[USIZE]] %_1.1)
101101
// unsafe interior means this isn't actually readonly and there may be aliases ...
102102
#[no_mangle]
103103
pub fn unsafe_slice(_: &[UnsafeInner]) {
104104
}
105105

106-
// CHECK: @str([0 x i8]* noalias nonnull readonly align 1 %arg0.0, [[USIZE]] %arg0.1)
106+
// CHECK: @str([0 x i8]* noalias nonnull readonly align 1 %_1.0, [[USIZE]] %_1.1)
107107
// FIXME #25759 This should also have `nocapture`
108108
#[no_mangle]
109109
pub fn str(_: &[u8]) {
110110
}
111111

112-
// CHECK: @trait_borrow({}* nonnull align 1 %arg0.0, [3 x [[USIZE]]]* noalias readonly align {{.*}} dereferenceable({{.*}}) %arg0.1)
112+
// CHECK: @trait_borrow({}* nonnull align 1 %_1.0, [3 x [[USIZE]]]* noalias readonly align {{.*}} dereferenceable({{.*}}) %_1.1)
113113
// FIXME #25759 This should also have `nocapture`
114114
#[no_mangle]
115115
pub fn trait_borrow(_: &Drop) {

src/test/codegen/refs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![crate_type = "lib"]
44

55
// Hack to get the correct size for the length part in slices
6-
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
6+
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
77
#[no_mangle]
88
pub fn helper(_: usize) {
99
}

src/test/codegen/repeat-trusted-len.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
use std::iter;
88

9-
// CHECK: @helper([[USIZE:i[0-9]+]] %arg0)
9+
// CHECK: @helper([[USIZE:i[0-9]+]] %_1)
1010
#[no_mangle]
1111
pub fn helper(_: usize) {
1212
}

src/test/codegen/repr-transparent.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@ pub struct Zst2(());
1414
#[repr(transparent)]
1515
pub struct F32(f32);
1616

17-
// CHECK: define float @test_F32(float %arg0)
17+
// CHECK: define float @test_F32(float %_1)
1818
#[no_mangle]
1919
pub extern fn test_F32(_: F32) -> F32 { loop {} }
2020

2121
#[repr(transparent)]
2222
pub struct Ptr(*mut u8);
2323

24-
// CHECK: define i8* @test_Ptr(i8* %arg0)
24+
// CHECK: define i8* @test_Ptr(i8* %_1)
2525
#[no_mangle]
2626
pub extern fn test_Ptr(_: Ptr) -> Ptr { loop {} }
2727

2828
#[repr(transparent)]
2929
pub struct WithZst(u64, Zst1);
3030

31-
// CHECK: define i64 @test_WithZst(i64 %arg0)
31+
// CHECK: define i64 @test_WithZst(i64 %_1)
3232
#[no_mangle]
3333
pub extern fn test_WithZst(_: WithZst) -> WithZst { loop {} }
3434

3535
#[repr(transparent)]
3636
pub struct WithZeroSizedArray(*const f32, [i8; 0]);
3737

3838
// Apparently we use i32* when newtype-unwrapping f32 pointers. Whatever.
39-
// CHECK: define i32* @test_WithZeroSizedArray(i32* %arg0)
39+
// CHECK: define i32* @test_WithZeroSizedArray(i32* %_1)
4040
#[no_mangle]
4141
pub extern fn test_WithZeroSizedArray(_: WithZeroSizedArray) -> WithZeroSizedArray { loop {} }
4242

4343
#[repr(transparent)]
4444
pub struct Generic<T>(T);
4545

46-
// CHECK: define double @test_Generic(double %arg0)
46+
// CHECK: define double @test_Generic(double %_1)
4747
#[no_mangle]
4848
pub extern fn test_Generic(_: Generic<f64>) -> Generic<f64> { loop {} }
4949

@@ -53,14 +53,14 @@ pub struct GenericPlusZst<T>(T, Zst2);
5353
#[repr(u8)]
5454
pub enum Bool { True, False, FileNotFound }
5555

56-
// CHECK: define{{( zeroext)?}} i8 @test_Gpz(i8{{( zeroext)?}} %arg0)
56+
// CHECK: define{{( zeroext)?}} i8 @test_Gpz(i8{{( zeroext)?}} %_1)
5757
#[no_mangle]
5858
pub extern fn test_Gpz(_: GenericPlusZst<Bool>) -> GenericPlusZst<Bool> { loop {} }
5959

6060
#[repr(transparent)]
6161
pub struct LifetimePhantom<'a, T: 'a>(*const T, PhantomData<&'a T>);
6262

63-
// CHECK: define i16* @test_LifetimePhantom(i16* %arg0)
63+
// CHECK: define i16* @test_LifetimePhantom(i16* %_1)
6464
#[no_mangle]
6565
pub extern fn test_LifetimePhantom(_: LifetimePhantom<i16>) -> LifetimePhantom<i16> { loop {} }
6666

@@ -70,28 +70,28 @@ pub struct UnitPhantom<T, U> { val: T, unit: PhantomData<U> }
7070

7171
pub struct Px;
7272

73-
// CHECK: define float @test_UnitPhantom(float %arg0)
73+
// CHECK: define float @test_UnitPhantom(float %_1)
7474
#[no_mangle]
7575
pub extern fn test_UnitPhantom(_: UnitPhantom<f32, Px>) -> UnitPhantom<f32, Px> { loop {} }
7676

7777
#[repr(transparent)]
7878
pub struct TwoZsts(Zst1, i8, Zst2);
7979

80-
// CHECK: define{{( signext)?}} i8 @test_TwoZsts(i8{{( signext)?}} %arg0)
80+
// CHECK: define{{( signext)?}} i8 @test_TwoZsts(i8{{( signext)?}} %_1)
8181
#[no_mangle]
8282
pub extern fn test_TwoZsts(_: TwoZsts) -> TwoZsts { loop {} }
8383

8484
#[repr(transparent)]
8585
pub struct Nested1(Zst2, Generic<f64>);
8686

87-
// CHECK: define double @test_Nested1(double %arg0)
87+
// CHECK: define double @test_Nested1(double %_1)
8888
#[no_mangle]
8989
pub extern fn test_Nested1(_: Nested1) -> Nested1 { loop {} }
9090

9191
#[repr(transparent)]
9292
pub struct Nested2(Nested1, Zst1);
9393

94-
// CHECK: define double @test_Nested2(double %arg0)
94+
// CHECK: define double @test_Nested2(double %_1)
9595
#[no_mangle]
9696
pub extern fn test_Nested2(_: Nested2) -> Nested2 { loop {} }
9797

@@ -101,7 +101,7 @@ struct f32x4(f32, f32, f32, f32);
101101
#[repr(transparent)]
102102
pub struct Vector(f32x4);
103103

104-
// CHECK: define <4 x float> @test_Vector(<4 x float> %arg0)
104+
// CHECK: define <4 x float> @test_Vector(<4 x float> %_1)
105105
#[no_mangle]
106106
pub extern fn test_Vector(_: Vector) -> Vector { loop {} }
107107

@@ -111,7 +111,7 @@ impl<T: ?Sized> Mirror for T { type It = Self; }
111111
#[repr(transparent)]
112112
pub struct StructWithProjection(<f32 as Mirror>::It);
113113

114-
// CHECK: define float @test_Projection(float %arg0)
114+
// CHECK: define float @test_Projection(float %_1)
115115
#[no_mangle]
116116
pub extern fn test_Projection(_: StructWithProjection) -> StructWithProjection { loop {} }
117117

@@ -120,7 +120,7 @@ pub enum EnumF32 {
120120
Variant(F32)
121121
}
122122

123-
// CHECK: define float @test_EnumF32(float %arg0)
123+
// CHECK: define float @test_EnumF32(float %_1)
124124
#[no_mangle]
125125
pub extern fn test_EnumF32(_: EnumF32) -> EnumF32 { loop {} }
126126

@@ -129,7 +129,7 @@ pub enum EnumF32WithZsts {
129129
Variant(Zst1, F32, Zst2)
130130
}
131131

132-
// CHECK: define float @test_EnumF32WithZsts(float %arg0)
132+
// CHECK: define float @test_EnumF32WithZsts(float %_1)
133133
#[no_mangle]
134134
pub extern fn test_EnumF32WithZsts(_: EnumF32WithZsts) -> EnumF32WithZsts { loop {} }
135135

@@ -138,7 +138,7 @@ pub union UnionF32 {
138138
field: F32,
139139
}
140140

141-
// CHECK: define float @test_UnionF32(float %arg0)
141+
// CHECK: define float @test_UnionF32(float %_1)
142142
#[no_mangle]
143143
pub extern fn test_UnionF32(_: UnionF32) -> UnionF32 { loop {} }
144144

@@ -149,7 +149,7 @@ pub union UnionF32WithZsts {
149149
zst2: Zst2,
150150
}
151151

152-
// CHECK: define float @test_UnionF32WithZsts(float %arg0)
152+
// CHECK: define float @test_UnionF32WithZsts(float %_1)
153153
#[no_mangle]
154154
pub extern fn test_UnionF32WithZsts(_: UnionF32WithZsts) -> UnionF32WithZsts { loop {} }
155155

src/test/codegen/scalar-pair-bool.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ pub fn pair_i32_bool(pair: (i32, bool)) -> (i32, bool) {
2020
pair
2121
}
2222

23-
// CHECK: define { i8, i8 } @pair_and_or(i1 zeroext %arg0.0, i1 zeroext %arg0.1)
23+
// CHECK: define { i8, i8 } @pair_and_or(i1 zeroext %_1.0, i1 zeroext %_1.1)
2424
#[no_mangle]
2525
pub fn pair_and_or((a, b): (bool, bool)) -> (bool, bool) {
2626
// Make sure it can operate directly on the unpacked args
27-
// CHECK: and i1 %arg0.0, %arg0.1
28-
// CHECK: or i1 %arg0.0, %arg0.1
27+
// CHECK: and i1 %_1.0, %_1.1
28+
// CHECK: or i1 %_1.0, %_1.1
2929
(a && b, a || b)
3030
}
3131

32-
// CHECK: define void @pair_branches(i1 zeroext %arg0.0, i1 zeroext %arg0.1)
32+
// CHECK: define void @pair_branches(i1 zeroext %_1.0, i1 zeroext %_1.1)
3333
#[no_mangle]
3434
pub fn pair_branches((a, b): (bool, bool)) {
3535
// Make sure it can branch directly on the unpacked bool args
36-
// CHECK: br i1 %arg0.0
36+
// CHECK: br i1 %_1.0
3737
if a {
3838
println!("Hello!");
3939
}
40-
// CHECK: br i1 %arg0.1
40+
// CHECK: br i1 %_1.1
4141
if b {
4242
println!("Goodbye!");
4343
}

0 commit comments

Comments
 (0)