SROA: Skip arrays of object/matrix as well.
Fix issues with ReplaceUseOfZeroInit*
- Fix ReplaceUseOfZeroInitPostDom bailing on use of memcpy dest.
When memcpy not in entry block, any use of dest after memcpy would abort
replacement, as if it was unsafe to replace dest with src. But uses
of dest dominated by memcpy *are* safe to replace.
- Fix ReplaceUseOfZeroInit* misuse of post-dom.
Post-dom was used to detect whether it was safe to replace uses of dest
before the memcpy with zero when dest was zeroinitialized. But post-dom
is not the right way to tell if this is safe. It is unsafe if any uses
*could* follow the memcpy. So the new test is to gather a set of blocks
that could be reachable from the successors of the memcpy block (where
memcpy ends the block because we split it there). If so, it is not safe
to replace the use with zeroinitializer, and because it was not dominated
by the memcpy either, it's not safe to replace dest with src here either,
so memcpy replacement must abort.
- Re-merge blocks after splitting in ReplaceUseOfZeroInitBeforeDef.
Restore CFG after ReplaceUseOfZeroInitBeforeDef, rather than leaving it
in more of a mess to be cleaned up much later.
This has the side benefit of preserving more trivial entry-block
replacement opportunities.
DFE should apply to internal functions in lib target as well.
- Also, iterating over RemoveUnusedFunctions will allow removal of more
functions only called by other internal functions being removed.
Add LowerStaticGlobalIntoAlloca before SROA for LowerMemcpy opportunities
- Existing location after SROA must also be there for non-resource aggregates
- Don't preserve zeroinitializer when moving static GV to alloca for objects
- Minor opt in LowerStaticGlobalIntoAlloca: skip fn decls more cheaply