This is an archive of the discontinued LLVM Phabricator instance.

[DependenceAnalysis] Check if result of getConstantPart is null
ClosedPublic

Authored by bcahoon on Apr 1 2016, 4:32 PM.

Details

Summary

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.

Diff Detail

Event Timeline

bcahoon updated this revision to Diff 52443.Apr 1 2016, 4:32 PM
bcahoon retitled this revision from to [DependenceAnalysis] Check if result of getConstantPart is null.
bcahoon updated this object.
bcahoon added a reviewer: sanjoy.
bcahoon added a subscriber: llvm-commits.
sanjoy accepted this revision.Apr 1 2016, 5:04 PM
sanjoy edited edge metadata.

Hi Brendan,

I'm not familiar with this code, but this change looks innocent enough that I LGTM'ed it.

However, I have a design nit: it looks like getConstantPart should be defined to take a const SCEV * and if it is a SCEVConstant, return that, else if it is SCEVMulExpr do what it does today and otherwise return nullptr -- it looks like that will fit in better with how getConstantPart is used. Moreover, a SCEVConstantExpr is really a degenerate SCEVMulExpr :) Do you mind doing that refactoring in a later change?

This revision is now accepted and ready to land.Apr 1 2016, 5:04 PM

Thanks for the review, Sanjoy. I'll refactor the getConstantPart function in a subsequent change as suggested.

This revision was automatically updated to reflect the committed changes.