diff options
author | Chris Lattner <sabre@nondot.org> | 2009-03-06 05:34:10 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-03-06 05:34:10 +0000 |
commit | cc14d25dd99e891c586bd56aa41796abbe4ac3d8 (patch) | |
tree | fcc5b45f79eaf1d6db4860bcf6e0771d3022c24b /lib/Transforms/Scalar/JumpThreading.cpp | |
parent | 3f43a7021fae71c056f5e1afc60016cfd8193f68 (diff) |
Change various llvm utilities to use PrettyStackTraceProgram in
their main routines. This makes the tools print their argc/argv
commands if they crash.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66248 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/JumpThreading.cpp')
-rw-r--r-- | lib/Transforms/Scalar/JumpThreading.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/JumpThreading.cpp b/lib/Transforms/Scalar/JumpThreading.cpp index f96fc208ae..1f3e6b11c8 100644 --- a/lib/Transforms/Scalar/JumpThreading.cpp +++ b/lib/Transforms/Scalar/JumpThreading.cpp @@ -407,6 +407,12 @@ bool JumpThreading::ProcessBranchOnDuplicateCond(BasicBlock *PredBB, return true; } +struct APIntUnsignedOrdering { + bool operator()(const APInt &LHS, const APInt &RHS) const { + return LHS.ult(RHS); + } +}; + /// ProcessSwitchOnDuplicateCond - We found a block and a predecessor of that /// block that switch on exactly the same condition. This means that we almost /// always know the direction of the edge in the DESTBB: @@ -474,6 +480,34 @@ bool JumpThreading::ProcessSwitchOnDuplicateCond(BasicBlock *PredBB, return true; } +#if 0 + // Figure out on which of the condition allow us to get to DESTBB. If DESTBB + // is the default label, we compute the set of values COND is known not to be + // otherwise we compute the set of options that COND could be. + SmallVector<APInt, 16> KnownValues; + bool DestBBIsDefault = PredSI->getSuccessor(0) == DestBB; + + if (DestBBIsDefault) { + // DestBB the default case. Collect the values where PredBB can't branch to + // DestBB. + for (unsigned i = 1/*skip default*/, e = PredSI->getNumCases(); i != e; ++i) + if (PredSI->getSuccessor(i) != DestBB) + KnownValues.push_back(PredSI->getCaseValue(i)->getValue()); + } else { + // Not the default case. Collect the values where PredBB can branch to + // DestBB. + for (unsigned i = 1/*skip default*/, e = PredSI->getNumCases(); i != e; ++i) + if (PredSI->getSuccessor(i) == DestBB) + KnownValues.push_back(PredSI->getCaseValue(i)->getValue()); + } + + std::sort(KnownValues.begin(), KnownValues.end(), APIntUnsignedOrdering()); + return false; + cerr << "\nFOUND THREAD BLOCKS:\n"; + PredBB->dump(); + DestBB->dump(); +#endif + return false; } |