loopAnalysis: Analysis of Loops in LLVM IR Code

View source: R/loop.R

loopAnalysisR Documentation

Analysis of Loops in LLVM IR Code

Description

When analyzing loops, it is good to first call runLoopPass on the Module-class to transform, simplify and canonicalize the loops in the Function-classs. This only needs to be done once as it applies to all of the functions.

Many of the functions that query individual characteristics of a loop only need the Loop-class itself. However, some other functions such as getBounds also require an additional argument (a ScalarEvolution-class object) and the results change if that is created after the loops are obtained.

Accordingly, it is useful to call loopAnalysis on a Function-class to get all the elements that will be needed to query all

Usage

loopAnalysis(fun)
DominatorTree(fun, ...)
PostDominatorTree(fun, ...)
runLoopPass(mod, passes = list(.Call("R_createLoopSimplifyCFGPass")), 
             mgr = passManager(mod)) 

Arguments

fun

the Function-class to be analyzed

mod

the Module-class to run the loop passes

passes

a list of Pass-class objects

mgr

the legacy PassManager-class used to run the loop passes.

...

arguments for methods

Value

A list with three elements

dominatorTree

the DominatorTree-class

loopInfo

the LoopInfo-class object

scalarEvolution

the ScalarEvolution-class object that provides information about variables that are incremented in the loop.

These elements are used in various functions that access information about the loops.

Author(s)

DTL

References

https://llvm.org/docs/LoopTerminology.html

See Also

getBounds and other functions for querying loop information.

Examples

f = system.file("IR/lengths.ir", package = "Rllvm")
m = parseIR(f)
runLoopPass(m)

la = loopAnalysis(m$two)
loop = getLoops(la)[[1]]

getBounds(loop, la)

duncantl/Rllvm documentation built on May 13, 2024, 7:45 p.m.