[PATCH] D47398: [WebAssembly] MC: Add compile-twice test and fix corresponding bug

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 25 16:35:36 PDT 2018


sbc100 created this revision.
Herald added subscribers: llvm-commits, sunfish, aheejin, jgravelle-google, dschuff.

Repository:
  rL LLVM

https://reviews.llvm.org/D47398

Files:
  lib/MC/MCContext.cpp
  lib/MC/WasmObjectWriter.cpp
  test/MC/WebAssembly/compile-twice.ll


Index: test/MC/WebAssembly/compile-twice.ll
===================================================================
--- /dev/null
+++ test/MC/WebAssembly/compile-twice.ll
@@ -0,0 +1,14 @@
+; Check that there is no persistent state in the MachO emitter that crashes
+; us when reusing the pass manager.
+; RUN: llc -mtriple=wasm32-unknown-unknown -compile-twice -filetype=obj %s -o -
+
+; Force the creation of a DWARF section
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4}
+
+ at myglobal = global i32 0, align 4
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "LLVM", isOptimized: true, emissionKind: FullDebug)
+!1 = !DIFile(filename: "<stdin>", directory: "/")
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
Index: lib/MC/WasmObjectWriter.cpp
===================================================================
--- lib/MC/WasmObjectWriter.cpp
+++ lib/MC/WasmObjectWriter.cpp
@@ -270,9 +270,9 @@
     Globals.clear();
     DataSegments.clear();
     SectionFunctions.clear();
-    MCObjectWriter::reset();
     NumFunctionImports = 0;
     NumGlobalImports = 0;
+    MCObjectWriter::reset();
   }
 
   void writeHeader(const MCAssembler &Asm);
Index: lib/MC/MCContext.cpp
===================================================================
--- lib/MC/MCContext.cpp
+++ lib/MC/MCContext.cpp
@@ -105,6 +105,7 @@
   MachOUniquingMap.clear();
   ELFUniquingMap.clear();
   COFFUniquingMap.clear();
+  WasmUniquingMap.clear();
 
   NextID.clear();
   AllowTemporaryLabels = true;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47398.148686.patch
Type: text/x-patch
Size: 1542 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180525/9d596b35/attachment.bin>


More information about the llvm-commits mailing list