[PATCH] D48627: [ImplicitNullChecks] Check for rewrite of register used in 'test' instruction

Surya Kumari Jangala via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 27 03:27:11 PDT 2018


jskumari created this revision.
jskumari added reviewers: sanjoy, skatkov.
Herald added a subscriber: llvm-commits.

The following code pattern:

  mov %rax, %rcx
  test %rax, %rax
  %rax = ....
  je  throw_npe
  mov(%rcx), %r9
  mov(%rax), %r10

gets transformed into the following incorrect code after implicit null check pass:

   mov %rax, %rcx
  %rax = ....
  faulting_load_op("movl (%rax), %r10", throw_npe)
  mov(%rcx), %r9

For implicit null check pass, if the register that is checked for null value (ie, the register used in the 'test' instruction) is written into before the condition jump, we should avoid doing the optimization.


Repository:
  rL LLVM

https://reviews.llvm.org/D48627

Files:
  lib/CodeGen/ImplicitNullChecks.cpp
  test/CodeGen/X86/implicit-null-chk-reg-rewrite.mir

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48627.153032.patch
Type: text/x-patch
Size: 2642 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180627/60451dfe/attachment.bin>


More information about the llvm-commits mailing list