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 {
5656 let ecx;
5757 let edx;
5858
59+ // LLVM sometimes reserves `ebx` for its internal use, we so we need to use
60+ // a scratch register for it instead.
5961 #[ cfg( target_arch = "x86" ) ]
6062 {
6163 asm ! (
64+ "mov {0}, ebx" ,
6265 "cpuid" ,
66+ "xchg {0}, ebx" ,
67+ lateout( reg) ebx,
6368 inlateout( "eax" ) leaf => eax,
64- lateout( "ebx" ) ebx,
6569 inlateout( "ecx" ) sub_leaf => ecx,
6670 lateout( "edx" ) edx,
6771 options( nostack, preserves_flags) ,
6872 ) ;
6973 }
7074 #[ cfg( target_arch = "x86_64" ) ]
7175 {
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
7576 asm ! (
76- "mov rsi , rbx" ,
77+ "mov {0:r} , rbx" ,
7778 "cpuid" ,
78- "xchg rsi, rbx" ,
79+ "xchg {0:r}, rbx" ,
80+ lateout( reg) ebx,
7981 inlateout( "eax" ) leaf => eax,
80- lateout( "esi" ) ebx,
8182 inlateout( "ecx" ) sub_leaf => ecx,
8283 lateout( "edx" ) edx,
8384 options( nostack, preserves_flags) ,
You can’t perform that action at this time.
0 commit comments