//===- SSAUpdaterBulk.cpp - Unstructured SSA Update Tool ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // This file implements the SSAUpdaterBulk class. // //===----------------------------------------------------------------------===// #include "llvm/Transforms/Utils/SSAUpdaterBulk.h" #include "llvm/Analysis/IteratedDominanceFrontier.h" #include "llvm/IR/BasicBlock.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/Use.h" #include "llvm/IR/Value.h" usingnamespacellvm; #define DEBUG_TYPE … /// Helper function for finding a block which should have a value for the given /// user. For PHI-nodes this block is the corresponding predecessor, for other /// instructions it's their parent block. static BasicBlock *getUserBB(Use *U) { … } /// Add a new variable to the SSA rewriter. This needs to be called before /// AddAvailableValue or AddUse calls. unsigned SSAUpdaterBulk::AddVariable(StringRef Name, Type *Ty) { … } /// Indicate that a rewritten value is available in the specified block with the /// specified value. void SSAUpdaterBulk::AddAvailableValue(unsigned Var, BasicBlock *BB, Value *V) { … } /// Record a use of the symbolic value. This use will be updated with a /// rewritten value when RewriteAllUses is called. void SSAUpdaterBulk::AddUse(unsigned Var, Use *U) { … } // Compute value at the given block BB. We either should already know it, or we // should be able to recursively reach it going up dominator tree. Value *SSAUpdaterBulk::computeValueAt(BasicBlock *BB, RewriteInfo &R, DominatorTree *DT) { … } /// Given sets of UsingBlocks and DefBlocks, compute the set of LiveInBlocks. /// This is basically a subgraph limited by DefBlocks and UsingBlocks. static void ComputeLiveInBlocks(const SmallPtrSetImpl<BasicBlock *> &UsingBlocks, const SmallPtrSetImpl<BasicBlock *> &DefBlocks, SmallPtrSetImpl<BasicBlock *> &LiveInBlocks, PredIteratorCache &PredCache) { … } /// Perform all the necessary updates, including new PHI-nodes insertion and the /// requested uses update. void SSAUpdaterBulk::RewriteAllUses(DominatorTree *DT, SmallVectorImpl<PHINode *> *InsertedPHIs) { … }