diff options
| author | Brendon Cahoon <bcahoon@codeaurora.org> | 2016-04-04 18:13:18 +0000 |
|---|---|---|
| committer | Brendon Cahoon <bcahoon@codeaurora.org> | 2016-04-04 18:13:18 +0000 |
| commit | 86f783e31532767b05467e7c902ae4a029d2c68a (patch) | |
| tree | be59dd63f2ce0c79d24d25e1113878241bf4da4a /llvm/lib/Analysis | |
| parent | 73900c6876ab794348e828312622bbdf536df8b4 (diff) | |
| download | bcm5719-llvm-86f783e31532767b05467e7c902ae4a029d2c68a.tar.gz bcm5719-llvm-86f783e31532767b05467e7c902ae4a029d2c68a.zip | |
[DependenceAnalysis] Check if result of getConstantPart is null
A seg-fault occurs due to a reference of a null pointer, which is
the value returned by getConstantPart. This function returns
null if the constant part is not found. The code that calls this
function needs to check for the null return value.
Differential Revision: http://reviews.llvm.org/D18718
llvm-svn: 265319
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/DependenceAnalysis.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/DependenceAnalysis.cpp b/llvm/lib/Analysis/DependenceAnalysis.cpp index 4040ad3cacd..93828904760 100644 --- a/llvm/lib/Analysis/DependenceAnalysis.cpp +++ b/llvm/lib/Analysis/DependenceAnalysis.cpp @@ -2409,6 +2409,8 @@ bool DependenceAnalysis::gcdMIVtest(const SCEV *Src, Constant = getConstantPart(Product); else Constant = cast<SCEVConstant>(Coeff); + if (!Constant) + return false; APInt ConstCoeff = Constant->getAPInt(); RunningGCD = APIntOps::GreatestCommonDivisor(RunningGCD, ConstCoeff.abs()); } @@ -2427,6 +2429,8 @@ bool DependenceAnalysis::gcdMIVtest(const SCEV *Src, Constant = getConstantPart(Product); else Constant = cast<SCEVConstant>(Coeff); + if (!Constant) + return false; APInt ConstCoeff = Constant->getAPInt(); RunningGCD = APIntOps::GreatestCommonDivisor(RunningGCD, ConstCoeff.abs()); } @@ -2444,6 +2448,8 @@ bool DependenceAnalysis::gcdMIVtest(const SCEV *Src, // or constant, in which case we give up on this direction. continue; } + if (!Constant) + continue; APInt ConstCoeff = Constant->getAPInt(); RunningGCD = APIntOps::GreatestCommonDivisor(RunningGCD, ConstCoeff.abs()); DEBUG(dbgs() << "\tRunningGCD = " << RunningGCD << "\n"); |

