[llvm] [ObjectSizeOffsetVisitor] Add a max recursion depth (PR #67479)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 26 13:10:32 PDT 2023
================
@@ -994,14 +1001,20 @@ SizeOffsetType ObjectSizeOffsetVisitor::combineSizeOffset(SizeOffsetType LHS,
}
SizeOffsetType ObjectSizeOffsetVisitor::visitPHINode(PHINode &PN) {
- if (PN.getNumIncomingValues() == 0)
+ if (PN.getNumIncomingValues() == 0 ||
+ RecurseDepth >= ObjectSizeOffsetVisitorMaxRecurseDepth)
return unknown();
+
+ ++RecurseDepth;
auto IncomingValues = PN.incoming_values();
- return std::accumulate(IncomingValues.begin() + 1, IncomingValues.end(),
- compute(*IncomingValues.begin()),
- [this](SizeOffsetType LHS, Value *VRHS) {
- return combineSizeOffset(LHS, compute(VRHS));
- });
+ SizeOffsetType Ret =
+ std::accumulate(IncomingValues.begin() + 1, IncomingValues.end(),
+ compute(*IncomingValues.begin()),
+ [this](SizeOffsetType LHS, Value *VRHS) {
+ return combineSizeOffset(LHS, compute(VRHS));
+ });
+ --RecurseDepth;
+ return Ret;
----------------
nikic wrote:
Do the same for selects?
https://github.com/llvm/llvm-project/pull/67479
More information about the llvm-commits
mailing list