Jlm
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
jlm::llvm::MemoryHoistBarrierOperation Class Referencefinal

#include <IOBarrier.hpp>

Inheritance diagram for jlm::llvm::MemoryHoistBarrierOperation:
Inheritance graph
[legend]
Collaboration diagram for jlm::llvm::MemoryHoistBarrierOperation:
Collaboration graph
[legend]

Public Member Functions

 ~MemoryHoistBarrierOperation () noexcept override
 
 MemoryHoistBarrierOperation (const std::size_t dereferenceableSize)
 
bool operator== (const Operation &other) const noexcept override
 
std::string debug_string () const override
 
std::unique_ptr< Operation > copy () const override
 
std::size_t getDereferenceableSize () const noexcept
 
- Public Member Functions inherited from jlm::rvsdg::SimpleOperation
 ~SimpleOperation () noexcept override
 
 SimpleOperation (std::vector< std::shared_ptr< const jlm::rvsdg::Type > > operands, std::vector< std::shared_ptr< const jlm::rvsdg::Type > > results)
 
size_t narguments () const noexcept
 
const std::shared_ptr< const rvsdg::Type > & argument (size_t index) const noexcept
 
size_t nresults () const noexcept
 
const std::shared_ptr< const rvsdg::Type > & result (size_t index) const noexcept
 
- Public Member Functions inherited from jlm::rvsdg::Operation
virtual ~Operation () noexcept
 
virtual bool operator== (const Operation &other) const noexcept=0
 
bool operator!= (const Operation &other) const noexcept
 

Static Public Member Functions

static rvsdg::Input & getAddressInput (const rvsdg::Node &node) noexcept
 
static rvsdg::Output & getAddressOutput (const rvsdg::Node &node) noexcept
 
static rvsdg::Input & getIOStateInput (const rvsdg::Node &node) noexcept
 
static rvsdg::SimpleNode & createNode (rvsdg::Output &address, rvsdg::Output &ioState, const std::size_t dereferenceableSize)
 
static std::optional< std::vector< rvsdg::Output * > > normalizeNestedMemoryHoistBarriers (const MemoryHoistBarrierOperation &lowerMhbOp, const std::vector< rvsdg::Output * > &operands)
 

Private Attributes

std::size_t dereferenceableSize_
 

Detailed Description

A MemoryHoistBarrierOperation is used to sequentialize memory operations, such as LoadNonVolatileOperation or StoreNonVolatileOperation, after other IO state operations. It has no equivalent in LLVM.

Example:

int f(int * x)
{
opaque(); //calls internally exit(0)
return *x;
}

The above code is valid C code and not undefined even if x is null. The reason for this is that the function opaque() invokes exit(0), and the load operation is never performed at runtime. In the RVSDG, the load operation might have no dependency on the function call to opaque() and therefore it can happen that it is sequentialized before the call operation, transforming the valid program to an undefined program.

The MemoryHoistBarrierOperation ensures a sequentialization of these two operations by routing the address operand through it along with an I/O state as additional operand. The load operation consumes then the result value of the MemoryHoistBarrierOperation, effectively sequentializing the load after the barrier and with that after the call operation:

... io = Call opaque .... ptr2 = MemoryHoistBarrierOperation ptr io ... = LoadNonVolatileOperation ptr2 ...

The MemoryHoistBarrierOperation has a MemoryHoistBarrierOperation::dereferenceableSize_ attribute, which determines the number of bytes that its input address is known to be dereferenceable.

Definition at line 127 of file IOBarrier.hpp.

Constructor & Destructor Documentation

◆ ~MemoryHoistBarrierOperation()

jlm::llvm::MemoryHoistBarrierOperation::~MemoryHoistBarrierOperation ( )
overridedefaultnoexcept

◆ MemoryHoistBarrierOperation()

jlm::llvm::MemoryHoistBarrierOperation::MemoryHoistBarrierOperation ( const std::size_t  dereferenceableSize)
inlineexplicit

Definition at line 132 of file IOBarrier.hpp.

Member Function Documentation

◆ copy()

std::unique_ptr< rvsdg::Operation > jlm::llvm::MemoryHoistBarrierOperation::copy ( ) const
overridevirtual

Implements jlm::rvsdg::Operation.

Definition at line 50 of file IOBarrier.cpp.

◆ createNode()

static rvsdg::SimpleNode & jlm::llvm::MemoryHoistBarrierOperation::createNode ( rvsdg::Output &  address,
rvsdg::Output &  ioState,
const std::size_t  dereferenceableSize 
)
inlinestatic

Definition at line 182 of file IOBarrier.hpp.

◆ debug_string()

std::string jlm::llvm::MemoryHoistBarrierOperation::debug_string ( ) const
overridevirtual

Implements jlm::rvsdg::Operation.

Definition at line 44 of file IOBarrier.cpp.

◆ getAddressInput()

static rvsdg::Input & jlm::llvm::MemoryHoistBarrierOperation::getAddressInput ( const rvsdg::Node &  node)
inlinestaticnoexcept

Definition at line 155 of file IOBarrier.hpp.

◆ getAddressOutput()

static rvsdg::Output & jlm::llvm::MemoryHoistBarrierOperation::getAddressOutput ( const rvsdg::Node &  node)
inlinestaticnoexcept

Definition at line 164 of file IOBarrier.hpp.

◆ getDereferenceableSize()

std::size_t jlm::llvm::MemoryHoistBarrierOperation::getDereferenceableSize ( ) const
inlinenoexcept

Definition at line 149 of file IOBarrier.hpp.

◆ getIOStateInput()

static rvsdg::Input & jlm::llvm::MemoryHoistBarrierOperation::getIOStateInput ( const rvsdg::Node &  node)
inlinestaticnoexcept

Definition at line 173 of file IOBarrier.hpp.

◆ normalizeNestedMemoryHoistBarriers()

std::optional< std::vector< rvsdg::Output * > > jlm::llvm::MemoryHoistBarrierOperation::normalizeNestedMemoryHoistBarriers ( const MemoryHoistBarrierOperation &  lowerMhbOp,
const std::vector< rvsdg::Output * > &  operands 
)
static

The normalization performs the following transformation:

a2 = MemoryHoistBarrierOperation[1] a1 io1 a3 = MemoryHoistBarrierOperation[4] a2 io1 => a3 = MemoryHoistBarrierOperation[1] a1 io1

Parameters
lowerMhbOpThe MemoryHoistBarrierOperation on which the transformation is performed.
operandsThe operands of the MemoryHoistBarrierOperation node.
Returns
If the normalization could be applied, then the results of the MemoryHoistBarrierOperation node after the transformation. Otherwise, std::nullopt.

Definition at line 56 of file IOBarrier.cpp.

◆ operator==()

bool jlm::llvm::MemoryHoistBarrierOperation::operator== ( const Operation &  other) const
overridenoexcept

Definition at line 37 of file IOBarrier.cpp.

Member Data Documentation

◆ dereferenceableSize_

std::size_t jlm::llvm::MemoryHoistBarrierOperation::dereferenceableSize_
private

Dereferenceable size of the memory input in bytes.

Definition at line 216 of file IOBarrier.hpp.


The documentation for this class was generated from the following files: