class MemorySSAUpdater

Declaration

class MemorySSAUpdater { /* full declaration omitted */ };

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:70

Method Overview

  • public MemorySSAUpdater(llvm::MemorySSA * MSSA)
  • public void applyInsertUpdates(ArrayRef<llvm::CFGUpdate> Updates, llvm::DominatorTree & DT)
  • public void applyUpdates(ArrayRef<llvm::CFGUpdate> Updates, llvm::DominatorTree & DT)
  • public void changeCondBranchToUnconditionalTo(const llvm::BranchInst * BI, const llvm::BasicBlock * To)
  • public void changeToUnreachable(const llvm::Instruction * I)
  • public llvm::MemoryUseOrDef * createMemoryAccessAfter(llvm::Instruction * I, llvm::MemoryAccess * Definition, llvm::MemoryAccess * InsertPt)
  • public llvm::MemoryUseOrDef * createMemoryAccessBefore(llvm::Instruction * I, llvm::MemoryAccess * Definition, llvm::MemoryUseOrDef * InsertPt)
  • public llvm::MemoryAccess * createMemoryAccessInBB(llvm::Instruction * I, llvm::MemoryAccess * Definition, const llvm::BasicBlock * BB, MemorySSA::InsertionPlace Point)
  • public llvm::MemorySSA * getMemorySSA() const
  • public void insertDef(llvm::MemoryDef * Def, bool RenameUses = false)
  • public void insertUse(llvm::MemoryUse * Use, bool RenameUses = false)
  • public void moveAfter(llvm::MemoryUseOrDef * What, llvm::MemoryUseOrDef * Where)
  • public void moveAllAfterMergeBlocks(llvm::BasicBlock * From, llvm::BasicBlock * To, llvm::Instruction * Start)
  • public void moveAllAfterSpliceBlocks(llvm::BasicBlock * From, llvm::BasicBlock * To, llvm::Instruction * Start)
  • public void moveBefore(llvm::MemoryUseOrDef * What, llvm::MemoryUseOrDef * Where)
  • public void moveToPlace(llvm::MemoryUseOrDef * What, llvm::BasicBlock * BB, MemorySSA::InsertionPlace Where)
  • public void removeBlocks(const SmallSetVector<llvm::BasicBlock *, 8> & DeadBlocks)
  • public void removeDuplicatePhiEdgesBetween(const llvm::BasicBlock * From, const llvm::BasicBlock * To)
  • public void removeEdge(llvm::BasicBlock * From, llvm::BasicBlock * To)
  • public void removeMemoryAccess(const llvm::Instruction * I, bool OptimizePhis = false)
  • public void removeMemoryAccess(llvm::MemoryAccess *, bool OptimizePhis = false)
  • public void updateExitBlocksForClonedLoop(ArrayRef<llvm::BasicBlock *> ExitBlocks, const llvm::ValueToValueMapTy & VMap, llvm::DominatorTree & DT)
  • public void updateExitBlocksForClonedLoop(ArrayRef<llvm::BasicBlock *> ExitBlocks, ArrayRef<std::unique_ptr<ValueToValueMapTy>> VMaps, llvm::DominatorTree & DT)
  • public void updateForClonedBlockIntoPred(llvm::BasicBlock * BB, llvm::BasicBlock * P1, const llvm::ValueToValueMapTy & VM)
  • public void updateForClonedLoop(const llvm::LoopBlocksRPO & LoopBlocks, ArrayRef<llvm::BasicBlock *> ExitBlocks, const llvm::ValueToValueMapTy & VM, bool IgnoreIncomingWithNoClones = false)
  • public void updatePhisWhenInsertingUniqueBackedgeBlock(llvm::BasicBlock * LoopHeader, llvm::BasicBlock * LoopPreheader, llvm::BasicBlock * BackedgeBlock)
  • public void wireOldPredecessorsToNewImmediatePredecessor(llvm::BasicBlock * Old, llvm::BasicBlock * New, ArrayRef<llvm::BasicBlock *> Preds, bool IdenticalEdgesWereMerged = true)

Methods

MemorySSAUpdater(llvm::MemorySSA* MSSA)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:82

Parameters

llvm::MemorySSA* MSSA

void applyInsertUpdates(
    ArrayRef<llvm::CFGUpdate> Updates,
    llvm::DominatorTree& DT)

Description

Apply CFG insert updates, analogous with the DT edge updates.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:139

Parameters

ArrayRef<llvm::CFGUpdate> Updates
llvm::DominatorTree& DT

void applyUpdates(
    ArrayRef<llvm::CFGUpdate> Updates,
    llvm::DominatorTree& DT)

Description

Apply CFG updates, analogous with the DT edge updates.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:137

Parameters

ArrayRef<llvm::CFGUpdate> Updates
llvm::DominatorTree& DT

void changeCondBranchToUnconditionalTo(
    const llvm::BranchInst* BI,
    const llvm::BasicBlock* To)

Description

Conditional branch BI is changed or replaced with an unconditional branch to `To`. Update Phis in BI's successors to remove BI's BB.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:256

Parameters

const llvm::BranchInst* BI
const llvm::BasicBlock* To

void changeToUnreachable(
    const llvm::Instruction* I)

Description

Instruction I will be changed to an unreachable. Remove all accesses in I's block that follow I (inclusive), and update the Phis in the blocks' successors.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:252

Parameters

const llvm::Instruction* I

llvm::MemoryUseOrDef* createMemoryAccessAfter(
    llvm::Instruction* I,
    llvm::MemoryAccess* Definition,
    llvm::MemoryAccess* InsertPt)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:220

Parameters

llvm::Instruction* I
llvm::MemoryAccess* Definition
llvm::MemoryAccess* InsertPt

llvm::MemoryUseOrDef* createMemoryAccessBefore(
    llvm::Instruction* I,
    llvm::MemoryAccess* Definition,
    llvm::MemoryUseOrDef* InsertPt)

Description

Create a MemoryAccess in MemorySSA before or after an existing MemoryAccess. Returns the new MemoryAccess. This should be called when a memory instruction is created that is being used to replace an existing memory instruction. It will *not* create PHI nodes, or verify the clobbering definition. Note: If a MemoryAccess already exists for I, this function will make it inaccessible and it *must* have removeMemoryAccess called on it.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:217

Parameters

llvm::Instruction* I
llvm::MemoryAccess* Definition
llvm::MemoryUseOrDef* InsertPt

llvm::MemoryAccess* createMemoryAccessInBB(
    llvm::Instruction* I,
    llvm::MemoryAccess* Definition,
    const llvm::BasicBlock* BB,
    MemorySSA::InsertionPlace Point)

Description

Create a MemoryAccess in MemorySSA at a specified point in a block, with a specified clobbering definition. Returns the new MemoryAccess. This should be called when a memory instruction is created that is being used to replace an existing memory instruction. It will *not* create PHI nodes, or verify the clobbering definition. The insertion place is used solely to determine where in the memoryssa access lists the instruction will be placed. The caller is expected to keep ordering the same as instructions. It will return the new MemoryAccess. Note: If a MemoryAccess already exists for I, this function will make it inaccessible and it *must* have removeMemoryAccess called on it.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:203

Parameters

llvm::Instruction* I
llvm::MemoryAccess* Definition
const llvm::BasicBlock* BB
MemorySSA::InsertionPlace Point

llvm::MemorySSA* getMemorySSA() const

Description

Get handle on MemorySSA.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:260

void insertDef(llvm::MemoryDef* Def,
               bool RenameUses = false)

Description

Insert a definition into the MemorySSA IR. RenameUses will rename any use below the new def block (and any inserted phis). RenameUses should be set to true if the definition may cause new aliases for loads below it. This is not the case for hoisting or sinking or other forms of code *movement*. It *is* the case for straight code insertion. For example: store a if (foo) { } load a Moving the store into the if block, and calling insertDef, does not require RenameUses. However, changing it to: store a if (foo) { store b } load a Where a mayalias b, *does* require RenameUses be set to true.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:101

Parameters

llvm::MemoryDef* Def
bool RenameUses = false

void insertUse(llvm::MemoryUse* Use,
               bool RenameUses = false)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:102

Parameters

llvm::MemoryUse* Use
bool RenameUses = false

void moveAfter(llvm::MemoryUseOrDef* What,
               llvm::MemoryUseOrDef* Where)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:142

Parameters

llvm::MemoryUseOrDef* What
llvm::MemoryUseOrDef* Where

void moveAllAfterMergeBlocks(
    llvm::BasicBlock* From,
    llvm::BasicBlock* To,
    llvm::Instruction* Start)

Description

`From` block was merged into `To`. There is a CFG edge from `To` to `From`.`To` still branches to `From`, but all instructions were moved and `From` is now an empty block; `From` is about to be deleted. Move all accesses from `From` to `To` starting at instruction `Start`. `To` may have multiple successors, `From` has a single predecessor. `From` may have successors with MPhi nodes, replace their incoming block with `To`. |------| |------| | To | | To | |------| | | || => | | \ / | | |------| | | < - Start | From | | | |------| |------|

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:174

Parameters

llvm::BasicBlock* From
llvm::BasicBlock* To
llvm::Instruction* Start

void moveAllAfterSpliceBlocks(
    llvm::BasicBlock* From,
    llvm::BasicBlock* To,
    llvm::Instruction* Start)

Description

`From` block was spliced into `From` and `To`. There is a CFG edge from `From` to `To`. Move all accesses from `From` to `To` starting at instruction `Start`. `To` is newly created BB, so empty of MemorySSA::MemoryAccesses. Edges are already updated, so successors of `To` with MPhi nodes need to update incoming block. |------| |------| | From | | From | | | |------| | | || | | => \ / | | |------| < - Start | | | To | |------| |------|

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:158

Parameters

llvm::BasicBlock* From
llvm::BasicBlock* To
llvm::Instruction* Start

void moveBefore(llvm::MemoryUseOrDef* What,
                llvm::MemoryUseOrDef* Where)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:141

Parameters

llvm::MemoryUseOrDef* What
llvm::MemoryUseOrDef* Where

void moveToPlace(llvm::MemoryUseOrDef* What,
                 llvm::BasicBlock* BB,
                 MemorySSA::InsertionPlace Where)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:143

Parameters

llvm::MemoryUseOrDef* What
llvm::BasicBlock* BB
MemorySSA::InsertionPlace Where

void removeBlocks(
    const SmallSetVector<llvm::BasicBlock*, 8>&
        DeadBlocks)

Description

Remove all MemoryAcceses in a set of BasicBlocks about to be deleted. Assumption we make here: all uses of deleted defs and phi must either occur in blocks about to be deleted (thus will be deleted as well), or they occur in phis that will simply lose an incoming value. Deleted blocks still have successor info, but their predecessor edges and Phi nodes may already be updated. Instructions in DeadBlocks should be deleted after this call.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:247

Parameters

const SmallSetVector<llvm::BasicBlock*, 8>& DeadBlocks

void removeDuplicatePhiEdgesBetween(
    const llvm::BasicBlock* From,
    const llvm::BasicBlock* To)

Description

Update the MemoryPhi in `To` to have a single incoming edge from `From`, following a CFG change that replaced multiple edges (switch) with a direct branch.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:109

Parameters

const llvm::BasicBlock* From
const llvm::BasicBlock* To

void removeEdge(llvm::BasicBlock* From,
                llvm::BasicBlock* To)

Description

Update the MemoryPhi in `To` following an edge deletion between `From` and `To`. If `To` becomes unreachable, a call to removeBlocks should be made.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:105

Parameters

llvm::BasicBlock* From
llvm::BasicBlock* To

void removeMemoryAccess(
    const llvm::Instruction* I,
    bool OptimizePhis = false)

Description

Remove MemoryAccess for a given instruction, if a MemoryAccess exists. This should be called when an instruction (load/store) is deleted from the program.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:235

Parameters

const llvm::Instruction* I
bool OptimizePhis = false

void removeMemoryAccess(llvm::MemoryAccess*,
                        bool OptimizePhis = false)

Description

Remove a MemoryAccess from MemorySSA, including updating all definitions and uses. This should be called when a memory instruction that has a MemoryAccess associated with it is erased from the program. For example, if a store or load is simply erased (not replaced), removeMemoryAccess should be called on the MemoryAccess for that store/load.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:230

Parameters

llvm::MemoryAccess*
bool OptimizePhis = false

void updateExitBlocksForClonedLoop(
    ArrayRef<llvm::BasicBlock*> ExitBlocks,
    const llvm::ValueToValueMapTy& VMap,
    llvm::DominatorTree& DT)

Description

Update phi nodes in exit block successors following cloning. Exit blocks that were not cloned don't have additional predecessors added.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:129

Parameters

ArrayRef<llvm::BasicBlock*> ExitBlocks
const llvm::ValueToValueMapTy& VMap
llvm::DominatorTree& DT

void updateExitBlocksForClonedLoop(
    ArrayRef<llvm::BasicBlock*> ExitBlocks,
    ArrayRef<std::unique_ptr<ValueToValueMapTy>>
        VMaps,
    llvm::DominatorTree& DT)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:132

Parameters

ArrayRef<llvm::BasicBlock*> ExitBlocks
ArrayRef<std::unique_ptr<ValueToValueMapTy>> VMaps
llvm::DominatorTree& DT

void updateForClonedBlockIntoPred(
    llvm::BasicBlock* BB,
    llvm::BasicBlock* P1,
    const llvm::ValueToValueMapTy& VM)

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:125

Parameters

llvm::BasicBlock* BB
llvm::BasicBlock* P1
const llvm::ValueToValueMapTy& VM

void updateForClonedLoop(
    const llvm::LoopBlocksRPO& LoopBlocks,
    ArrayRef<llvm::BasicBlock*> ExitBlocks,
    const llvm::ValueToValueMapTy& VM,
    bool IgnoreIncomingWithNoClones = false)

Description

Update MemorySSA after a loop was cloned, given the blocks in RPO order, the exit blocks and a 1:1 mapping of all blocks and instructions cloned. This involves duplicating all defs and uses in the cloned blocks Updating phi nodes in exit block successors is done separately.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:119

Parameters

const llvm::LoopBlocksRPO& LoopBlocks
ArrayRef<llvm::BasicBlock*> ExitBlocks
const llvm::ValueToValueMapTy& VM
bool IgnoreIncomingWithNoClones = false

void updatePhisWhenInsertingUniqueBackedgeBlock(
    llvm::BasicBlock* LoopHeader,
    llvm::BasicBlock* LoopPreheader,
    llvm::BasicBlock* BackedgeBlock)

Description

Update MemorySSA when inserting a unique backedge block for a loop.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:112

Parameters

llvm::BasicBlock* LoopHeader
llvm::BasicBlock* LoopPreheader
llvm::BasicBlock* BackedgeBlock

void wireOldPredecessorsToNewImmediatePredecessor(
    llvm::BasicBlock* Old,
    llvm::BasicBlock* New,
    ArrayRef<llvm::BasicBlock*> Preds,
    bool IdenticalEdgesWereMerged = true)

Description

A new empty BasicBlock (New) now branches directly to Old. Some of Old's predecessors (Preds) are now branching to New instead of Old. If New is the only predecessor, move Old's Phi, if present, to New. Otherwise, add a new Phi in New with appropriate incoming values, and update the incoming values in Old's Phi node too, if present.

Declared at: llvm/include/llvm/Analysis/MemorySSAUpdater.h:181

Parameters

llvm::BasicBlock* Old
llvm::BasicBlock* New
ArrayRef<llvm::BasicBlock*> Preds
bool IdenticalEdgesWereMerged = true