@@ -55,26 +55,33 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult {
55
55
let ebx;
56
56
let ecx;
57
57
let edx;
58
+
58
59
#[ cfg( target_arch = "x86" ) ]
59
60
{
60
- llvm_asm ! ( "cpuid"
61
- : "={eax}" ( eax) , "={ebx}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
62
- : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
63
- : : ) ;
61
+ asm ! (
62
+ "cpuid" ,
63
+ inlateout( "eax" ) leaf => eax,
64
+ lateout( "ebx" ) ebx,
65
+ inlateout( "ecx" ) sub_leaf => ecx,
66
+ lateout( "edx" ) edx,
67
+ options( nostack, preserves_flags) ,
68
+ ) ;
64
69
}
65
70
#[ cfg( target_arch = "x86_64" ) ]
66
71
{
67
- // x86-64 uses % rbx as the base register, so preserve it.
72
+ // x86-64 uses ` rbx` as the base register, so preserve it.
68
73
// This works around a bug in LLVM with ASAN enabled:
69
74
// https://bugs.llvm.org/show_bug.cgi?id=17907
70
- llvm_asm ! ( r#"
71
- mov %rbx, %rsi
72
- cpuid
73
- xchg %rbx, %rsi
74
- "#
75
- : "={eax}" ( eax) , "={esi}" ( ebx) , "={ecx}" ( ecx) , "={edx}" ( edx)
76
- : "{eax}" ( leaf) , "{ecx}" ( sub_leaf)
77
- : : ) ;
75
+ asm ! (
76
+ "mov rsi, rbx" ,
77
+ "cpuid" ,
78
+ "xchg rsi, rbx" ,
79
+ inlateout( "eax" ) leaf => eax,
80
+ lateout( "esi" ) ebx,
81
+ inlateout( "ecx" ) sub_leaf => ecx,
82
+ lateout( "edx" ) edx,
83
+ options( nostack, preserves_flags) ,
84
+ ) ;
78
85
}
79
86
CpuidResult { eax, ebx, ecx, edx }
80
87
}
0 commit comments