Add a 2 byte safety margin in offset computations.

ARMConstantIslandPass still has bugs where jump table compression can
cause constant pool entries to go out of range.

Add a safety margin of 2 bytes when placing constant islands, but use
the real max displacement for verification.

<rdar://problem/11156595>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@153789 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Jakob Stoklund Olesen 2012-03-31 00:06:44 +00:00
parent 101c03a8c9
commit 3ee3661f8f

View File

@ -209,8 +209,9 @@ namespace {
}
/// getMaxDisp - Returns the maximum displacement supported by MI.
/// Correct for unknown alignment.
/// Conservatively subtract 2 bytes to handle weird alignment effects.
unsigned getMaxDisp() const {
return KnownAlignment ? MaxDisp : MaxDisp - 2;
return (KnownAlignment ? MaxDisp : MaxDisp - 2) - 2;
}
};
@ -350,7 +351,9 @@ void ARMConstantIslands::verify() {
for (unsigned i = 0, e = CPUsers.size(); i != e; ++i) {
CPUser &U = CPUsers[i];
unsigned UserOffset = getUserOffset(U);
if (isCPEntryInRange(U.MI, UserOffset, U.CPEMI, U.getMaxDisp(), U.NegOk,
// Verify offset using the real max displacement without the safety
// adjustment.
if (isCPEntryInRange(U.MI, UserOffset, U.CPEMI, U.getMaxDisp()+2, U.NegOk,
/* DoDump = */ true)) {
DEBUG(dbgs() << "OK\n");
continue;