[llvm] [verify][swift] Allow passing swifterror to phi instructions (PR #138598)
Matthias Braun via llvm-commits
llvm-commits at lists.llvm.org
Mon May 5 16:49:34 PDT 2025
================
@@ -3653,20 +3653,22 @@ void Verifier::visitCallBase(CallBase &Call) {
// well.
for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) {
if (Call.paramHasAttr(i, Attribute::SwiftError)) {
- SetVector<const Value *> Args;
- Args.insert(Call.getArgOperand(i));
- bool DidChange;
- do {
- DidChange = false;
- // Inherit the incoming values of phi instructions to capture all
- // values.
- for (const Value *Arg : Args)
- if (auto *PhiI = dyn_cast<PHINode>(Arg))
- for (const auto &Op : PhiI->incoming_values())
- DidChange |= Args.insert(Op.get());
- } while (DidChange);
-
- for (const Value *SwiftErrorArg : Args) {
+ const Value *Arg = Call.getArgOperand(i);
+ SetVector<const Value *> Values;
+ Values.insert(Arg);
+ SmallVector<const PHINode *> PHIWorkList;
+ if (auto *PhiI = dyn_cast<PHINode>(Arg))
+ PHIWorkList.push_back(PhiI);
+
+ while (!PHIWorkList.empty()) {
+ const auto *PhiI = PHIWorkList.pop_back_val();
+ for (const auto &Op : PhiI->incoming_values()) {
+ const auto *NextPhiI = dyn_cast<PHINode>(Op.get());
+ if (Values.insert(Op.get()) && NextPhiI)
+ PHIWorkList.push_back(NextPhiI);
+ }
----------------
MatzeB wrote:
Does this work using implicit conversion from `Use` to `Value`?
```suggestion
const auto *PhiI = PHIWorkList.pop_back_val();
for (Value *Op : PhiI->incoming_values()) {
const auto *NextPhiI = dyn_cast<PHINode>(Op);
if (Values.insert(Op) && NextPhiI)
PHIWorkList.push_back(NextPhiI);
}
```
https://github.com/llvm/llvm-project/pull/138598
More information about the llvm-commits
mailing list