@@ -45,7 +45,64 @@ template <typename T> class ArrayRef;
4545
4646constexpr unsigned MaxAnalysisRecursionDepth = 6 ;
4747
48- unsigned getAnalysisRecursionDepthLimit ();
48+ class DepthLimit {
49+ public:
50+ static DepthLimit &get () {
51+ static DepthLimit Instance;
52+ return Instance;
53+ }
54+
55+ enum class VTCycle {
56+ KNOWNBIT = 0 ,
57+ KNOWNBITCOND = 1 ,
58+ NONZERO = 2 ,
59+ NONEQUAL = 3 ,
60+ IMPLIED = 4 ,
61+ FPCLASS = 5 ,
62+ RANGE = 6 ,
63+ SIGNBITS = 7 ,
64+ NOTUNDEFPOISON = 8 ,
65+ NONE = 9
66+ };
67+
68+ static unsigned getMaxRecursionDepth (VTCycle Cycle, const Value *I,
69+ unsigned Depth) {
70+ if (!get ().RecursionDepthOverride || Cycle == VTCycle::NONE)
71+ return get ().getMaxRecursionDepthImpl ();
72+
73+ if (get ().Encountered [Cycle].insert (I).second )
74+ return get ().getMaxRecursionDepthImpl ();
75+
76+ return Depth;
77+ }
78+ static unsigned getMaxRecursionDepth () {
79+ return get ().getMaxRecursionDepthImpl ();
80+ }
81+ static void setOverrideDepthLimit () { get ().setOverrideDepthLimitImpl (); }
82+ static void resetOverrideDepthLimit () { get ().resetOverrideDepthLimitImpl (); }
83+
84+ DepthLimit (const DepthLimit &) = delete ;
85+ DepthLimit &operator =(const DepthLimit &) = delete ;
86+
87+ private:
88+ DepthLimit () {}
89+
90+ const unsigned MaxAnalysisRecurionsDpeth = 6 ;
91+ bool RecursionDepthOverride = false ;
92+
93+ DenseMap<VTCycle, SmallPtrSet<const Value *, 8 >> Encountered;
94+
95+ unsigned getMaxRecursionDepthImpl () {
96+ return RecursionDepthOverride ? -1 : MaxAnalysisRecurionsDpeth;
97+ }
98+
99+ void setOverrideDepthLimitImpl () { RecursionDepthOverride = true ; }
100+
101+ void resetOverrideDepthLimitImpl () {
102+ RecursionDepthOverride = false ;
103+ Encountered.clear ();
104+ }
105+ };
49106
50107// / Determine which bits of V are known to be either zero or one and return
51108// / them in the KnownZero/KnownOne bit sets.
@@ -88,6 +145,13 @@ LLVM_ABI KnownBits computeKnownBits(const Value *V, const SimplifyQuery &Q,
88145LLVM_ABI void computeKnownBits (const Value *V, KnownBits &Known,
89146 const SimplifyQuery &Q, unsigned Depth = 0 );
90147
148+ void computeKnownBitsExhaustive (const Value *V, KnownBits &Known,
149+ const DataLayout &DL,
150+ AssumptionCache *AC = nullptr ,
151+ const Instruction *CxtI = nullptr ,
152+ const DominatorTree *DT = nullptr ,
153+ bool UseInstrInfo = true );
154+
91155// / Compute known bits from the range metadata.
92156// / \p KnownZero the set of bits that are known to be zero
93157// / \p KnownOne the set of bits that are known to be one
0 commit comments