[llvm] [DFAJumpThreading] Prevent pass from using too much memory. (PR #145482)

Usman Nadeem via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 1 12:28:54 PDT 2025


================
@@ -679,6 +683,10 @@ struct AllSwitchPaths {
           ThreadingPath NewPath(Path);
           NewPath.appendExcludingFirst(IPath);
----------------
UsmanNadeem wrote:

IntermediatePaths are appended to the list of PredPaths (here, and also in the run() function), so the total number of paths is the multiplication of the sizes of the two lists. IntermediatePaths are already calculated so we are wasting compute cycles here by doing wasteful computation and by breaking the loop later than we should.

Since `getPathsFromStateDefMap()` and `paths()` are called multiple times and from different places they don't see the global picture of the number of paths we already have.

My suggestion is to add an argument to these two functions and update every call to these functions with a more appropriate limit instead of `MaxNumPaths`.

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


More information about the llvm-commits mailing list