Skip to content

Commit 48cf620

Browse files
committed
[ARM][ConstantIslands] Correct MinNoSplitDisp calculation
MinNoSplitDisp was first introduced in D16890 to handle cases where the ConstantIslands pass fails to converge in the presence of big basic blocks. However, the computation of the variable seems to be wrong as it currently computes the offset immediately following UserBB. In other words, it represents the distance from the beginning of the function to the end of UserBB. The distance from the beginning of the function does not seem to be a good indicator of how big the basic block is unless the basic block is close to the beginning of the function. I think MinNoSplitDisp should compute the distance between UserOffset and the end of UserBB instead.
1 parent 339c788 commit 48cf620

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

llvm/lib/Target/ARM/ARMConstantIslandPass.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1324,7 +1324,8 @@ bool ARMConstantIslands::findAvailableWater(CPUser &U, unsigned UserOffset,
13241324
MachineBasicBlock *UserBB = U.MI->getParent();
13251325
BBInfoVector &BBInfo = BBUtils->getBBInfo();
13261326
const Align CPEAlign = getCPEAlign(U.CPEMI);
1327-
unsigned MinNoSplitDisp = BBInfo[UserBB->getNumber()].postOffset(CPEAlign);
1327+
unsigned MinNoSplitDisp =
1328+
BBInfo[UserBB->getNumber()].postOffset(CPEAlign) - UserOffset;
13281329
if (CloserWater && MinNoSplitDisp > U.getMaxDisp() / 2)
13291330
return false;
13301331
for (water_iterator IP = std::prev(WaterList.end()), B = WaterList.begin();;

0 commit comments

Comments
 (0)