[PATCH] D87851: [AArch64] Enable implicit null check transformation

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 17 12:35:57 PDT 2020


reames created this revision.
reames added reviewers: anna, dantrushin, resistor, efriedma.
Herald added subscribers: danielkiss, jfb, bollu, hiraditya, kristof.beyls, mcrosier.
Herald added a project: LLVM.
reames requested review of this revision.

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.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D87851

Files:
  llvm/lib/CodeGen/BranchRelaxation.cpp
  llvm/lib/CodeGen/ImplicitNullChecks.cpp
  llvm/lib/Target/AArch64/AArch64AsmPrinter.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.cpp
  llvm/lib/Target/AArch64/AArch64InstrInfo.h
  llvm/test/CodeGen/AArch64/implicit-null-check.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D87851.292590.patch
Type: text/x-patch
Size: 18131 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200917/6505c87d/attachment.bin>


More information about the llvm-commits mailing list