[llvm] Implement missing PHINode functions (PR #101734)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 2 11:56:58 PDT 2024
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 3af26be42e39405d9b3e1023853218dea20b5d1f 8ea3fbf24bd71583649cc98e8e088640a3fde8ff --extensions cpp,h -- llvm/include/llvm/SandboxIR/SandboxIR.h llvm/lib/SandboxIR/SandboxIR.cpp llvm/unittests/SandboxIR/SandboxIRTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/SandboxIR/SandboxIR.h b/llvm/include/llvm/SandboxIR/SandboxIR.h
index d47bb4e87c..e6d2026706 100644
--- a/llvm/include/llvm/SandboxIR/SandboxIR.h
+++ b/llvm/include/llvm/SandboxIR/SandboxIR.h
@@ -1585,10 +1585,10 @@ public:
return cast<llvm::PHINode>(Val)->hasConstantOrUndefValue();
}
bool isComplete() const { return cast<llvm::PHINode>(Val)->isComplete(); }
- void replaceIncomingBlockWith (const BasicBlock *Old, BasicBlock *New);
- void removeIncomingValueIf(function_ref< bool(unsigned)> Predicate,
- bool DeletePHIIfEmpty=true);
- // TODO: Implement
+ void replaceIncomingBlockWith(const BasicBlock *Old, BasicBlock *New);
+ void removeIncomingValueIf(function_ref<bool(unsigned)> Predicate,
+ bool DeletePHIIfEmpty = true);
+ // TODO: Implement
// void copyIncomingBlocks(iterator_range<const_block_iterator> BBRange,
// uint32_t ToIdx = 0)
#ifndef NDEBUG
diff --git a/llvm/lib/SandboxIR/SandboxIR.cpp b/llvm/lib/SandboxIR/SandboxIR.cpp
index f34eeee239..44932c2f66 100644
--- a/llvm/lib/SandboxIR/SandboxIR.cpp
+++ b/llvm/lib/SandboxIR/SandboxIR.cpp
@@ -1150,14 +1150,14 @@ 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) {
+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)
+ 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,
+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
diff --git a/llvm/unittests/SandboxIR/SandboxIRTest.cpp b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
index 5d22f3b003..6ae1723270 100644
--- a/llvm/unittests/SandboxIR/SandboxIRTest.cpp
+++ b/llvm/unittests/SandboxIR/SandboxIRTest.cpp
@@ -1982,9 +1982,8 @@ bb3:
EXPECT_EQ(PHI->getIncomingBlock(0), BB2);
// Check replaceIncomingValueIf
EXPECT_EQ(PHI->getNumIncomingValues(), 2u);
- PHI->removeIncomingValueIf([&](unsigned Idx) {
- return PHI->getIncomingBlock(Idx) == BB2;
- });
+ PHI->removeIncomingValueIf(
+ [&](unsigned Idx) { return PHI->getIncomingBlock(Idx) == BB2; });
EXPECT_EQ(PHI->getNumIncomingValues(), 1u);
// Check create().
auto *NewPHI = cast<sandboxir::PHINode>(
``````````
</details>
https://github.com/llvm/llvm-project/pull/101734
More information about the llvm-commits
mailing list