summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2014-09-10 21:05:52 +0000
committerHal Finkel <hfinkel@anl.gov>2014-09-10 21:05:52 +0000
commit71b70841126a975d8876ba72cfba7ed803e9b689 (patch)
tree91e67700278f764d418cea19e1bf4dbd7b4487e8 /llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
parentd13951ff2feefe5bda0065ffb799874e86bc36e1 (diff)
downloadbcm5719-llvm-71b70841126a975d8876ba72cfba7ed803e9b689.tar.gz
bcm5719-llvm-71b70841126a975d8876ba72cfba7ed803e9b689.zip
[AlignmentFromAssumptions] Don't divide by zero for unknown starting alignment
The routine that determines an alignment given some SCEV returns zero if the answer is unknown. In a case where we could determine the increment of an AddRec but not the starting alignment, we would compute the integer modulus by zero (which is illegal and traps). Prevent this by returning early if either the start or increment alignment is unknown (zero). llvm-svn: 217544
Diffstat (limited to 'llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
index a662accf69f..7ab16f13811 100644
--- a/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
+++ b/llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
@@ -179,7 +179,9 @@ static unsigned getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV,
DEBUG(dbgs() << "\tnew start alignment: " << NewAlignment << "\n");
DEBUG(dbgs() << "\tnew inc alignment: " << NewIncAlignment << "\n");
- if (NewAlignment > NewIncAlignment) {
+ if (!NewAlignment || !NewIncAlignment) {
+ return 0;
+ } else if (NewAlignment > NewIncAlignment) {
if (NewAlignment % NewIncAlignment == 0) {
DEBUG(dbgs() << "\tnew start/inc alignment: " <<
NewIncAlignment << "\n");
@@ -191,7 +193,7 @@ static unsigned getNewAlignment(const SCEV *AASCEV, const SCEV *AlignSCEV,
NewAlignment << "\n");
return NewAlignment;
}
- } else if (NewIncAlignment == NewAlignment && NewIncAlignment) {
+ } else if (NewIncAlignment == NewAlignment) {
DEBUG(dbgs() << "\tnew start/inc alignment: " <<
NewAlignment << "\n");
return NewAlignment;
OpenPOWER on IntegriCloud