mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
[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). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217544 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -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;
|
||||
|
Reference in New Issue
Block a user