]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_data_structures/profiling.rs
Rollup merge of #69340 - Centril:self-ctor-normalize, r=nikomatsakis
[rust.git] / src / librustc_data_structures / profiling.rs
index debda9f0a0a24f409701eedb3e7d945f124803cc..f2c80510f226945413530eef779359c3b5e0f577 100644 (file)
@@ -81,6 +81,7 @@
 //!
 //! [mm]: https://github.com/rust-lang/measureme/
 
+use crate::cold_path;
 use crate::fx::FxHashMap;
 
 use std::borrow::Borrow;
@@ -127,6 +128,7 @@ struct EventFilter: u32 {
 
         const QUERY_KEYS         = 1 << 5;
         const FUNCTION_ARGS      = 1 << 6;
+        const LLVM               = 1 << 7;
 
         const DEFAULT = Self::GENERIC_ACTIVITIES.bits |
                         Self::QUERY_PROVIDERS.bits |
@@ -150,6 +152,7 @@ struct EventFilter: u32 {
     ("query-keys", EventFilter::QUERY_KEYS),
     ("function-args", EventFilter::FUNCTION_ARGS),
     ("args", EventFilter::ARGS),
+    ("llvm", EventFilter::LLVM),
 ];
 
 /// Something that uniquely identifies a query invocation.
@@ -364,6 +367,15 @@ pub fn with_profiler(&self, f: impl FnOnce(&SelfProfiler)) {
     pub fn enabled(&self) -> bool {
         self.profiler.is_some()
     }
+
+    #[inline]
+    pub fn llvm_recording_enabled(&self) -> bool {
+        self.event_filter_mask.contains(EventFilter::LLVM)
+    }
+    #[inline]
+    pub fn get_self_profiler(&self) -> Option<Arc<SelfProfiler>> {
+        self.profiler.clone()
+    }
 }
 
 pub struct SelfProfiler {
@@ -520,9 +532,11 @@ pub fn start(
     #[inline]
     pub fn finish_with_query_invocation_id(self, query_invocation_id: QueryInvocationId) {
         if let Some(guard) = self.0 {
-            let event_id = StringId::new_virtual(query_invocation_id.0);
-            let event_id = EventId::from_virtual(event_id);
-            guard.finish_with_override_event_id(event_id);
+            cold_path(|| {
+                let event_id = StringId::new_virtual(query_invocation_id.0);
+                let event_id = EventId::from_virtual(event_id);
+                guard.finish_with_override_event_id(event_id);
+            });
         }
     }