[PATCH] D28934: Write a new SSAUpdater
Daniel Berlin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 26 18:19:39 PDT 2017
dberlin added a comment.
In https://reviews.llvm.org/D28934#791453, @davide wrote:
> Thanks for your comment, I'll see what I can do given this shows up in some of our internal workload.
> One thing, I agree we should change the API at some point (and maybe use a O(def + uses) renamer as we do in PredInfo) but, for starters, we should be able to have a drop-in replacement for `RewriteUse`, i.e. the new algorithm will always pick the correct value?
>
> void SSAUpdater::RewriteUse(Use &U) {
> Instruction *User = cast<Instruction>(U.getUser());
>
> Value *V;
> if (PHINode *UserPN = dyn_cast<PHINode>(User))
> V = GetValueAtEndOfBlock(UserPN->getIncomingBlock(U));
> else
> V = GetValueInMiddleOfBlock(User->getParent());
> [...]
>
I believe this should be:
void SSAUpdater::RewriteUse(unsigned Var, Use &U) {
Instruction *User = cast<Instruction>(U.getUser());
BasicBlock *VarBB = User->getParent();
if (auto *PN = dyn_cast<PHINode>(User))
VarBB = PN->getIncomingBlock(U);
return readVariableAfterDef(Var, VarBB);
}
(Note all these API's, both old and new, assume you are rewriting in program order. It's possible to make it not require that, by storing all the defs in a given block and using ordered instructions to see where the use occurs relative to them)
https://reviews.llvm.org/D28934
More information about the llvm-commits
mailing list