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

Whitney via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 14 09:28:52 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:
> 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().


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