diff options
| author | Yong He <yonghe@outlook.com> | 2023-04-13 09:04:18 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-04-13 09:04:18 -0700 |
| commit | 352a460fc866998da5f45a8c117d891c51ab5a47 (patch) | |
| tree | 425f2b3ddfbdd45301d06ddd4c7681a5e2063141 /source | |
| parent | 59a603593f06ca2935a376b17a91ec42657f1ef8 (diff) | |
Fix stack overflow in lookupWitness lowering pass. (#2798)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/slang-ir-lower-witness-lookup.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/slang/slang-ir-lower-witness-lookup.cpp b/source/slang/slang-ir-lower-witness-lookup.cpp index 1a1900cd2..d3e96eb21 100644 --- a/source/slang/slang-ir-lower-witness-lookup.cpp +++ b/source/slang/slang-ir-lower-witness-lookup.cpp @@ -39,12 +39,24 @@ struct WitnessLookupLoweringContext { if (!type) return false; - if (type->getOp() == kIROp_AssociatedType) - return true; - for (UInt i = 0; i < type->getOperandCount(); i++) + + HashSet<IRInst*> processedSet; + List<IRInst*> workList; + workList.add(type); + processedSet.add(type); + for (Index i = 0; i < workList.getCount(); i++) { - if (hasAssocType(type->getOperand(i))) + auto inst = workList[i]; + if (inst->getOp() == kIROp_AssociatedType) return true; + + for (UInt j = 0; j < inst->getOperandCount(); j++) + { + if (!inst->getOperand(j)) + continue; + if (processedSet.Add(inst->getOperand(j))) + workList.add(inst->getOperand(j)); + } } return false; } |
