pub struct LoopAnalysisManager { /* private fields */ }Expand description
Analysis manager handle for loop passes and analyses.
Implementations§
Source§impl LoopAnalysisManager
impl LoopAnalysisManager
Sourcepub unsafe fn from_raw(raw: *mut c_void) -> Self
pub unsafe fn from_raw(raw: *mut c_void) -> Self
Construct from an opaque manager pointer passed by the C++ layer.
§Safety
raw must be a valid pointer to LLVM’s LoopAnalysisManager.
Sourcepub fn add_analysis<P>(&self, pass: P)
pub fn add_analysis<P>(&self, pass: P)
Register a loop analysis pass.
Examples found in repository?
examples/all_pass_kinds.rs (line 485)
474 fn run_pass(
475 &self,
476 loop_header: llvm_pm::traits::LLVMBasicBlockRef,
477 manager: &LoopAnalysisManager,
478 ) -> PreservedAnalyses {
479 self.ran.fetch_add(1, Ordering::SeqCst);
480 if self
481 .registered
482 .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
483 .is_ok()
484 {
485 manager.add_analysis(LoopHeaderNonNullAnalysis);
486 }
487 let ok = *manager.get_result::<LoopHeaderNonNullAnalysis>(loop_header);
488 if ok {
489 // SAFETY: loop_header originates from LLVM pass callback and belongs to a live function.
490 let function = unsafe { LLVMGetBasicBlockParent(loop_header) };
491 assert!(!function.is_null(), "loop header must have parent function");
492 // SAFETY: parent function pointer was obtained from a valid loop header.
493 unsafe { set_pass_delta_from_function_ref(function, DELTA_LOOP) };
494 }
495 PreservedAnalyses::None
496 }Sourcepub fn get_result<A>(&self, loop_header: LLVMBasicBlockRef) -> &A::Resultwhere
A: LlvmLoopAnalysis + 'static,
A::Result: 'static,
pub fn get_result<A>(&self, loop_header: LLVMBasicBlockRef) -> &A::Resultwhere
A: LlvmLoopAnalysis + 'static,
A::Result: 'static,
Get (or compute) analysis result for a loop header.
Examples found in repository?
examples/all_pass_kinds.rs (line 487)
474 fn run_pass(
475 &self,
476 loop_header: llvm_pm::traits::LLVMBasicBlockRef,
477 manager: &LoopAnalysisManager,
478 ) -> PreservedAnalyses {
479 self.ran.fetch_add(1, Ordering::SeqCst);
480 if self
481 .registered
482 .compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
483 .is_ok()
484 {
485 manager.add_analysis(LoopHeaderNonNullAnalysis);
486 }
487 let ok = *manager.get_result::<LoopHeaderNonNullAnalysis>(loop_header);
488 if ok {
489 // SAFETY: loop_header originates from LLVM pass callback and belongs to a live function.
490 let function = unsafe { LLVMGetBasicBlockParent(loop_header) };
491 assert!(!function.is_null(), "loop header must have parent function");
492 // SAFETY: parent function pointer was obtained from a valid loop header.
493 unsafe { set_pass_delta_from_function_ref(function, DELTA_LOOP) };
494 }
495 PreservedAnalyses::None
496 }Sourcepub fn get_cached_result<A>(
&self,
loop_header: LLVMBasicBlockRef,
) -> Option<&A::Result>where
A: LlvmLoopAnalysis + 'static,
A::Result: 'static,
pub fn get_cached_result<A>(
&self,
loop_header: LLVMBasicBlockRef,
) -> Option<&A::Result>where
A: LlvmLoopAnalysis + 'static,
A::Result: 'static,
Get cached analysis result if present.
Auto Trait Implementations§
impl !Send for LoopAnalysisManager
impl !Sync for LoopAnalysisManager
impl Freeze for LoopAnalysisManager
impl RefUnwindSafe for LoopAnalysisManager
impl Unpin for LoopAnalysisManager
impl UnsafeUnpin for LoopAnalysisManager
impl UnwindSafe for LoopAnalysisManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more