Loading from null is valid outside of addrspace 0
authorPhilip Reames <listmail@philipreames.com>
Mon, 29 Dec 2014 22:46:21 +0000 (22:46 +0000)
committerPhilip Reames <listmail@philipreames.com>
Mon, 29 Dec 2014 22:46:21 +0000 (22:46 +0000)
commit456b7b602ca3f9a5ec584c11172fbcce3cdc6679
tree7f1223cef52bb21be977d63dc3561139c068520b
parent02d187cdb99f077d91ae7a8e2a29ba7e4b00fcf7
Loading from null is valid outside of addrspace 0

This patches fixes a miscompile where we were assuming that loading from null is undefined and thus we could assume it doesn't happen.  This transform is perfectly legal in address space 0, but is not neccessarily legal in other address spaces.

We really should introduce a hook to control this property on a per target per address space basis.  We may be loosing valuable optimizations in some address spaces by being too conservative.

Original patch by Thomas P Raoux (submitted to llvm-commits), tests and formatting fixes by me.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224961 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/select.ll