[llvm] [SandboxIR] Implement missing PHINode functions (PR #101734)

Thorsten Schütt via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 2 12:49:03 PDT 2024


================
@@ -1150,6 +1150,22 @@ Value *PHINode::hasConstantValue() const {
   llvm::Value *LLVMV = cast<llvm::PHINode>(Val)->hasConstantValue();
   return LLVMV != nullptr ? Ctx.getValue(LLVMV) : nullptr;
 }
+void PHINode::replaceIncomingBlockWith (const BasicBlock *Old, BasicBlock *New) {
+  assert(New && Old && "Sandbox IR PHI node got a null basic block!");
+  for (unsigned Op = 0,
+            NumOps = cast<llvm::PHINode>(Val)->getNumOperands(); Op != NumOps; ++Op)
+    if (getIncomingBlock(Op) == Old)
+      setIncomingBlock(Op, New);
+}
+void PHINode::removeIncomingValueIf(function_ref< bool(unsigned)> Predicate,
+                                    bool DeletePHIIfEmpty) {
+  // Avoid duplicate tracking by going through this->removeIncomingValue here at
+  // the expense of some performance. Copy PHI::removeIncomingValueIf more
+  // directly if performance becomes an issue.
+  for (unsigned Idx = 0; Idx < getNumIncomingValues(); ++Idx)
----------------
tschuett wrote:

Fine.

https://github.com/llvm/llvm-project/pull/101734


More information about the llvm-commits mailing list