This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Handle t2ADDri in ARMAsmPrinter::EmitUnwindingInstruction
Needs ReviewPublic

Authored by ahatanak on Nov 9 2015, 3:31 PM.

Details

Reviewers
t.p.northover
Summary

This fixes a bug in ARMAsmPrinter::EmitUnwindingInstruction where llvm_unreachable was reached because t2ADDri wasn't handled.

It looks like this crash could also have been avoided if the function checked MAI->getExceptionHandlingType() (and returned early), but it looks like the case clause for t2ADDri should be added regardless of that.

Diff Detail

Event Timeline

ahatanak updated this revision to Diff 39760.Nov 9 2015, 3:31 PM
ahatanak retitled this revision from to [ARM] Handle t2ADDri in ARMAsmPrinter::EmitUnwindingInstruction.
ahatanak updated this object.
ahatanak added a reviewer: t.p.northover.
ahatanak added a subscriber: llvm-commits.
dirty added a subscriber: dirty.Nov 9 2015, 3:35 PM
t.p.northover edited edge metadata.Nov 9 2015, 3:52 PM

Hi Akira,

The code change looks fine, but the test is quite a bit more complicated than it needs to be. The key points triggering this error are:

  • A frame pointer is required and is r11 (so that t2ADD is used)
  • sp != fp

I believe this is a reasonably minimal example (using the normal call to ensure the FP isn't eliminated and the asm to make sure at least one callee-saved register is used):

define void @foo1() {
  call void asm sideeffect "", "~{r4}"()
  call void @foo2()
  ret void
}
declare void @foo2()

Thanks Tim. Your minimal test case is indeed sufficient to trigger the crash. I'll update the test case and commit the patch shortly.