File tree Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Expand file tree Collapse file tree 1 file changed +8
-7
lines changed Original file line number Diff line number Diff line change @@ -56,28 +56,29 @@ pub unsafe fn __cpuid_count(leaf: u32, sub_leaf: u32) -> CpuidResult {
56
56
let ecx;
57
57
let edx;
58
58
59
+ // LLVM sometimes reserves `ebx` for its internal use, we so we need to use
60
+ // a scratch register for it instead.
59
61
#[ cfg( target_arch = "x86" ) ]
60
62
{
61
63
asm ! (
64
+ "mov {0}, ebx" ,
62
65
"cpuid" ,
66
+ "xchg {0}, ebx" ,
67
+ lateout( reg) ebx,
63
68
inlateout( "eax" ) leaf => eax,
64
- lateout( "ebx" ) ebx,
65
69
inlateout( "ecx" ) sub_leaf => ecx,
66
70
lateout( "edx" ) edx,
67
71
options( nostack, preserves_flags) ,
68
72
) ;
69
73
}
70
74
#[ cfg( target_arch = "x86_64" ) ]
71
75
{
72
- // x86-64 uses `rbx` as the base register, so preserve it.
73
- // This works around a bug in LLVM with ASAN enabled:
74
- // https://bugs.llvm.org/show_bug.cgi?id=17907
75
76
asm ! (
76
- "mov rsi , rbx" ,
77
+ "mov {0:r} , rbx" ,
77
78
"cpuid" ,
78
- "xchg rsi, rbx" ,
79
+ "xchg {0:r}, rbx" ,
80
+ lateout( reg) ebx,
79
81
inlateout( "eax" ) leaf => eax,
80
- lateout( "esi" ) ebx,
81
82
inlateout( "ecx" ) sub_leaf => ecx,
82
83
lateout( "edx" ) edx,
83
84
options( nostack, preserves_flags) ,
You can’t perform that action at this time.
0 commit comments