@@ -543,16 +543,20 @@ mod hw {
543543                asm ! ( 
544544                    // Dummy `cpuid(0)` to serialize instruction execution. 
545545                    "xor eax, eax" , 
546+                     // LLVM sometimes reserves `ebx` for its internal use, we so we need to use 
547+                     // a scratch register for it instead. 
548+                     "mov {tmp_rbx:r}, rbx" , 
546549                    "cpuid" , 
550+                     "mov rbx, {tmp_rbx:r}" , 
547551
548552                    "mov ecx, {rdpmc_ecx:e}" , 
549553                    "rdpmc" , 
550554                    rdpmc_ecx = in( reg)  reg_idx, 
555+                     tmp_rbx = out( reg)  _, 
551556                    out( "eax" )  lo, 
552557                    out( "edx" )  hi, 
553558
554559                    // `cpuid` clobbers (not overwritten by `rdpmc`). 
555-                     out( "ebx" )  _, 
556560                    out( "ecx" )  _, 
557561
558562                    options( nostack) , 
@@ -574,7 +578,11 @@ mod hw {
574578            asm ! ( 
575579                // Dummy `cpuid(0)` to serialize instruction execution. 
576580                "xor eax, eax" , 
581+                 // LLVM sometimes reserves `ebx` for its internal use, we so we need to use 
582+                 // a scratch register for it instead. 
583+                 "mov {tmp_rbx:r}, rbx" , 
577584                "cpuid" , 
585+                 "mov rbx, {tmp_rbx:r}" , 
578586
579587                "mov ecx, {a_rdpmc_ecx:e}" , 
580588                "rdpmc" , 
@@ -586,11 +594,11 @@ mod hw {
586594                a_rdpmc_eax = out( reg)  a_lo, 
587595                a_rdpmc_edx = out( reg)  a_hi, 
588596                b_rdpmc_ecx = in( reg)  b_reg_idx, 
597+                 tmp_rbx = out( reg)  _, 
589598                out( "eax" )  b_lo, 
590599                out( "edx" )  b_hi, 
591600
592601                // `cpuid` clobbers (not overwritten by `rdpmc`). 
593-                 out( "ebx" )  _, 
594602                out( "ecx" )  _, 
595603
596604                options( nostack) , 
0 commit comments