Track worst case alignment padding more accurately.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 27 Apr 2012 22:58:38 +0000 (22:58 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Fri, 27 Apr 2012 22:58:38 +0000 (22:58 +0000)
commit456ff46e668f361f79e8e91f145152089cd7d933
treefae7ca5096aa1013b9a8e2c1e9de77831baf76fb
parent0e47cfd5b647e8480274c6b29c4e2d01c41a9e82
Track worst case alignment padding more accurately.

Previously, ARMConstantIslandPass would conservatively compute the
address of an aligned basic block as:

  RoundUpToAlignment(Offset + UnknownPadding)

This worked fine for the layout algorithm itself, but it could fool the
verify() function because it accounts for alignment padding twice: Once
when adding the worst case UnknownPadding, and again by rounding up the
fictional block offset. This meant that when optimizeThumb2Instructions
would shrink an instruction, the conservative distance estimate could
grow. That shouldn't be possible since the woorst case alignment padding
wss already included.

This patch drops the use of RoundUpToAlignment, and depends only on
worst case padding to compute conservative block offsets. This has the
weird effect that the computed offset for an aligned block may not be
aligned.

The important difference is that shrinking an instruction can never
cause the estimated distance between two instructions to grow. The
estimated distance is always larger than the real distance that only the
assembler knows.

<rdar://problem/11339352>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155744 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/ARM/ARMConstantIslandPass.cpp