This is an archive of the discontinued LLVM Phabricator instance.

ARM: Use BKPT instead of TRAP to implement llvm.debugtrap.
ClosedPublic

Authored by pcc on Oct 23 2018, 2:54 PM.

Details

Summary

The BKPT instruction is specified to cause a software breakpoint,
and at least on Linux results in a SIGTRAP. This makes it more
suitable for implementing debugtrap than TRAP (aka UDF #254), which
is specified to cause an undefined instruction exception and results
in a SIGILL on Linux.

Moreover, BKPT is not marked as a terminator, which is not only
consistent with the IR instruction but allows the analyzeBlock
function to correctly analyze a basic block containing the instruction,
which fixes an assertion failure in the machine block placement pass
previously triggered by the included test case.

Because BKPT is only supported starting with ARMv5T, we continue to
use UDF #254 when targeting v4T.

Diff Detail

Event Timeline

pcc created this revision.Oct 23 2018, 2:54 PM
compnerd accepted this revision.Oct 24 2018, 10:32 AM
compnerd added a subscriber: compnerd.

LGTM. WRT the test case, is the DI needed? If not, I would strip the debug info for the test.

This revision is now accepted and ready to land.Oct 24 2018, 10:32 AM
pcc added a comment.Oct 24 2018, 11:10 AM

Yes, the DI is needed (c-reduce can't remove it, and stripping makes the problem disappear).

This revision was automatically updated to reflect the committed changes.