diff options
author | Whitney Tsang <whitney.uwaterloo@gmail.com> | 2019-06-17 14:38:56 +0000 |
---|---|---|
committer | Whitney Tsang <whitney.uwaterloo@gmail.com> | 2019-06-17 14:38:56 +0000 |
commit | 15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6 (patch) | |
tree | fdc3c71b9334ee77ede0ec010ac2269a03d24651 /llvm/lib/Transforms/Utils | |
parent | 1c91e63897d8832a7b634d9662b8dbcc3ba36efd (diff) | |
download | bcm5719-llvm-15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6.tar.gz bcm5719-llvm-15b7f5b72d2ae3dae37a42caa8d3259cfafc70c6.zip |
PHINode: introduce setIncomingValueForBlock() function, and use it.
Summary:
There is PHINode::getBasicBlockIndex() and PHINode::setIncomingValue()
but no function to replace incoming value for a specified BasicBlock*
predecessor.
Clearly, there are a lot of places that could use that functionality.
Reviewer: craig.topper, lebedev.ri, Meinersbur, kbarton, fhahn
Reviewed By: Meinersbur, fhahn
Subscribers: fhahn, hiraditya, zzheng, jsji, llvm-commits
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D63338
llvm-svn: 363566
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp | 9 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 3 |
3 files changed, 6 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp index 5ca09046199..6c922c2a698 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollPeel.cpp @@ -644,7 +644,7 @@ bool llvm::peelLoop(Loop *L, unsigned PeelCount, LoopInfo *LI, if (LatchInst && L->contains(LatchInst)) NewVal = LVMap[LatchInst]; - PHI->setIncomingValue(PHI->getBasicBlockIndex(NewPreHeader), NewVal); + PHI->setIncomingValueForBlock(NewPreHeader, NewVal); } // Adjust the branch weights on the loop exit. diff --git a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp index 03f31327365..b39d78dde00 100644 --- a/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp +++ b/llvm/lib/Transforms/Utils/LoopUnrollRuntime.cpp @@ -124,11 +124,10 @@ static void ConnectProlog(Loop *L, Value *BECount, unsigned Count, // Update the existing PHI node operand with the value from the // new PHI node. How this is done depends on if the existing // PHI node is in the original loop block, or the exit block. - if (L->contains(&PN)) { - PN.setIncomingValue(PN.getBasicBlockIndex(NewPreHeader), NewPN); - } else { + if (L->contains(&PN)) + PN.setIncomingValueForBlock(NewPreHeader, NewPN); + else PN.addIncoming(NewPN, PrologExit); - } } } @@ -264,7 +263,7 @@ static void ConnectEpilog(Loop *L, Value *ModVal, BasicBlock *NewExit, // Update the existing PHI node operand with the value from the new PHI // node. Corresponding instruction in epilog loop should be PHI. PHINode *VPN = cast<PHINode>(VMap[&PN]); - VPN->setIncomingValue(VPN->getBasicBlockIndex(EpilogPreHeader), NewPN); + VPN->setIncomingValueForBlock(EpilogPreHeader, NewPN); } } diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index f571aa6bf2e..91c645bcf92 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -2826,8 +2826,7 @@ bool llvm::FoldBranchToCommonDest(BranchInst *BI, MemorySSAUpdater *MSSAU, } } // Update PHI Node. - PHIs[i]->setIncomingValue(PHIs[i]->getBasicBlockIndex(PBI->getParent()), - MergedCond); + PHIs[i]->setIncomingValueForBlock(PBI->getParent(), MergedCond); } // PBI is changed to branch to TrueDest below. Remove itself from |