Skip to main content

LoopAnalysisManager

Struct LoopAnalysisManager 

Source
pub struct LoopAnalysisManager { /* private fields */ }
Expand description

Analysis manager handle for loop passes and analyses.

Implementations§

Source§

impl LoopAnalysisManager

Source

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.

Source

pub fn as_raw(&self) -> *mut c_void

Get the underlying opaque pointer.

Source

pub fn add_analysis<P>(&self, pass: P)
where P: LlvmLoopAnalysis + 'static, <P as LlvmLoopAnalysis>::Result: 'static,

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    }
Source

pub fn get_result<A>(&self, loop_header: LLVMBasicBlockRef) -> &A::Result
where 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    }
Source

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§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.