[PATCH] D23271: Move AArch64BranchRelaxation to generic code

Hal Finkel via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 18:16:36 PDT 2016


hfinkel added a comment.

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



> BranchRelaxation.cpp:53
> +    unsigned postOffset(unsigned LogAlign = 0) const {
> +      unsigned PO = Offset + Size;
> +      unsigned Align = 1 << LogAlign;

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

> BranchRelaxation.cpp:171
> +    unsigned LogAlign = MBB.getAlignment();
> +    BlockInfo[Num].Offset = BlockInfo[PrevNum].postOffset(LogAlign);
> +    PrevNum = Num;

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.

https://reviews.llvm.org/D23271





More information about the llvm-commits mailing list