[llvm-dev] Overlapping memcpy

Maciej Adamczyk via llvm-dev llvm-dev at lists.llvm.org
Sun Dec 6 22:33:29 PST 2015


Hello.
My friend's data compressor has a problem. During decompression stage, 
on some corrupted files, it may issue an overlapping memcpy.
He has two easy solutions for that:
  * switch to memmove
  * add a branch to detect such case
However, he's not happy with either of them as they slow the 
decompression down to handle a case that will never happen to almost 
everyone. Furthermore, we don't see anything that could fail with memcpy 
(aside from nasal elephants, but we're used to them). The copied data 
may be corrupted, but it's not a failure as the compressed data is 
corrupted already.
We see another solution, to write a custom memcpy. We'd like to avoid it 
for now as getting portable performance has proved to be a problem.
So I have two questions:
  * what are possible failures with overlapping memcpy?
  * what solution to the problem do you recommend?

Regards,

-- 
Maciej Adamczyk



More information about the llvm-dev mailing list