Skip to content

Commit 4adee2b

Browse files
Rollup merge of rust-lang#142285 - workingjubilee:dont-use-bad-assembly, r=nnethercote
tests: Do not run afoul of asm.validity.non-exhaustive in input-stats This addresses one of the three powerpc64-unknown-linux-musl test failures in rust-lang#142280 I was motivated to cover it myself because technically this is also compile-time UB if we compile a program that has `asm!` with x86-64-specific instructions on another platform. That'll only mean something if this is ever switched to build-pass, or if checking emits object code, but conveniently "nop" is valid assembly on all platforms anyone has implemented Rust codegen for. Even the weird ones LLVM doesn't support, like PA-RISC or Common Intermediate Language. ...except GPUs. Not sure about those. r? ````@nnethercote````
2 parents 8adc333 + 2338821 commit 4adee2b

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

tests/ui/stats/input-stats.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//@ check-pass
22
//@ compile-flags: -Zinput-stats
33
//@ only-64bit
4+
//@ needs-asm-support
45
// layout randomization affects the hir stat output
56
//@ needs-deterministic-layouts
67
//
@@ -49,5 +50,7 @@ fn main() {
4950
_ => {}
5051
}
5152

52-
unsafe { asm!("mov rdi, 1"); }
53+
// NOTE(workingjubilee): do GPUs support NOPs? remove this cfg if they do
54+
#[cfg(not(any(target_arch = "nvptx64", target_arch = "amdgpu")))]
55+
unsafe { asm!("nop"); }
5356
}

tests/ui/stats/input-stats.stderr

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ast-stats - Ptr 64 (NN.N%) 1
1515
ast-stats - Ref 64 (NN.N%) 1
1616
ast-stats - ImplicitSelf 128 (NN.N%) 2
1717
ast-stats - Path 640 (NN.N%) 10
18-
ast-stats PathSegment 864 (NN.N%) 36 24
18+
ast-stats PathSegment 888 (NN.N%) 37 24
1919
ast-stats Expr 648 (NN.N%) 9 72
2020
ast-stats - InlineAsm 72 (NN.N%) 1
2121
ast-stats - Match 72 (NN.N%) 1
@@ -41,9 +41,9 @@ ast-stats - Let 32 (NN.N%) 1
4141
ast-stats - Semi 32 (NN.N%) 1
4242
ast-stats - Expr 96 (NN.N%) 3
4343
ast-stats Param 160 (NN.N%) 4 40
44-
ast-stats Attribute 128 (NN.N%) 4 32
44+
ast-stats Attribute 160 (NN.N%) 5 32
4545
ast-stats - DocComment 32 (NN.N%) 1
46-
ast-stats - Normal 96 (NN.N%) 3
46+
ast-stats - Normal 128 (NN.N%) 4
4747
ast-stats InlineAsm 120 (NN.N%) 1 120
4848
ast-stats FnDecl 120 (NN.N%) 5 24
4949
ast-stats Local 96 (NN.N%) 1 96
@@ -57,7 +57,7 @@ ast-stats GenericArgs 40 (NN.N%) 1 40
5757
ast-stats - AngleBracketed 40 (NN.N%) 1
5858
ast-stats Crate 40 (NN.N%) 1 40
5959
ast-stats ----------------------------------------------------------------
60-
ast-stats Total 7_416 127
60+
ast-stats Total 7_472 129
6161
ast-stats ================================================================
6262
hir-stats ================================================================
6363
hir-stats HIR STATS: input_stats
@@ -93,7 +93,7 @@ hir-stats - Binding 216 (NN.N%) 3
9393
hir-stats Block 288 (NN.N%) 6 48
9494
hir-stats GenericBound 256 (NN.N%) 4 64
9595
hir-stats - Trait 256 (NN.N%) 4
96-
hir-stats Attribute 160 (NN.N%) 4 40
96+
hir-stats Attribute 200 (NN.N%) 5 40
9797
hir-stats Variant 144 (NN.N%) 2 72
9898
hir-stats GenericArgs 144 (NN.N%) 3 48
9999
hir-stats FieldDef 128 (NN.N%) 2 64
@@ -119,5 +119,5 @@ hir-stats Mod 32 (NN.N%) 1 32
119119
hir-stats Lifetime 28 (NN.N%) 1 28
120120
hir-stats ForeignItemRef 24 (NN.N%) 1 24
121121
hir-stats ----------------------------------------------------------------
122-
hir-stats Total 8_676 172
122+
hir-stats Total 8_716 173
123123
hir-stats ================================================================

0 commit comments

Comments
 (0)