ScEpTIC.AST.transformations.virtual_memory.elements package

Submodules

ScEpTIC.AST.transformations.virtual_memory.elements.base_element module

class ScEpTIC.AST.transformations.virtual_memory.elements.base_element.BaseASTElement

Bases: object

Base component of the AST structure that we use for AST transformations

calls_checkpoint(checkpoint_function_name, ignore_nested_checkpoint=False)

Returns if the basic block has a call to a checkpoint

calls_to(function_names, is_checkpoint=True)

Returns if the basic block has a call to given functions

flatten()

Returns a flatten representation of the element

get_label()

Returns element label

get_labels()

Returns a list of all the labels covered by the object

get_next_labels()

Returns labels of the elements directly reachable from the current one

get_previous_labels()

Returns the labels of the basic blocks that precede the current one

get_real_next_prev()

Returns the real next and prev (conditional entry/exit block have theirs overwritten)

has_backward_jump()

Returns if the basic block performs a backward jump

has_nested_loop()

Returns if the element has a nested loop

jumps_after(label)

Returns if the element can jump after a certain label

static label_to_int(label)

Converts a LLVM IR label to an integer representation

reset_conditional_structure()

Resets the book-keeping information for conditionals structures

set_conditional_entry_label(label)

Sets the label of the entry block

set_conditional_exit_label(label)

Sets the label of the exit block

ScEpTIC.AST.transformations.virtual_memory.elements.basic_block module

class ScEpTIC.AST.transformations.virtual_memory.elements.basic_block.BasicBlock(label, function_name)

Bases: ScEpTIC.AST.transformations.virtual_memory.elements.base_element.BaseASTElement

Basic block of the AST

add_instruction(instruction)

Adds an instruction in the basic block

add_next_label(label)

Adds the label of a subsequent basic block

add_prev_label(label)

Adds the label of a basic block that precedes the one of this object

all_elements = {}
calls_checkpoint(checkpoint_function_name, ignore_nested_checkpoint=False)

Returns if the basic block has a call to a checkpoint

calls_to(function_names, is_checkpoint=True)

Returns if the basic block has a call to given functions

get_all_instructions_targeting_nvm(surrounding_sequence)

Returns a list of all the instructions that target NVM contained in the element

get_all_instructions_targeting_nvm_after(first_instruction, memory_tag, from_conditional=False)
get_label()

Returns element label

get_memory_tag_first_reads_writes(only_nvm=False)
Returns two dictionaries which contains the first reads and writes instructions for each memory tag
  • reads: contains the memory reads operations that happen before the first write

  • writes: contains the first memory write instruction

get_memory_tag_last_reads_writes(only_nvm=False)
Returns two dictionaries which contains the last reads and writes instructions for each memory tag
  • reads: contains the memory reads operations that happen after the last write

  • writes: contains the last memory write instruction

get_nested_loops()

Returns a list with the loop blocks contained in this element (depth 1, no nested loop of nested loops)

has_nested_loop()

Returns if the element has a nested loop

static reset_all_elements()

Resets the list of basic blocks

str_print_instructions = False

ScEpTIC.AST.transformations.virtual_memory.elements.conditional_block module

class ScEpTIC.AST.transformations.virtual_memory.elements.conditional_block.ConditionalBlock(entry_block, exit_block, paths, function_name)

Bases: ScEpTIC.AST.transformations.virtual_memory.elements.base_element.BaseASTElement

Representation of conditionally-executed basic blocks. This corresponds to a bifurcation in the CFG

Entry Block

||

||

Branch A Branch B
||

|| Exit Block

add_to_custom_basic_block(bb_type, instruction)

Adds a given instruction at the end of a custom basic block

all_elements = {}
calls_checkpoint(checkpoint_function_name, ignore_nested_checkpoint=False)

Returns if the conditional contains a basic block that calls a checkpoint

calls_to(function_names, is_checkpoint=True)

Returns if the conditional contains a basic block that calls given functions

flatten()

Returns a flatten representation of the conditional block

get_all_instructions_targeting_nvm(surrounding_sequence)

Returns a list of all the instructions that target NVM contained in the element

Implementation limitation: no nested conditionals (not needed for evaluation) TODO: implement for nested conditionals

get_all_instructions_targeting_nvm_after(indexes, memory_tag)
get_label()

Returns element label

get_labels()

Returns the labels of all the basic blocks included inside the conditional block

get_memory_tag_first_reads_writes(only_nvm=False)
Returns two dictionaries which contains the first reads and writes instructions for each memory tag
  • reads: contains the memory reads operations that happen before the first write

  • writes: contains the first memory write instruction

get_memory_tag_last_reads_writes(only_nvm=False)
Returns two dictionaries which contains the last reads and writes instructions for each memory tag
  • reads: contains the memory reads operations that happen after the last write

  • writes: contains the last memory write instruction

get_nested_loops()

Returns a list with the loop blocks contained in this element (depth 1, no nested loop of nested loops)

has_nested_loop()

Returns if the element has a nested loop

static reset_all_elements()

Resets the list of conditional blocks

ScEpTIC.AST.transformations.virtual_memory.elements.loop_block module

class ScEpTIC.AST.transformations.virtual_memory.elements.loop_block.LoopBlock(function_name)

Bases: ScEpTIC.AST.transformations.virtual_memory.elements.base_element.BaseASTElement

Representation of a loop in its natural form -> header, body, latch

add_basic_block(block_type, basic_block)

Adds a basic block in the loop

Parameters
  • block_type – type of the basic block (header, body, latch)

  • basic_block – the basic block

add_to_custom_exit_block(instruction)

Adds a given instruction at the end of the custom exit block

add_to_custom_preheader(instruction)

Adds a given instruction at the end of the custom pre-header

all_elements = {}
calls_checkpoint(checkpoint_function_name, ignore_nested_checkpoint=False)

Returns if the loop contains a basic block that calls a checkpoint

calls_to(function_names, is_checkpoint=True)

Returns if the loop contains a basic block that calls given functions

flatten()

Returns a flatten representation of the conditional block

get_basic_blocks()

Returns the sequence of elements contained in the header, body, and latch (in correct order)

get_code_len()
get_label()

Returns element label

get_labels()

Returns the labels of all the basic blocks included inside the loop

get_memory_tag_first_reads_writes(only_nvm=False)
Returns two dictionaries which contains the first reads and writes instructions for each memory tag
  • reads: contains the memory reads operations that happen before the first write

  • writes: contains the first memory write instruction

get_memory_tag_last_reads_writes()
Returns two dictionaries which contains the last reads and writes instructions for each memory tag
  • reads: contains the memory reads operations that happen after the last write

  • writes: contains the last memory write instruction

get_memory_tag_reads()
get_memory_tag_writes()
get_nested_loops()

Returns a list with the loop blocks contained in this element (depth 1, no nested loop of nested loops)

has_nested_loop()

Returns if the element has a nested loop

identify_uncertain_instructions()
insert_dummy_writes(create_dummy_write)

Inserts the dummy writes before and after the loop :param create_dummy_write function to create a dummy write

static reset_all_elements()

Resets the list of loop blocks

ScEpTIC.AST.transformations.virtual_memory.elements.memory_access_metadata module

class ScEpTIC.AST.transformations.virtual_memory.elements.memory_access_metadata.CompositeMemoryAccessMetadata(memory_tag, basic_block, instruction)

Bases: object

set_conditional_container(conditional, path)

Sets the conditional element that contains the basic block

set_surrounding_sequence(surrounding_sequence)

Sets the list of instructions where the instruction resides

class ScEpTIC.AST.transformations.virtual_memory.elements.memory_access_metadata.MemoryAccessMetadata(basic_block, index, instruction, memory_tag, missing)

Bases: object

Class representing the metadata required for identifying the first/last memory read/write instructions

set_conditional_container(conditional, path)

Sets the conditional element that contains the basic block

set_surrounding_sequence(surrounding_sequence)

Sets the list of instructions where the instruction resides

Module contents