about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2020-11-05 19:28:36 +0200
committerEduard-Mihai Burtescu <eddyb@lyken.rs>2022-06-13 08:06:07 +0000
commit85947f0fe26360c17ea877ae67cac7c092de9cfc (patch)
tree86067c34a73b1f1bfc6d7475cd4784edad293685 /compiler
parent44783f1db0bd1076d825b2b681c4220bbf97bbec (diff)
downloadrust-85947f0fe26360c17ea877ae67cac7c092de9cfc.tar.gz
rust-85947f0fe26360c17ea877ae67cac7c092de9cfc.zip
rustc_trait_selection: work around instruction-counting non-determinism.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_trait_selection/src/traits/select/mod.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index a484b594418..60e13d9b8c3 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -1525,6 +1525,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
         other: &EvaluatedCandidate<'tcx>,
         needs_infer: bool,
     ) -> bool {
+        // HACK(eddyb) remove instruction-counting noise from `-Z self-profile`.
+        #[cfg(target_arch = "x86_64")]
+        unsafe {
+            std::arch::asm!("mfence", options(nostack));
+        }
+
         if victim.candidate == other.candidate {
             return true;
         }