[ImplicitNullChecks] Be smarter in picking the memory op.
authorSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 9 Jul 2015 20:13:25 +0000 (20:13 +0000)
committerSanjoy Das <sanjoy@playingwithpointers.com>
Thu, 9 Jul 2015 20:13:25 +0000 (20:13 +0000)
commita5a3e2d58a1d887f2b0591d34bc2549fc1512536
treea1201f97944b0219641ebc6332b42d68e2f1d340
parent377796abdf17caa54e84daa29925efe6e7679bdc
[ImplicitNullChecks] Be smarter in picking the memory op.

Summary:
Before this change ImplicitNullChecks would only pick loads of the form:

```
   test Reg, Reg
   jz elsewhere
 fallthrough:
   movl 32(Reg), Reg2
```

but not (say)

```
   test Reg, Reg
   jz elsewhere
 fallthrough:
   inc Reg3
   movl 32(Reg), Reg2
```

This change teaches ImplicitNullChecks to look through "unrelated"
instructions like `inc Reg3` when searching for a load instruction
to convert to a trapping load.

Reviewers: atrick, JosephTremoulet, reames

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D11044

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@241850 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/ImplicitNullChecks.cpp
test/CodeGen/X86/implicit-null-check-negative.ll
test/CodeGen/X86/implicit-null-check.ll