Mach-O LLD uses the buffer identifier of the memory buffer backing an object file to generate stabs which are used by dsymutil to find the object file for dSYM generation.
When using thinLTO, these buffers are provided by the cache which initially saves them to disk as temporary files beginning with "Thin-" but renames them to persistent files beginning with "llvmcache-" before the buffer is provided to the cache user.
However, the buffer is created before the file is renamed and is given the temp file's name as an identifier. This causes the generated stabs to point to nonexistent files.
This change names the buffer with the eventual persistent filename. I think this is safe because failing to rename the temp file is a fatal error.