Fold compares irrespective of whether allocation can be elided
authorAnna Thomas <anna@azul.com>
Tue, 3 May 2016 14:58:21 +0000 (14:58 +0000)
committerAnna Thomas <anna@azul.com>
Tue, 3 May 2016 14:58:21 +0000 (14:58 +0000)
commit43d7e1cbffd668e188f19784ca876032255626e4
treeb170645024f05649ac04118b7f9b446146614a3f
parentef31eafbd14a87ebc768377eb3dce42d4230455c
Fold compares irrespective of whether allocation can be elided

Summary
When a non-escaping pointer is compared to a global value, the
comparison can be folded even if the corresponding malloc/allocation
call cannot be elided.
We need to make sure the global value is not null, since comparisons to
null cannot be folded.

In future, we should also handle cases when the the comparison
instruction dominates the pointer escape.

Reviewers: sanjoy
Subscribers s.egerton, llvm-commits

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

llvm-svn: 268390
llvm/lib/Analysis/CaptureTracking.cpp
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Transforms/InstCombine/compare-unescaped.ll