[all-commits] [llvm/llvm-project] cfebd7: [GISel][KnownBits] Fix a bug where we could run ou...
qcolombet via All-commits
all-commits at lists.llvm.org
Thu Jan 30 19:46:03 PST 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: cfebd7774229885e7ec88ae9ef1f4ae819cce1d2
https://github.com/llvm/llvm-project/commit/cfebd7774229885e7ec88ae9ef1f4ae819cce1d2
Author: Quentin Colombet <qcolombet at apple.com>
Date: 2020-01-30 (Thu, 30 Jan 2020)
Changed paths:
M llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
Log Message:
-----------
[GISel][KnownBits] Fix a bug where we could run out of stack space
One of the exit criteria of computeKnownBits is whether we reach the max
recursive call depth. Before this patch we would check that the
depth is exactly equal to max depth to exit.
Depth may get bigger than max depth if it gets passed to a different
GISelKnownBits object.
This may happen when say a generic part uses a GISelKnownBits object
with some max depth, but then we hit TL.computeKnownBitsForTargetInstr
which creates a new GISelKnownBits object with a different and smaller
depth. In that situation, when we hit the max depth check for the first
time in the target specific GISelKnownBits object, depth may already
be bigger than the current max depth. Hence we would continue to compute
the known bits, until we ran through the full depth of the chain of
computation or ran out of stack space.
For instance, let say we have
GISelKnownBits Info(/*MaxDepth*/ = 10);
Info.getKnownBits(Foo)
// 9 recursive calls to computeKnownBitsImpl.
// Then we hit a target specific instruction.
// The target specific GISelKnownBits does this:
GISelKnownBits TargetSpecificInfo(/*MaxDepth*/ = 6)
TargetSpecificInfo.computeKnownBitsImpl() // <-- next max depth checks would
// always return false.
This commit does not have any test case, none of the in-tree targets
use computeKnownBitsForTargetInstr.
More information about the All-commits
mailing list