This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Enable implicit null check transformation
ClosedPublic

Authored by reames on Sep 17 2020, 12:35 PM.

Details

Summary

This change enables the generic implicit null transformation for the AArch64 target. As background for those unfamiliar with our implicit null check support:

  • An implicit null check is the use of a signal handler to catch and redirect to a handler a null pointer. Specifically, it's replacing an explicit conditional branch with such a redirect. This is only done for very cold branches under frontend control w/appropriate metadata.
  • FAULTING_OP is used to wrap the faulting instruction. It is modelled as being a conditional branch to reflect the fact it can transfer control in the CFG.
  • FAULTING_OP does not need to be an analyzable branch to achieve it's purpose. (Or at least, that's the x86 model. I find this slightly questionable.)
  • When lowering to MC, we convert the FAULTING_OP back into the actual instruction, record the labels, and lower the original instruction.

As can be seen in the test changes, currently the AArch64 backend does not eliminate the unconditional branch to the fallthrough block. I've tried two approaches, neither of which worked. I plan to return to this in a separate change set once I've wrapped my head around the interactions a bit better. (X86 handles this via AllowModify on analyzeBranch, but adding the obvious code causing BranchFolding to crash. I haven't yet figured out if it's a latent bug in BranchFolding, or something I'm doing wrong.)

Diff Detail

Event Timeline

reames created this revision.Sep 17 2020, 12:35 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 17 2020, 12:35 PM
reames requested review of this revision.Sep 17 2020, 12:35 PM
efriedma accepted this revision.Sep 17 2020, 1:54 PM

Please fix clang-format warnings. Otherwise LGTM.

This revision is now accepted and ready to land.Sep 17 2020, 1:54 PM
This revision was landed with ongoing or failed builds.Sep 17 2020, 4:02 PM
This revision was automatically updated to reflect the committed changes.