From cadaf891646c9f833722f911af0fd76f77264472 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Thu, 24 Jul 2025 22:09:04 +0000 Subject: [PATCH 1/2] [GVN/MemDep] Limit the size of the cache for non-local dependencies. --- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 67c2cfadb6533..5c03df2518ceb 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -80,6 +80,10 @@ static cl::opt cl::desc("The number of blocks to scan during memory " "dependency analysis (default = 200)")); +static cl::opt CacheGlobalLimit( + "cache-global-limit", cl::Hidden, cl::init(10000), + cl::desc("The max number of entries allowed in a cache (default = 10000)")); + // Limit on the number of memdep results to process. static const unsigned int NumResultsLimit = 100; @@ -1142,6 +1146,11 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( return true; } + // If the size of this cache has surpassed the global limit, stop here. + if (Cache->size() > CacheGlobalLimit) { + return false; + } + // Otherwise, either this is a new block, a block with an invalid cache // pointer or one that we're about to invalidate by putting more info into // it than its valid cache info. If empty and not explicitly indicated as From 08680ccb4e855fa126a5fb7df636d23f983c8d60 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Tue, 23 Sep 2025 21:08:26 +0000 Subject: [PATCH 2/2] Comments. --- llvm/lib/Analysis/MemoryDependenceAnalysis.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp index 5c03df2518ceb..9a022d9ed09ce 100644 --- a/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp +++ b/llvm/lib/Analysis/MemoryDependenceAnalysis.cpp @@ -81,7 +81,7 @@ static cl::opt "dependency analysis (default = 200)")); static cl::opt CacheGlobalLimit( - "cache-global-limit", cl::Hidden, cl::init(10000), + "memdep-cache-global-limit", cl::Hidden, cl::init(10000), cl::desc("The max number of entries allowed in a cache (default = 10000)")); // Limit on the number of memdep results to process. @@ -1147,9 +1147,8 @@ bool MemoryDependenceResults::getNonLocalPointerDepFromBB( } // If the size of this cache has surpassed the global limit, stop here. - if (Cache->size() > CacheGlobalLimit) { + if (Cache->size() > CacheGlobalLimit) return false; - } // Otherwise, either this is a new block, a block with an invalid cache // pointer or one that we're about to invalidate by putting more info into