In module LLVM.Module, the functions writeObjectToFile, writeLLVMAssemblyToFile, writeTargetAssemblyToFile (and possibly others) write to the named file, but if the file already exists and was longer than the number of bytes newly written, then the old data remain at the end of the file, creating a mix of old and new content.
This behavior seems surprising to me. If it is a feature, then I think it needs to be called out in the Haddock documentation. If it is a bug, then it should be easy to fix.