This is an archive of the discontinued LLVM Phabricator instance.

[ARM CodeGen] @llvm.debugtrap call may be removed when restoring callee saved registers
ClosedPublic

Authored by iid_iunknown on Oct 12 2015, 1:35 PM.

Details

Summary

When ARMFrameLowering::emitPopInst generates a "pop" instruction to restore the callee saved registers, it checks if the LR register is among them. If so, the function may decide to remove the basic block's terminator and replace it with a "pop" to the PC register instead of LR.

This leads to a problem when the block's terminator is preceded by a "llvm.debugtrap" call. The MI iterator points to the trap in such a case, which is also a terminator. If the function decides to restore LR to PC, it erroneously removes the trap.

Diff Detail

Repository
rL LLVM

Event Timeline

iid_iunknown retitled this revision from to [ARM CodeGen] @llvm.debugtrap call may be removed when restoring callee saved registers.
iid_iunknown updated this object.
iid_iunknown added reviewers: asl, rengolin.
iid_iunknown set the repository for this revision to rL LLVM.
iid_iunknown added a subscriber: llvm-commits.
rengolin edited edge metadata.Oct 14 2015, 4:39 AM

Hi Oleg,

This sounds simple and correct. I just have one inline comment.

cheers,
--renato

test/CodeGen/ARM/debugtrap.ll
15

A clearer CHECK line sequence would be:

; CHECK: bl foo
; CHECK-NEXT: ... trap
; CHECK-NEXT: pop
iid_iunknown edited edge metadata.

The test updated according to the remarks from Renato to make the checks clearer.

iid_iunknown marked an inline comment as done.Oct 15 2015, 3:02 PM

I just have one inline comment.

Hi Renato,

Thank you for your attention to this.
I have changed the test according to your suggestion. Please note that the "pop" is inserted before the "trap" for this test case.

rengolin accepted this revision.Oct 16 2015, 6:30 AM
rengolin edited edge metadata.

LGTM. Thanks!

This revision is now accepted and ready to land.Oct 16 2015, 6:30 AM
iid_iunknown closed this revision.Oct 23 2015, 10:20 AM