Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
71213ef
Replace empty gotos with assume false
henrybatt Apr 17, 2025
89491e6
Create SlicerLogger
henrybatt Apr 17, 2025
d240896
Create Slicer Summaries from results
henrybatt Apr 17, 2025
5694a1c
Slicer IDE Analysis to build sets
henrybatt Apr 17, 2025
025d830
Create Slicer class to run analysis
henrybatt Apr 17, 2025
668701c
Run slicer on IR
henrybatt Apr 17, 2025
ea2549f
Added performance timers + cleanup
henrybatt Apr 22, 2025
a5649c2
Cleanup criterion pair generation
henrybatt Apr 22, 2025
c97a5f6
Cleanup IDEAnalysis with better match grouping
henrybatt Apr 22, 2025
f8b17ae
Merge branch 'main' into ir-slicing
henrybatt May 7, 2025
ac3db10
Extend IDEAnalysis to allow stateless transfer functions
henrybatt May 8, 2025
a1bfecf
Use new IDE Transfers in Slicer Analysis
henrybatt May 9, 2025
7e007d0
Move StatementSlice def
henrybatt May 9, 2025
d6e8a4d
Add Summary toString + Fix single assign issue
henrybatt May 9, 2025
1d1fafd
Updated summary generation
henrybatt May 9, 2025
8ab41df
Separate into Slicer Phase1 + Cleanup
henrybatt May 9, 2025
20bb97b
Added in Phase2 + debugging methods
henrybatt May 9, 2025
dd759f6
Cleanup RunUtils so slicer is single line usage
henrybatt May 9, 2025
4a4ed5e
Merge branch 'main' into ir-slicing
henrybatt May 10, 2025
1e924ca
Slicer indirect call analysis extended
henrybatt May 12, 2025
25fa239
Slicer defined starting node
henrybatt May 12, 2025
04523a5
Cleanup + added logging of statements removed
henrybatt May 12, 2025
d393e94
Utilise Slicer results for parameter reduction
henrybatt May 12, 2025
42bda04
Fixed impact detection error
henrybatt May 13, 2025
568fefe
Added BASIL flags to enable slicer
henrybatt May 13, 2025
d65fe53
Add in SC to all transfers
henrybatt May 14, 2025
a697882
SlicingCriterion now used FOR not FROM
henrybatt May 14, 2025
b489925
Remove matcher for criterion definition
henrybatt May 15, 2025
b2e6814
Restructure SlicerAnalysis results
henrybatt May 15, 2025
c272d33
Parse Slicer config to build starting criterion
henrybatt May 15, 2025
b926a02
Cleanup + define transfer application
henrybatt May 15, 2025
49973b6
Added label to DSL directCall
henrybatt May 22, 2025
c1363be
Improve call impact detection
henrybatt May 22, 2025
bf2ea2b
Only add assume/assert if criterion is still alive (not empty)
henrybatt May 22, 2025
baab705
Cleanup
henrybatt May 22, 2025
d2d705c
Add and remove temp NOP if starting on call edge to insert criterion
henrybatt May 22, 2025
02ade11
Use IRWalker to get call edge pred
henrybatt May 22, 2025
2045775
Remove LocalVars when entering new call and readd after exit
henrybatt May 22, 2025
9a1f4b2
Replace Registers with Global detection
henrybatt May 22, 2025
9615de6
Move NOP insertion into Phase1 + change access modifiers
henrybatt May 23, 2025
1748496
Clean up DirectCall transfer and impact detection
henrybatt May 23, 2025
9138505
Added simplify & memory-transform flag checks for slicer
henrybatt May 26, 2025
72d71f0
Ensure global criterion are correctly handled across calls
henrybatt May 26, 2025
b49837a
Remove Pair Generation
henrybatt May 26, 2025
34bfede
Add jumps into variable detection
henrybatt May 26, 2025
8f87560
Remove Structures
henrybatt May 26, 2025
fa3bbfa
Merge branch 'main' into ir-slicing
henrybatt May 27, 2025
a318be8
Convert MemoryStore + MemoryLoad indexes as required
henrybatt May 30, 2025
f3f08cc
Formatter
henrybatt May 30, 2025
678f750
Cache call procedure globals
henrybatt May 30, 2025
38301b4
Improve logging levels on Slicer
henrybatt May 30, 2025
31ebf47
Ensure variable exists in parameter list
henrybatt May 30, 2025
c25f88b
Added invariant checking after IR Slice
henrybatt Jun 11, 2025
e7c81e3
Add SlicerConfig to Basil tests + fix Boogie verification checking
henrybatt Jun 19, 2025
6e4af26
Slicer IDE - cleanup + strip locals on flow back
henrybatt Jun 19, 2025
941cd4a
Filter SlicerConfig + correctly parse return command variables
henrybatt Jun 19, 2025
599a580
Slicer - Formatting + early call handling
henrybatt Jun 19, 2025
a518cc3
Added slicer scenario tests
henrybatt Jun 20, 2025
d434fa6
Added tests that slice system tests to ensure they still verify
henrybatt Jun 20, 2025
fbf2124
Remove StatementSlice type + refactor our unnecessary methods
henrybatt Jun 20, 2025
2c7cfa4
Don't strip unreachables if slicer on
henrybatt Jun 22, 2025
5ace412
Added test to check if non main criterion procedure preserved
henrybatt Jun 22, 2025
30ef708
Move and merge all slicer classes into 1 file in ir.transforms.
henrybatt Jun 23, 2025
2cae2db
Added comments to slicer + cleanup access
henrybatt Jun 23, 2025
30602b2
Fix test imports
henrybatt Jun 23, 2025
11d2f58
Merge branch 'main' into ir-slicing
henrybatt Jun 23, 2025
1fa4bad
Cleanup comments + loggers
henrybatt Jun 23, 2025
63500fe
Add cli arg docs
henrybatt Jun 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 27 additions & 2 deletions src/main/scala/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.collection.{immutable, mutable}
import scala.language.postfixOps
import scala.sys.process.*
import util.*
import mainargs.{Flag, ParserForClass, arg, main}
import mainargs.{Flag, ParserForClass, arg, main, TokensReader}
import util.DSAConfig.{Checks, Prereq, Standard}
import util.boogie_interaction.BoogieResultKind

Expand Down Expand Up @@ -216,9 +216,17 @@ object Main {
@arg(name = "memory-transform", doc = "Transform memory access to region accesses")
memoryTransform: Flag,
@arg(name = "noif", doc = "Disable information flow security transform in Boogie output")
noif: Flag
noif: Flag,
@arg(name = "slice", doc = "Block name to begin program slicing from (requires --criterion, --simplify, --dsa, and --memory-transform flags)")
slice: Option[String],
@arg(name = "criterion", doc = "Collection of comma separated variable names outlining the initial slicing criterion values (requires --slice, --simplify, --dsa, and --memory-transform flags)")
criterion: Option[List[String]]
)

implicit object ListStringRead extends TokensReader.Simple[List[String]]:
def shortName = "list<str>"
def read(strs: Seq[String]) = Right(strs.flatMap(_.split(",\\s*")).toList)

def main(args: Array[String]): Unit = {
val parser = ParserForClass[Config]
val parsed = parser.constructEither(args.toSeq)
Expand Down Expand Up @@ -327,6 +335,22 @@ object Main {
)
}

val slicerConfig = (conf.slice, conf.criterion) match {
case (Some(blockLabel), Some(criterion)) => {
if !conf.memoryTransform.value then throw IllegalArgumentException("Slicer requires --memory-transform")
if !conf.simplify.value then throw IllegalArgumentException("Slicer requires --simplify")
dsa match {
case None => throw IllegalArgumentException("Slicer requires --dsa checks|standard")
case Some(Prereq) => throw IllegalArgumentException("Slicer requires --dsa checks|standard")
case _ => ()
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I can tell, slicer doesn't directly use the results from DSA but implicitly benefits from the region separation, why is the region pass enforced here?

Some(SlicerConfig(blockLabel, criterion.toSet))
}
case (Some(_), None) => throw IllegalArgumentException("Slicer requires both --slice AND --criterion")
case (None, Some(_)) => throw IllegalArgumentException("Slicer requires both --slice AND --criterion")
case (None, None) => None
}

if (loadingInputs.specFile.isDefined && loadingInputs.relfFile.isEmpty) {
throw IllegalArgumentException("--spec requires --relf")
}
Expand All @@ -353,6 +377,7 @@ object Main {
outputPrefix = conf.outFileName,
dsaConfig = dsa,
memoryTransform = conf.memoryTransform.value,
slicerConfig = slicerConfig,
assertCalleeSaved = calleeSaved
)

Expand Down
44 changes: 36 additions & 8 deletions src/main/scala/analysis/IDEAnalysis.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ package analysis

import ir.{CFGPosition, Command, DirectCall, GoTo, Return, IndirectCall, Procedure, Program}

/**
* Adapted from Tip
* https://github.com/cs-au-dk/TIP/blob/master/src/tip/solvers/IDEAnalysis.scala
*
* The special item representing the empty element in IDE.
*/
final case class Lambda()

/** Base trait for IDE analyses.
/** Transfer functions that define IDE analysis edges.
*
* @tparam E
* Type of the function entry CFGPosition
Expand All @@ -19,13 +25,9 @@ final case class Lambda()
* @tparam T
* type of elements of the value lattice
* @tparam L
* the type of the value lattice Adapted from Tip
* https://github.com/cs-au-dk/TIP/blob/master/src/tip/solvers/IDEAnalysis.scala The special item representing the
* empty element in IDE.
* the type of the value lattice
*/
trait IDEAnalysis[E, EE, C, R, D, T, L <: Lattice[T]] {
val program: Program

trait IDETransferFunctions[E, EE, C, R, D, T, L <: Lattice[T]] {
type DL = Either[D, Lambda]

/** The value lattice.
Expand Down Expand Up @@ -53,7 +55,33 @@ trait IDEAnalysis[E, EE, C, R, D, T, L <: Lattice[T]] {
def edgesOther(n: CFGPosition)(d: DL): Map[DL, EdgeFunction[T]]
}

// IndirectCall in these is because they are returns so that can be further tightened in future
/* Traits for Forward and Backward IDE Transfer Functions */
trait ForwardIDETransferFunctions[D, T, L <: Lattice[T]] extends IDETransferFunctions[Procedure, Return, DirectCall, Command, D, T, L]

trait BackwardIDETransferFunctions[D, T, L <: Lattice[T]] extends IDETransferFunctions[Return, Procedure, Command, DirectCall, D, T, L]


/** Base trait for IDE analyses.
*
* @tparam E
* Type of the function entry CFGPosition
* @tparam EE
* Type of the function exit CFGPosition
* @tparam C
* Type of a function call
* @tparam R
* Type of a call return site
* @tparam D
* the type of items
* @tparam T
* type of elements of the value lattice
* @tparam L
* the type of the value lattice
*/
trait IDEAnalysis[E, EE, C, R, D, T, L <: Lattice[T]] extends IDETransferFunctions[E, EE, C, R, D, T, L] {
val program: Program
}

trait ForwardIDEAnalysis[D, T, L <: Lattice[T]] extends IDEAnalysis[Procedure, Return, DirectCall, Command, D, T, L]

trait BackwardIDEAnalysis[D, T, L <: Lattice[T]] extends IDEAnalysis[Return, Procedure, Command, DirectCall, D, T, L]
2 changes: 1 addition & 1 deletion src/main/scala/ir/dsl/DSL.scala
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ def directCall(lhs: Iterable[(String, Variable)], rhs: call): EventuallyCall =

def directCall(tgt: String): EventuallyCall = directCall(Nil, tgt, Nil)

def directCall(tgt: String, label: Option[String]): EventuallyCall = directCall(Nil, tgt, Nil)
def directCall(tgt: String, label: Option[String]): EventuallyCall = directCall(Nil, tgt, Nil, label)

def indirectCall(tgt: Variable): EventuallyIndirectCall = EventuallyIndirectCall(tgt)

Expand Down
Loading