This is an archive of the discontinued LLVM Phabricator instance.

Move AArch64BranchRelaxation to generic code
ClosedPublic

Authored by arsenm on Aug 8 2016, 9:32 AM.

Details

Reviewers
hfinkel

Diff Detail

Event Timeline

arsenm updated this revision to Diff 67186.Aug 8 2016, 9:32 AM
arsenm retitled this revision from to Move AArch64BranchRelaxation to generic code.
arsenm updated this object.
arsenm added a subscriber: llvm-commits.
arsenm updated this revision to Diff 71679.Sep 16 2016, 11:21 AM

Update for trunk

Thanks for doing this; I want to try using it for PPC too...

lib/CodeGen/BranchRelaxation.cpp
53

Can you use OffsetToAlignment (from MathExtras.h) here?

171

I'm not sure this is correct, the PowerPC branch relaxation pass has this:

unsigned Align = MBB.getAlignment();
if (!Align)
  return 0;

unsigned AlignAmt = 1 << Align;
unsigned ParentAlign = MBB.getParent()->getAlignment();

if (Align <= ParentAlign)
  return OffsetToAlignment(Offset, AlignAmt);

// The alignment of this MBB is larger than the function's alignment, so we
// can't tell whether or not it will insert nops. Assume that it will.
return AlignAmt + OffsetToAlignment(Offset, AlignAmt);

It is this last part of the check, where if the alignment is greater than the parent-function's alignment, we conservatively assume we get the full adjustment, that I don't see reflected here.

arsenm added inline comments.
lib/CodeGen/BranchRelaxation.cpp
171

I fixed this in D25174

hfinkel accepted this revision.Oct 3 2016, 5:23 AM
hfinkel added a reviewer: hfinkel.
hfinkel added inline comments.
lib/CodeGen/BranchRelaxation.cpp
171

With that, this LGTM.

This revision is now accepted and ready to land.Oct 3 2016, 5:23 AM
Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in rL283459. Please specify "Differential revision: <URL>" as last line of commit message.

lib/Target/AArch64/AArch64.h