From 75774476776ce1bf63c9a334183f381a34f9e1ee Mon Sep 17 00:00:00 2001 From: Andreas Jonson Date: Wed, 6 Oct 2021 08:52:13 +0200 Subject: [PATCH] counters: use AT&T inline asm syntax for older LLVM. Rust minimum LLVM version still do not support Intel syntax inline asm --- measureme/src/counters.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/measureme/src/counters.rs b/measureme/src/counters.rs index df92d35..bac4ea3 100644 --- a/measureme/src/counters.rs +++ b/measureme/src/counters.rs @@ -558,12 +558,12 @@ mod hw { fn serialize_instruction_execution() { unsafe { asm!( - "xor eax, eax", + "xor %eax, %eax", // Intel syntax: "xor eax, eax" // LLVM sometimes reserves `ebx` for its internal use, so we need to use // a scratch register for it instead. - "mov {tmp_rbx:r}, rbx", + "mov %rbx, {tmp_rbx:r}", // Intel syntax: "mov {tmp_rbx:r}, rbx" "cpuid", - "mov rbx, {tmp_rbx:r}", + "mov {tmp_rbx:r}, %rbx", // Intel syntax: "mov rbx, {tmp_rbx:r}" tmp_rbx = lateout(reg) _, // `cpuid` clobbers. lateout("eax") _, @@ -571,6 +571,11 @@ mod hw { lateout("ecx") _, options(nostack), + // Older versions of LLVM do not support modifiers in + // Intel syntax inline asm; whenever Rust minimum LLVM version + // supports Intel syntax inline asm, remove and replace above + // instructions with Intel syntax version (from comments). + options(att_syntax), ); } } @@ -588,7 +593,12 @@ mod hw { in("ecx") reg_idx, lateout("eax") lo, lateout("edx") hi, - options(nostack) + options(nostack), + // Older versions of LLVM do not support modifiers in + // Intel syntax inline asm; whenever Rust minimum LLVM version + // supports Intel syntax inline asm, remove and replace above + // instructions with Intel syntax version (from comments). + options(att_syntax), ); } lo as u64 | (hi as u64) << 32