OSDN Git Service

SimplifyCFG: If we have a PHI node that can evaluate to NULL and do a load or store...
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 26 Aug 2011 01:22:29 +0000 (01:22 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 26 Aug 2011 01:22:29 +0000 (01:22 +0000)
commit98d6d2372feb2f8bb4c3941b278027499cbfc00b
treecb59e69fde14c5b6d82f15ca93ffac2204b3a510
parent1a9a2d0d6b16cea4cf98fdce5db597008453cbd6
SimplifyCFG: If we have a PHI node that can evaluate to NULL and do a load or store to the address returned by the PHI node then we can consider this incoming value as dead and remove the edge pointing there, unless there are instructions that can affect control flow executed in between.

In theory this could be extended to other instructions, eg. division by zero, but it's likely that it will "miscompile" some code because people depend on div by zero not trapping. NULL pointer dereference usually leads to a crash so we should be on the safe side.

This shrinks the size of a Release clang by 16k on x86_64.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138618 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Utils/SimplifyCFG.cpp
test/Transforms/SimplifyCFG/phi-undef-loadstore.ll [new file with mode: 0644]