[PATCH] Eliminate memcpy of undefined values

Nick Lewycky nicholas at mxc.ca
Tue Feb 4 23:45:05 PST 2014


Patrick Walton wrote:
> Hi everyone,
>
> This patch optimizes out memcpy operations that copy undefined data from
> fresh allocas. Since the data was already undefined, we can simply not
> do the memcpy and leave the data that was already there in place. SROA
> frequently creates these memcpys when aggregates that contain padding
> are copied around, so this eliminates a significant chunk (0.5% or so)
> of code from Rust binaries.

Should SROA delete the ones it creates? Does it delete alloca+load?

Either way, the patch to MemCpyOptimizer.cpp looks good. The testcase 
should be reduced to something that doesn't run -dse.

Nick



More information about the llvm-commits mailing list