[PATCH] D63338: PHINode: introduce setIncomingValueForBlock() function, and use it.

Whitney via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 09:55:50 PDT 2019


Whitney marked an inline comment as done.
Whitney added inline comments.


================
Comment at: llvm/include/llvm/IR/Instructions.h:2729
+  void setIncomingValueForBlock(const BasicBlock *BB, Value *V) {
+    assert(BB && "PHI node got a null basic block!");
+    for (unsigned Op = 0, NumOps = getNumOperands(); Op != NumOps; ++Op)
----------------
fhahn wrote:
> Whitney wrote:
> > fhahn wrote:
> > > can this just be 
> > > ```
> > >     int Idx = getBasicBlockIndex(BB);
> > >     assert(Idx >= 0 && "Invalid basic block argument!");
> > >     return setIncomingValue(Idx, V);
> > > ```
> > > 
> > > similar to getIncomingValueForBlock above?
> > I thought of doing that, but sometimes a phi node may have multiple operands of the same incoming block (not sure why). I am using a similar code pattern as in replaceIncomingBlockWith().
> Ah right. I think it is worth mentioning in the doc comment that it will replace all values coming from BB? 
> 
> For the places that use getbasicBlockIndex, this is not a NFC I think, as they would only replace the incoming value of the first occurrence.
Removed [NFC] from the title. And updated the comment.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D63338/new/

https://reviews.llvm.org/D63338





More information about the llvm-commits mailing list