This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][ShrinkWrap] Fix bug in prolog clobbering live reg when shrink wrapping.
ClosedPublic

Authored by gberry on Feb 17 2016, 2:22 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

gberry updated this revision to Diff 48242.Feb 17 2016, 2:22 PM
gberry retitled this revision from to [AArch64][ShrinkWrap] Fix bug in prolog clobbering live reg when shrink wrapping..
gberry updated this object.
gberry added reviewers: qcolombet, t.p.northover.
gberry added a subscriber: llvm-commits.
t.p.northover edited edge metadata.Feb 17 2016, 3:38 PM

Hi Geoff,

I'm not sure this is going to work. I think this sequence of events might break:

  1. During shrink-wrapping, canUseAsPrologue finds a callee-saved register and decides the block can be used.
  2. PrologueEpilogueInserter adds all callee-saved registers as live-ins to the candidate shrink-wrapped prologue and calls emitPrologue.
  3. emitPrologue asks for a callee-saved register again and is told there aren't any.

Tim.

qcolombet edited edge metadata.Feb 17 2016, 4:02 PM

Hi Geoff,

I believe Tim is right.
We want to restrict ourselves to the set of caller-saved registers to avoid that.

Cheers,
Q.

+Kit

Hi Kit,

I believe you have the same issue for the PPC backend as what Tim pointed out.

Could you double check?

Cheers,
-Quentin

FWIW, this patch is basically a cut and paste from the PPC code, with some simplification done since AArch64 doesn't need a scratch register in the epilog. I believe this same potential bug would be present for PPC currently as well.

gberry updated this revision to Diff 48358.Feb 18 2016, 10:46 AM
gberry edited edge metadata.

Update to address Tim's comments.

Hi Tim,

I've uploaded a new revision that I believe addresses your concerns by avoiding using callee-save registers for the stack pointer re-alignment scratch register.

qcolombet added inline comments.Feb 18 2016, 5:00 PM
test/CodeGen/AArch64/arm64-shrink-wrapping.ll
645 ↗(On Diff #48358)

I know this is painful (I’ve done quite a few time already ;)), but could you add the DISABLE check and regular CHECK to minimize the ENABLE/DISABLE differences.

672 ↗(On Diff #48358)

In this case, since both shrink-wrapped and non-shrink-wrapped tests are the same, you should use CHECK lines everywhere.

gberry updated this revision to Diff 48501.Feb 19 2016, 8:36 AM

Updated test to address Quentin's comments.

qcolombet accepted this revision.Feb 19 2016, 9:46 AM
qcolombet edited edge metadata.

Hi Geoff,

LGTM.

Thanks,
-Quentin

This revision is now accepted and ready to land.Feb 19 2016, 9:46 AM
This revision was automatically updated to reflect the committed changes.