[llvm] ac2165f - [coff] Don't try to write the obj if the assembler has errors (#123007)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 09:27:15 PST 2025


Author: Daniel Paoliello
Date: 2025-01-15T09:27:11-08:00
New Revision: ac2165fe7bb4626c85a9c8938dbe2448220217a5

URL: https://github.com/llvm/llvm-project/commit/ac2165fe7bb4626c85a9c8938dbe2448220217a5
DIFF: https://github.com/llvm/llvm-project/commit/ac2165fe7bb4626c85a9c8938dbe2448220217a5.diff

LOG: [coff] Don't try to write the obj if the assembler has errors (#123007)

The ASAN and MSAN tests have been failing after #122777 because some
fields are now set in `executePostLayoutBinding` which is skipped by the
assembler if it had errors but read in `writeObject`

Since the compilation has failed anyway, skip `writeObject` if the
assembler had errors.

Added: 
    

Modified: 
    llvm/lib/MC/WinCOFFObjectWriter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 39e02d0522bcfb..da0c0661117b28 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -1193,6 +1193,11 @@ void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
 }
 
 uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm) {
+  // If the assember had an error, then layout will not have completed, so we
+  // cannot write an object file.
+  if (Asm.getContext().hadError())
+    return 0;
+
   uint64_t TotalSize = ObjWriter->writeObject(Asm);
   if (DwoWriter)
     TotalSize += DwoWriter->writeObject(Asm);


        


More information about the llvm-commits mailing list