@@ -55,26 +55,33 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult {
5555 let ebx;
5656 let ecx;
5757 let edx;
58+
5859 #[ cfg( target_arch = "x86" ) ]
5960 {
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+ ) ;
6469 }
6570 #[ cfg( target_arch = "x86_64" ) ]
6671 {
67- // x86-64 uses % rbx as the base register, so preserve it.
72+ // x86-64 uses ` rbx` as the base register, so preserve it.
6873 // This works around a bug in LLVM with ASAN enabled:
6974 // 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+ ) ;
7885 }
7986 CpuidResult { eax, ebx, ecx, edx }
8087}
0 commit comments