[VirtualInstruction] Avoid use of getStmtFor(BB). NFC.

With this patch, we get rid of the last use of getStmtFor(BB). Here
this is done by getting the last statement of the incoming block in
case the user is a phi node; otherwise just fetching the statement
comprising the instruction for which the virtual use is being created.

Differential Revision: https://reviews.llvm.org/D36268

llvm-svn: 309947
This commit is contained in:
Michael Kruse 2017-08-03 15:27:00 +00:00
parent 7cf745cc94
commit 672c011460
1 changed files with 6 additions and 1 deletions

View File

@ -21,7 +21,12 @@ using namespace llvm;
VirtualUse VirtualUse ::create(Scop *S, const Use &U, LoopInfo *LI,
bool Virtual) {
auto *UserBB = getUseBlock(U);
auto *UserStmt = S->getStmtFor(UserBB);
Instruction *UI = dyn_cast<Instruction>(U.getUser());
ScopStmt *UserStmt = nullptr;
if (PHINode *PHI = dyn_cast<PHINode>(UI))
UserStmt = S->getLastStmtFor(PHI->getIncomingBlock(U));
else
UserStmt = S->getStmtFor(UI);
auto *UserScope = LI->getLoopFor(UserBB);
return create(S, UserStmt, UserScope, U.get(), Virtual);
}