Closed apsun closed 2 years ago
Seems clang generates a "mem* instruction" (https://github.com/llvm/llvm-project/blob/f3e9047249d05ff2fb79076dbfbbdad4a35fbc63/llvm/include/llvm/IR/IntrinsicInst.h#L874) as part of its optimization passes.
FWIW, rep movsb is still fast enough to watch video (since we're bottlenecked on copying packets from ne2k). So we could go back to doing that if there's no way to disable this behavior.
Apparently clang only generated this because I wrote word_t word = {0};
in memset
... Initializing the bytes one at a time avoids the memset recursion. Fixed with 3efea79e81c016834f6822210c1752cf81661398
Building with clang and optimizations disabled causes infinite recursion. Apparently clang synthesizes a call to memset... inside of memset. -fno-builtin does not help (IIRC all it does is disable the builtin aliases for e.g. memcpy -> __builtin_memcpy, not prevent the builtins from being used).
Potential solutions, off the top of my head: