[llvm] [ObjectSizeOffsetVisitor] Bail after visiting 100 instructions (PR #67479)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 27 00:36:41 PDT 2023


================
@@ -729,13 +742,16 @@ SizeOffsetType ObjectSizeOffsetVisitor::compute(Value *V) {
           SOT.second.getBitWidth() > 1 ? SOT.second + Offset : SOT.second};
 }
 
-SizeOffsetType ObjectSizeOffsetVisitor::computeImpl(Value *V) {
+SizeOffsetType ObjectSizeOffsetVisitor::computeValue(Value *V) {
   if (Instruction *I = dyn_cast<Instruction>(V)) {
     // If we have already seen this instruction, bail out. Cycles can happen in
     // unreachable code after constant propagation.
     auto P = SeenInsts.try_emplace(I, unknown());
     if (!P.second)
       return P.first->second;
+    ++InstructionsVisited;
+    if (InstructionsVisited > ObjectSizeOffsetVisitorMaxVisitInstructions)
----------------
nikic wrote:

Good point. I was not aware that ObjectSizeOffsetVisitor is designed for reuse, but apparently AddressSanitizer does use it that way.

Possibly we should be clearing SeenInsts for each call as well...

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


More information about the llvm-commits mailing list